babylon.d.ts 3.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307
  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. * The options Interface for creating a Capsule Mesh
  6820. */
  6821. export interface ICreateCapsuleOptions {
  6822. /** The Orientation of the capsule. Default : Vector3.Up() */
  6823. orientation: Vector3;
  6824. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6825. subdivisions: number;
  6826. /** Number of cylindrical segments on the capsule. */
  6827. tessellation: number;
  6828. /** Height or Length of the capsule. */
  6829. height: number;
  6830. /** Radius of the capsule. */
  6831. radius: number;
  6832. /** Height or Length of the capsule. */
  6833. capSubdivisions: number;
  6834. /** Overwrite for the top radius. */
  6835. radiusTop?: number;
  6836. /** Overwrite for the bottom radius. */
  6837. radiusBottom?: number;
  6838. /** Overwrite for the top capSubdivisions. */
  6839. topCapSubdivisions?: number;
  6840. /** Overwrite for the bottom capSubdivisions. */
  6841. bottomCapSubdivisions?: number;
  6842. }
  6843. /**
  6844. * Class containing static functions to help procedurally build meshes
  6845. */
  6846. export class CapsuleBuilder {
  6847. /**
  6848. * Creates a capsule or a pill mesh
  6849. * @param name defines the name of the mesh
  6850. * @param options The constructors options.
  6851. * @param scene The scene the mesh is scoped to.
  6852. * @returns Capsule Mesh
  6853. */
  6854. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6855. }
  6856. }
  6857. declare module BABYLON {
  6858. /**
  6859. * @hidden
  6860. */
  6861. export class IntersectionInfo {
  6862. bu: Nullable<number>;
  6863. bv: Nullable<number>;
  6864. distance: number;
  6865. faceId: number;
  6866. subMeshId: number;
  6867. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6868. }
  6869. }
  6870. declare module BABYLON {
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module BABYLON {
  6957. /**
  6958. * Class used to store bounding box information
  6959. */
  6960. export class BoundingBox implements ICullable {
  6961. /**
  6962. * Gets the 8 vectors representing the bounding box in local space
  6963. */
  6964. readonly vectors: Vector3[];
  6965. /**
  6966. * Gets the center of the bounding box in local space
  6967. */
  6968. readonly center: Vector3;
  6969. /**
  6970. * Gets the center of the bounding box in world space
  6971. */
  6972. readonly centerWorld: Vector3;
  6973. /**
  6974. * Gets the extend size in local space
  6975. */
  6976. readonly extendSize: Vector3;
  6977. /**
  6978. * Gets the extend size in world space
  6979. */
  6980. readonly extendSizeWorld: Vector3;
  6981. /**
  6982. * Gets the OBB (object bounding box) directions
  6983. */
  6984. readonly directions: Vector3[];
  6985. /**
  6986. * Gets the 8 vectors representing the bounding box in world space
  6987. */
  6988. readonly vectorsWorld: Vector3[];
  6989. /**
  6990. * Gets the minimum vector in world space
  6991. */
  6992. readonly minimumWorld: Vector3;
  6993. /**
  6994. * Gets the maximum vector in world space
  6995. */
  6996. readonly maximumWorld: Vector3;
  6997. /**
  6998. * Gets the minimum vector in local space
  6999. */
  7000. readonly minimum: Vector3;
  7001. /**
  7002. * Gets the maximum vector in local space
  7003. */
  7004. readonly maximum: Vector3;
  7005. private _worldMatrix;
  7006. private static readonly TmpVector3;
  7007. /**
  7008. * @hidden
  7009. */
  7010. _tag: number;
  7011. /**
  7012. * Creates a new bounding box
  7013. * @param min defines the minimum vector (in local space)
  7014. * @param max defines the maximum vector (in local space)
  7015. * @param worldMatrix defines the new world matrix
  7016. */
  7017. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7018. /**
  7019. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7020. * @param min defines the new minimum vector (in local space)
  7021. * @param max defines the new maximum vector (in local space)
  7022. * @param worldMatrix defines the new world matrix
  7023. */
  7024. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7025. /**
  7026. * Scale the current bounding box by applying a scale factor
  7027. * @param factor defines the scale factor to apply
  7028. * @returns the current bounding box
  7029. */
  7030. scale(factor: number): BoundingBox;
  7031. /**
  7032. * Gets the world matrix of the bounding box
  7033. * @returns a matrix
  7034. */
  7035. getWorldMatrix(): DeepImmutable<Matrix>;
  7036. /** @hidden */
  7037. _update(world: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Tests if the bounding box is intersecting the frustum planes
  7040. * @param frustumPlanes defines the frustum planes to test
  7041. * @returns true if there is an intersection
  7042. */
  7043. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7044. /**
  7045. * Tests if the bounding box is entirely inside the frustum planes
  7046. * @param frustumPlanes defines the frustum planes to test
  7047. * @returns true if there is an inclusion
  7048. */
  7049. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7050. /**
  7051. * Tests if a point is inside the bounding box
  7052. * @param point defines the point to test
  7053. * @returns true if the point is inside the bounding box
  7054. */
  7055. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7056. /**
  7057. * Tests if the bounding box intersects with a bounding sphere
  7058. * @param sphere defines the sphere to test
  7059. * @returns true if there is an intersection
  7060. */
  7061. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7062. /**
  7063. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7064. * @param min defines the min vector to use
  7065. * @param max defines the max vector to use
  7066. * @returns true if there is an intersection
  7067. */
  7068. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if two bounding boxes are intersections
  7071. * @param box0 defines the first box to test
  7072. * @param box1 defines the second box to test
  7073. * @returns true if there is an intersection
  7074. */
  7075. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7076. /**
  7077. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7078. * @param minPoint defines the minimum vector of the bounding box
  7079. * @param maxPoint defines the maximum vector of the bounding box
  7080. * @param sphereCenter defines the sphere center
  7081. * @param sphereRadius defines the sphere radius
  7082. * @returns true if there is an intersection
  7083. */
  7084. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7085. /**
  7086. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7087. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7088. * @param frustumPlanes defines the frustum planes to test
  7089. * @return true if there is an inclusion
  7090. */
  7091. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7092. /**
  7093. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7094. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7095. * @param frustumPlanes defines the frustum planes to test
  7096. * @return true if there is an intersection
  7097. */
  7098. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7099. }
  7100. }
  7101. declare module BABYLON {
  7102. /** @hidden */
  7103. export class Collider {
  7104. /** Define if a collision was found */
  7105. collisionFound: boolean;
  7106. /**
  7107. * Define last intersection point in local space
  7108. */
  7109. intersectionPoint: Vector3;
  7110. /**
  7111. * Define last collided mesh
  7112. */
  7113. collidedMesh: Nullable<AbstractMesh>;
  7114. private _collisionPoint;
  7115. private _planeIntersectionPoint;
  7116. private _tempVector;
  7117. private _tempVector2;
  7118. private _tempVector3;
  7119. private _tempVector4;
  7120. private _edge;
  7121. private _baseToVertex;
  7122. private _destinationPoint;
  7123. private _slidePlaneNormal;
  7124. private _displacementVector;
  7125. /** @hidden */
  7126. _radius: Vector3;
  7127. /** @hidden */
  7128. _retry: number;
  7129. private _velocity;
  7130. private _basePoint;
  7131. private _epsilon;
  7132. /** @hidden */
  7133. _velocityWorldLength: number;
  7134. /** @hidden */
  7135. _basePointWorld: Vector3;
  7136. private _velocityWorld;
  7137. private _normalizedVelocity;
  7138. /** @hidden */
  7139. _initialVelocity: Vector3;
  7140. /** @hidden */
  7141. _initialPosition: Vector3;
  7142. private _nearestDistance;
  7143. private _collisionMask;
  7144. get collisionMask(): number;
  7145. set collisionMask(mask: number);
  7146. /**
  7147. * Gets the plane normal used to compute the sliding response (in local space)
  7148. */
  7149. get slidePlaneNormal(): Vector3;
  7150. /** @hidden */
  7151. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7152. /** @hidden */
  7153. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7154. /** @hidden */
  7155. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7156. /** @hidden */
  7157. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7158. /** @hidden */
  7159. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7160. /** @hidden */
  7161. _getResponse(pos: Vector3, vel: Vector3): void;
  7162. }
  7163. }
  7164. declare module BABYLON {
  7165. /**
  7166. * Interface for cullable objects
  7167. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7168. */
  7169. export interface ICullable {
  7170. /**
  7171. * Checks if the object or part of the object is in the frustum
  7172. * @param frustumPlanes Camera near/planes
  7173. * @returns true if the object is in frustum otherwise false
  7174. */
  7175. isInFrustum(frustumPlanes: Plane[]): boolean;
  7176. /**
  7177. * Checks if a cullable object (mesh...) is in the camera frustum
  7178. * Unlike isInFrustum this cheks the full bounding box
  7179. * @param frustumPlanes Camera near/planes
  7180. * @returns true if the object is in frustum otherwise false
  7181. */
  7182. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7183. }
  7184. /**
  7185. * Info for a bounding data of a mesh
  7186. */
  7187. export class BoundingInfo implements ICullable {
  7188. /**
  7189. * Bounding box for the mesh
  7190. */
  7191. readonly boundingBox: BoundingBox;
  7192. /**
  7193. * Bounding sphere for the mesh
  7194. */
  7195. readonly boundingSphere: BoundingSphere;
  7196. private _isLocked;
  7197. private static readonly TmpVector3;
  7198. /**
  7199. * Constructs bounding info
  7200. * @param minimum min vector of the bounding box/sphere
  7201. * @param maximum max vector of the bounding box/sphere
  7202. * @param worldMatrix defines the new world matrix
  7203. */
  7204. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7205. /**
  7206. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7207. * @param min defines the new minimum vector (in local space)
  7208. * @param max defines the new maximum vector (in local space)
  7209. * @param worldMatrix defines the new world matrix
  7210. */
  7211. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7212. /**
  7213. * min vector of the bounding box/sphere
  7214. */
  7215. get minimum(): Vector3;
  7216. /**
  7217. * max vector of the bounding box/sphere
  7218. */
  7219. get maximum(): Vector3;
  7220. /**
  7221. * If the info is locked and won't be updated to avoid perf overhead
  7222. */
  7223. get isLocked(): boolean;
  7224. set isLocked(value: boolean);
  7225. /**
  7226. * Updates the bounding sphere and box
  7227. * @param world world matrix to be used to update
  7228. */
  7229. update(world: DeepImmutable<Matrix>): void;
  7230. /**
  7231. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7232. * @param center New center of the bounding info
  7233. * @param extend New extend of the bounding info
  7234. * @returns the current bounding info
  7235. */
  7236. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7237. /**
  7238. * Scale the current bounding info by applying a scale factor
  7239. * @param factor defines the scale factor to apply
  7240. * @returns the current bounding info
  7241. */
  7242. scale(factor: number): BoundingInfo;
  7243. /**
  7244. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7245. * @param frustumPlanes defines the frustum to test
  7246. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7247. * @returns true if the bounding info is in the frustum planes
  7248. */
  7249. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7250. /**
  7251. * Gets the world distance between the min and max points of the bounding box
  7252. */
  7253. get diagonalLength(): number;
  7254. /**
  7255. * Checks if a cullable object (mesh...) is in the camera frustum
  7256. * Unlike isInFrustum this cheks the full bounding box
  7257. * @param frustumPlanes Camera near/planes
  7258. * @returns true if the object is in frustum otherwise false
  7259. */
  7260. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7261. /** @hidden */
  7262. _checkCollision(collider: Collider): boolean;
  7263. /**
  7264. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7265. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7266. * @param point the point to check intersection with
  7267. * @returns if the point intersects
  7268. */
  7269. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7270. /**
  7271. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7272. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7273. * @param boundingInfo the bounding info to check intersection with
  7274. * @param precise if the intersection should be done using OBB
  7275. * @returns if the bounding info intersects
  7276. */
  7277. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7278. }
  7279. }
  7280. declare module BABYLON {
  7281. /**
  7282. * Extracts minimum and maximum values from a list of indexed positions
  7283. * @param positions defines the positions to use
  7284. * @param indices defines the indices to the positions
  7285. * @param indexStart defines the start index
  7286. * @param indexCount defines the end index
  7287. * @param bias defines bias value to add to the result
  7288. * @return minimum and maximum values
  7289. */
  7290. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7291. minimum: Vector3;
  7292. maximum: Vector3;
  7293. };
  7294. /**
  7295. * Extracts minimum and maximum values from a list of positions
  7296. * @param positions defines the positions to use
  7297. * @param start defines the start index in the positions array
  7298. * @param count defines the number of positions to handle
  7299. * @param bias defines bias value to add to the result
  7300. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7301. * @return minimum and maximum values
  7302. */
  7303. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7304. minimum: Vector3;
  7305. maximum: Vector3;
  7306. };
  7307. }
  7308. declare module BABYLON {
  7309. /** @hidden */
  7310. export class WebGLDataBuffer extends DataBuffer {
  7311. private _buffer;
  7312. constructor(resource: WebGLBuffer);
  7313. get underlyingResource(): any;
  7314. }
  7315. }
  7316. declare module BABYLON {
  7317. /** @hidden */
  7318. export class WebGLPipelineContext implements IPipelineContext {
  7319. engine: ThinEngine;
  7320. program: Nullable<WebGLProgram>;
  7321. context?: WebGLRenderingContext;
  7322. vertexShader?: WebGLShader;
  7323. fragmentShader?: WebGLShader;
  7324. isParallelCompiled: boolean;
  7325. onCompiled?: () => void;
  7326. transformFeedback?: WebGLTransformFeedback | null;
  7327. vertexCompilationError: Nullable<string>;
  7328. fragmentCompilationError: Nullable<string>;
  7329. programLinkError: Nullable<string>;
  7330. programValidationError: Nullable<string>;
  7331. get isAsync(): boolean;
  7332. get isReady(): boolean;
  7333. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7334. _getVertexShaderCode(): string | null;
  7335. _getFragmentShaderCode(): string | null;
  7336. }
  7337. }
  7338. declare module BABYLON {
  7339. interface ThinEngine {
  7340. /**
  7341. * Create an uniform buffer
  7342. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7343. * @param elements defines the content of the uniform buffer
  7344. * @returns the webGL uniform buffer
  7345. */
  7346. createUniformBuffer(elements: FloatArray): DataBuffer;
  7347. /**
  7348. * Create a dynamic uniform buffer
  7349. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7350. * @param elements defines the content of the uniform buffer
  7351. * @returns the webGL uniform buffer
  7352. */
  7353. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7354. /**
  7355. * Update an existing uniform buffer
  7356. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7357. * @param uniformBuffer defines the target uniform buffer
  7358. * @param elements defines the content to update
  7359. * @param offset defines the offset in the uniform buffer where update should start
  7360. * @param count defines the size of the data to update
  7361. */
  7362. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7363. /**
  7364. * Bind an uniform buffer to the current webGL context
  7365. * @param buffer defines the buffer to bind
  7366. */
  7367. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7368. /**
  7369. * Bind a buffer to the current webGL context at a given location
  7370. * @param buffer defines the buffer to bind
  7371. * @param location defines the index where to bind the buffer
  7372. */
  7373. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7374. /**
  7375. * Bind a specific block at a given index in a specific shader program
  7376. * @param pipelineContext defines the pipeline context to use
  7377. * @param blockName defines the block name
  7378. * @param index defines the index where to bind the block
  7379. */
  7380. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7381. }
  7382. }
  7383. declare module BABYLON {
  7384. /**
  7385. * Uniform buffer objects.
  7386. *
  7387. * Handles blocks of uniform on the GPU.
  7388. *
  7389. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7390. *
  7391. * For more information, please refer to :
  7392. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7393. */
  7394. export class UniformBuffer {
  7395. private _engine;
  7396. private _buffer;
  7397. private _data;
  7398. private _bufferData;
  7399. private _dynamic?;
  7400. private _uniformLocations;
  7401. private _uniformSizes;
  7402. private _uniformLocationPointer;
  7403. private _needSync;
  7404. private _noUBO;
  7405. private _currentEffect;
  7406. /** @hidden */
  7407. _alreadyBound: boolean;
  7408. private static _MAX_UNIFORM_SIZE;
  7409. private static _tempBuffer;
  7410. /**
  7411. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7416. /**
  7417. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7422. /**
  7423. * Lambda to Update a single float in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateFloat: (name: string, x: number) => void;
  7428. /**
  7429. * Lambda to Update a vec2 of float in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7434. /**
  7435. * Lambda to Update a vec3 of float in a uniform buffer.
  7436. * This is dynamic to allow compat with webgl 1 and 2.
  7437. * You will need to pass the name of the uniform as well as the value.
  7438. */
  7439. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7440. /**
  7441. * Lambda to Update a vec4 of float in a uniform buffer.
  7442. * This is dynamic to allow compat with webgl 1 and 2.
  7443. * You will need to pass the name of the uniform as well as the value.
  7444. */
  7445. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7446. /**
  7447. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7448. * This is dynamic to allow compat with webgl 1 and 2.
  7449. * You will need to pass the name of the uniform as well as the value.
  7450. */
  7451. updateMatrix: (name: string, mat: Matrix) => void;
  7452. /**
  7453. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateVector3: (name: string, vector: Vector3) => void;
  7458. /**
  7459. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateVector4: (name: string, vector: Vector4) => void;
  7464. /**
  7465. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7470. /**
  7471. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7476. /**
  7477. * Instantiates a new Uniform buffer objects.
  7478. *
  7479. * Handles blocks of uniform on the GPU.
  7480. *
  7481. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7482. *
  7483. * For more information, please refer to :
  7484. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7485. * @param engine Define the engine the buffer is associated with
  7486. * @param data Define the data contained in the buffer
  7487. * @param dynamic Define if the buffer is updatable
  7488. */
  7489. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7490. /**
  7491. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7492. * or just falling back on setUniformXXX calls.
  7493. */
  7494. get useUbo(): boolean;
  7495. /**
  7496. * Indicates if the WebGL underlying uniform buffer is in sync
  7497. * with the javascript cache data.
  7498. */
  7499. get isSync(): boolean;
  7500. /**
  7501. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7502. * Also, a dynamic UniformBuffer will disable cache verification and always
  7503. * update the underlying WebGL uniform buffer to the GPU.
  7504. * @returns if Dynamic, otherwise false
  7505. */
  7506. isDynamic(): boolean;
  7507. /**
  7508. * The data cache on JS side.
  7509. * @returns the underlying data as a float array
  7510. */
  7511. getData(): Float32Array;
  7512. /**
  7513. * The underlying WebGL Uniform buffer.
  7514. * @returns the webgl buffer
  7515. */
  7516. getBuffer(): Nullable<DataBuffer>;
  7517. /**
  7518. * std140 layout specifies how to align data within an UBO structure.
  7519. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7520. * for specs.
  7521. */
  7522. private _fillAlignment;
  7523. /**
  7524. * Adds an uniform in the buffer.
  7525. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7526. * for the layout to be correct !
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param size Data size, or data directly.
  7529. */
  7530. addUniform(name: string, size: number | number[]): void;
  7531. /**
  7532. * Adds a Matrix 4x4 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. * @param mat A 4x4 matrix.
  7535. */
  7536. addMatrix(name: string, mat: Matrix): void;
  7537. /**
  7538. * Adds a vec2 to the uniform buffer.
  7539. * @param name Name of the uniform, as used in the uniform block in the shader.
  7540. * @param x Define the x component value of the vec2
  7541. * @param y Define the y component value of the vec2
  7542. */
  7543. addFloat2(name: string, x: number, y: number): void;
  7544. /**
  7545. * Adds a vec3 to the uniform buffer.
  7546. * @param name Name of the uniform, as used in the uniform block in the shader.
  7547. * @param x Define the x component value of the vec3
  7548. * @param y Define the y component value of the vec3
  7549. * @param z Define the z component value of the vec3
  7550. */
  7551. addFloat3(name: string, x: number, y: number, z: number): void;
  7552. /**
  7553. * Adds a vec3 to the uniform buffer.
  7554. * @param name Name of the uniform, as used in the uniform block in the shader.
  7555. * @param color Define the vec3 from a Color
  7556. */
  7557. addColor3(name: string, color: Color3): void;
  7558. /**
  7559. * Adds a vec4 to the uniform buffer.
  7560. * @param name Name of the uniform, as used in the uniform block in the shader.
  7561. * @param color Define the rgb components from a Color
  7562. * @param alpha Define the a component of the vec4
  7563. */
  7564. addColor4(name: string, color: Color3, alpha: number): void;
  7565. /**
  7566. * Adds a vec3 to the uniform buffer.
  7567. * @param name Name of the uniform, as used in the uniform block in the shader.
  7568. * @param vector Define the vec3 components from a Vector
  7569. */
  7570. addVector3(name: string, vector: Vector3): void;
  7571. /**
  7572. * Adds a Matrix 3x3 to the uniform buffer.
  7573. * @param name Name of the uniform, as used in the uniform block in the shader.
  7574. */
  7575. addMatrix3x3(name: string): void;
  7576. /**
  7577. * Adds a Matrix 2x2 to the uniform buffer.
  7578. * @param name Name of the uniform, as used in the uniform block in the shader.
  7579. */
  7580. addMatrix2x2(name: string): void;
  7581. /**
  7582. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7583. */
  7584. create(): void;
  7585. /** @hidden */
  7586. _rebuild(): void;
  7587. /**
  7588. * Updates the WebGL Uniform Buffer on the GPU.
  7589. * If the `dynamic` flag is set to true, no cache comparison is done.
  7590. * Otherwise, the buffer will be updated only if the cache differs.
  7591. */
  7592. update(): void;
  7593. /**
  7594. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7595. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7596. * @param data Define the flattened data
  7597. * @param size Define the size of the data.
  7598. */
  7599. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7600. private _valueCache;
  7601. private _cacheMatrix;
  7602. private _updateMatrix3x3ForUniform;
  7603. private _updateMatrix3x3ForEffect;
  7604. private _updateMatrix2x2ForEffect;
  7605. private _updateMatrix2x2ForUniform;
  7606. private _updateFloatForEffect;
  7607. private _updateFloatForUniform;
  7608. private _updateFloat2ForEffect;
  7609. private _updateFloat2ForUniform;
  7610. private _updateFloat3ForEffect;
  7611. private _updateFloat3ForUniform;
  7612. private _updateFloat4ForEffect;
  7613. private _updateFloat4ForUniform;
  7614. private _updateMatrixForEffect;
  7615. private _updateMatrixForUniform;
  7616. private _updateVector3ForEffect;
  7617. private _updateVector3ForUniform;
  7618. private _updateVector4ForEffect;
  7619. private _updateVector4ForUniform;
  7620. private _updateColor3ForEffect;
  7621. private _updateColor3ForUniform;
  7622. private _updateColor4ForEffect;
  7623. private _updateColor4ForUniform;
  7624. /**
  7625. * Sets a sampler uniform on the effect.
  7626. * @param name Define the name of the sampler.
  7627. * @param texture Define the texture to set in the sampler
  7628. */
  7629. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7630. /**
  7631. * Directly updates the value of the uniform in the cache AND on the GPU.
  7632. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7633. * @param data Define the flattened data
  7634. */
  7635. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7636. /**
  7637. * Binds this uniform buffer to an effect.
  7638. * @param effect Define the effect to bind the buffer to
  7639. * @param name Name of the uniform block in the shader.
  7640. */
  7641. bindToEffect(effect: Effect, name: string): void;
  7642. /**
  7643. * Disposes the uniform buffer.
  7644. */
  7645. dispose(): void;
  7646. }
  7647. }
  7648. declare module BABYLON {
  7649. /**
  7650. * Enum that determines the text-wrapping mode to use.
  7651. */
  7652. export enum InspectableType {
  7653. /**
  7654. * Checkbox for booleans
  7655. */
  7656. Checkbox = 0,
  7657. /**
  7658. * Sliders for numbers
  7659. */
  7660. Slider = 1,
  7661. /**
  7662. * Vector3
  7663. */
  7664. Vector3 = 2,
  7665. /**
  7666. * Quaternions
  7667. */
  7668. Quaternion = 3,
  7669. /**
  7670. * Color3
  7671. */
  7672. Color3 = 4,
  7673. /**
  7674. * String
  7675. */
  7676. String = 5
  7677. }
  7678. /**
  7679. * Interface used to define custom inspectable properties.
  7680. * This interface is used by the inspector to display custom property grids
  7681. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7682. */
  7683. export interface IInspectable {
  7684. /**
  7685. * Gets the label to display
  7686. */
  7687. label: string;
  7688. /**
  7689. * Gets the name of the property to edit
  7690. */
  7691. propertyName: string;
  7692. /**
  7693. * Gets the type of the editor to use
  7694. */
  7695. type: InspectableType;
  7696. /**
  7697. * Gets the minimum value of the property when using in "slider" mode
  7698. */
  7699. min?: number;
  7700. /**
  7701. * Gets the maximum value of the property when using in "slider" mode
  7702. */
  7703. max?: number;
  7704. /**
  7705. * Gets the setp to use when using in "slider" mode
  7706. */
  7707. step?: number;
  7708. }
  7709. }
  7710. declare module BABYLON {
  7711. /**
  7712. * Class used to provide helper for timing
  7713. */
  7714. export class TimingTools {
  7715. /**
  7716. * Polyfill for setImmediate
  7717. * @param action defines the action to execute after the current execution block
  7718. */
  7719. static SetImmediate(action: () => void): void;
  7720. }
  7721. }
  7722. declare module BABYLON {
  7723. /**
  7724. * Class used to enable instatition of objects by class name
  7725. */
  7726. export class InstantiationTools {
  7727. /**
  7728. * Use this object to register external classes like custom textures or material
  7729. * to allow the laoders to instantiate them
  7730. */
  7731. static RegisteredExternalClasses: {
  7732. [key: string]: Object;
  7733. };
  7734. /**
  7735. * Tries to instantiate a new object from a given class name
  7736. * @param className defines the class name to instantiate
  7737. * @returns the new object or null if the system was not able to do the instantiation
  7738. */
  7739. static Instantiate(className: string): any;
  7740. }
  7741. }
  7742. declare module BABYLON {
  7743. /**
  7744. * Define options used to create a depth texture
  7745. */
  7746. export class DepthTextureCreationOptions {
  7747. /** Specifies whether or not a stencil should be allocated in the texture */
  7748. generateStencil?: boolean;
  7749. /** Specifies whether or not bilinear filtering is enable on the texture */
  7750. bilinearFiltering?: boolean;
  7751. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7752. comparisonFunction?: number;
  7753. /** Specifies if the created texture is a cube texture */
  7754. isCube?: boolean;
  7755. }
  7756. }
  7757. declare module BABYLON {
  7758. interface ThinEngine {
  7759. /**
  7760. * Creates a depth stencil cube texture.
  7761. * This is only available in WebGL 2.
  7762. * @param size The size of face edge in the cube texture.
  7763. * @param options The options defining the cube texture.
  7764. * @returns The cube texture
  7765. */
  7766. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7767. /**
  7768. * Creates a cube texture
  7769. * @param rootUrl defines the url where the files to load is located
  7770. * @param scene defines the current scene
  7771. * @param files defines the list of files to load (1 per face)
  7772. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7773. * @param onLoad defines an optional callback raised when the texture is loaded
  7774. * @param onError defines an optional callback raised if there is an issue to load the texture
  7775. * @param format defines the format of the data
  7776. * @param forcedExtension defines the extension to use to pick the right loader
  7777. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7778. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7779. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7780. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7781. * @returns the cube texture as an InternalTexture
  7782. */
  7783. 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;
  7784. /**
  7785. * Creates a cube texture
  7786. * @param rootUrl defines the url where the files to load is located
  7787. * @param scene defines the current scene
  7788. * @param files defines the list of files to load (1 per face)
  7789. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7790. * @param onLoad defines an optional callback raised when the texture is loaded
  7791. * @param onError defines an optional callback raised if there is an issue to load the texture
  7792. * @param format defines the format of the data
  7793. * @param forcedExtension defines the extension to use to pick the right loader
  7794. * @returns the cube texture as an InternalTexture
  7795. */
  7796. 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;
  7797. /**
  7798. * Creates a cube texture
  7799. * @param rootUrl defines the url where the files to load is located
  7800. * @param scene defines the current scene
  7801. * @param files defines the list of files to load (1 per face)
  7802. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7803. * @param onLoad defines an optional callback raised when the texture is loaded
  7804. * @param onError defines an optional callback raised if there is an issue to load the texture
  7805. * @param format defines the format of the data
  7806. * @param forcedExtension defines the extension to use to pick the right loader
  7807. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7808. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7809. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7810. * @returns the cube texture as an InternalTexture
  7811. */
  7812. 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;
  7813. /** @hidden */
  7814. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7815. /** @hidden */
  7816. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7817. /** @hidden */
  7818. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7819. /** @hidden */
  7820. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7821. /**
  7822. * @hidden
  7823. */
  7824. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7825. }
  7826. }
  7827. declare module BABYLON {
  7828. /**
  7829. * Class for creating a cube texture
  7830. */
  7831. export class CubeTexture extends BaseTexture {
  7832. private _delayedOnLoad;
  7833. /**
  7834. * Observable triggered once the texture has been loaded.
  7835. */
  7836. onLoadObservable: Observable<CubeTexture>;
  7837. /**
  7838. * The url of the texture
  7839. */
  7840. url: string;
  7841. /**
  7842. * Gets or sets the center of the bounding box associated with the cube texture.
  7843. * It must define where the camera used to render the texture was set
  7844. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7845. */
  7846. boundingBoxPosition: Vector3;
  7847. private _boundingBoxSize;
  7848. /**
  7849. * Gets or sets the size of the bounding box associated with the cube texture
  7850. * When defined, the cubemap will switch to local mode
  7851. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7852. * @example https://www.babylonjs-playground.com/#RNASML
  7853. */
  7854. set boundingBoxSize(value: Vector3);
  7855. /**
  7856. * Returns the bounding box size
  7857. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7858. */
  7859. get boundingBoxSize(): Vector3;
  7860. protected _rotationY: number;
  7861. /**
  7862. * Sets texture matrix rotation angle around Y axis in radians.
  7863. */
  7864. set rotationY(value: number);
  7865. /**
  7866. * Gets texture matrix rotation angle around Y axis radians.
  7867. */
  7868. get rotationY(): number;
  7869. /**
  7870. * Are mip maps generated for this texture or not.
  7871. */
  7872. get noMipmap(): boolean;
  7873. private _noMipmap;
  7874. private _files;
  7875. protected _forcedExtension: Nullable<string>;
  7876. private _extensions;
  7877. private _textureMatrix;
  7878. private _format;
  7879. private _createPolynomials;
  7880. /**
  7881. * Creates a cube texture from an array of image urls
  7882. * @param files defines an array of image urls
  7883. * @param scene defines the hosting scene
  7884. * @param noMipmap specifies if mip maps are not used
  7885. * @returns a cube texture
  7886. */
  7887. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7888. /**
  7889. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7890. * @param url defines the url of the prefiltered texture
  7891. * @param scene defines the scene the texture is attached to
  7892. * @param forcedExtension defines the extension of the file if different from the url
  7893. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7894. * @return the prefiltered texture
  7895. */
  7896. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7897. /**
  7898. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7899. * as prefiltered data.
  7900. * @param rootUrl defines the url of the texture or the root name of the six images
  7901. * @param null defines the scene or engine the texture is attached to
  7902. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7903. * @param noMipmap defines if mipmaps should be created or not
  7904. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7905. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7906. * @param onError defines a callback triggered in case of error during load
  7907. * @param format defines the internal format to use for the texture once loaded
  7908. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7909. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7910. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7911. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7912. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7913. * @return the cube texture
  7914. */
  7915. 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);
  7916. /**
  7917. * Get the current class name of the texture useful for serialization or dynamic coding.
  7918. * @returns "CubeTexture"
  7919. */
  7920. getClassName(): string;
  7921. /**
  7922. * Update the url (and optional buffer) of this texture if url was null during construction.
  7923. * @param url the url of the texture
  7924. * @param forcedExtension defines the extension to use
  7925. * @param onLoad callback called when the texture is loaded (defaults to null)
  7926. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7927. */
  7928. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7929. /**
  7930. * Delays loading of the cube texture
  7931. * @param forcedExtension defines the extension to use
  7932. */
  7933. delayLoad(forcedExtension?: string): void;
  7934. /**
  7935. * Returns the reflection texture matrix
  7936. * @returns the reflection texture matrix
  7937. */
  7938. getReflectionTextureMatrix(): Matrix;
  7939. /**
  7940. * Sets the reflection texture matrix
  7941. * @param value Reflection texture matrix
  7942. */
  7943. setReflectionTextureMatrix(value: Matrix): void;
  7944. /**
  7945. * Parses text to create a cube texture
  7946. * @param parsedTexture define the serialized text to read from
  7947. * @param scene defines the hosting scene
  7948. * @param rootUrl defines the root url of the cube texture
  7949. * @returns a cube texture
  7950. */
  7951. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7952. /**
  7953. * Makes a clone, or deep copy, of the cube texture
  7954. * @returns a new cube texture
  7955. */
  7956. clone(): CubeTexture;
  7957. }
  7958. }
  7959. declare module BABYLON {
  7960. /**
  7961. * Manages the defines for the Material
  7962. */
  7963. export class MaterialDefines {
  7964. /** @hidden */
  7965. protected _keys: string[];
  7966. private _isDirty;
  7967. /** @hidden */
  7968. _renderId: number;
  7969. /** @hidden */
  7970. _areLightsDirty: boolean;
  7971. /** @hidden */
  7972. _areLightsDisposed: boolean;
  7973. /** @hidden */
  7974. _areAttributesDirty: boolean;
  7975. /** @hidden */
  7976. _areTexturesDirty: boolean;
  7977. /** @hidden */
  7978. _areFresnelDirty: boolean;
  7979. /** @hidden */
  7980. _areMiscDirty: boolean;
  7981. /** @hidden */
  7982. _areImageProcessingDirty: boolean;
  7983. /** @hidden */
  7984. _normals: boolean;
  7985. /** @hidden */
  7986. _uvs: boolean;
  7987. /** @hidden */
  7988. _needNormals: boolean;
  7989. /** @hidden */
  7990. _needUVs: boolean;
  7991. [id: string]: any;
  7992. /**
  7993. * Specifies if the material needs to be re-calculated
  7994. */
  7995. get isDirty(): boolean;
  7996. /**
  7997. * Marks the material to indicate that it has been re-calculated
  7998. */
  7999. markAsProcessed(): void;
  8000. /**
  8001. * Marks the material to indicate that it needs to be re-calculated
  8002. */
  8003. markAsUnprocessed(): void;
  8004. /**
  8005. * Marks the material to indicate all of its defines need to be re-calculated
  8006. */
  8007. markAllAsDirty(): void;
  8008. /**
  8009. * Marks the material to indicate that image processing needs to be re-calculated
  8010. */
  8011. markAsImageProcessingDirty(): void;
  8012. /**
  8013. * Marks the material to indicate the lights need to be re-calculated
  8014. * @param disposed Defines whether the light is dirty due to dispose or not
  8015. */
  8016. markAsLightDirty(disposed?: boolean): void;
  8017. /**
  8018. * Marks the attribute state as changed
  8019. */
  8020. markAsAttributesDirty(): void;
  8021. /**
  8022. * Marks the texture state as changed
  8023. */
  8024. markAsTexturesDirty(): void;
  8025. /**
  8026. * Marks the fresnel state as changed
  8027. */
  8028. markAsFresnelDirty(): void;
  8029. /**
  8030. * Marks the misc state as changed
  8031. */
  8032. markAsMiscDirty(): void;
  8033. /**
  8034. * Rebuilds the material defines
  8035. */
  8036. rebuild(): void;
  8037. /**
  8038. * Specifies if two material defines are equal
  8039. * @param other - A material define instance to compare to
  8040. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8041. */
  8042. isEqual(other: MaterialDefines): boolean;
  8043. /**
  8044. * Clones this instance's defines to another instance
  8045. * @param other - material defines to clone values to
  8046. */
  8047. cloneTo(other: MaterialDefines): void;
  8048. /**
  8049. * Resets the material define values
  8050. */
  8051. reset(): void;
  8052. /**
  8053. * Converts the material define values to a string
  8054. * @returns - String of material define information
  8055. */
  8056. toString(): string;
  8057. }
  8058. }
  8059. declare module BABYLON {
  8060. /**
  8061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8063. * 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;
  8064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8065. */
  8066. export class ColorCurves {
  8067. private _dirty;
  8068. private _tempColor;
  8069. private _globalCurve;
  8070. private _highlightsCurve;
  8071. private _midtonesCurve;
  8072. private _shadowsCurve;
  8073. private _positiveCurve;
  8074. private _negativeCurve;
  8075. private _globalHue;
  8076. private _globalDensity;
  8077. private _globalSaturation;
  8078. private _globalExposure;
  8079. /**
  8080. * Gets the global Hue value.
  8081. * 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).
  8082. */
  8083. get globalHue(): number;
  8084. /**
  8085. * Sets the global Hue value.
  8086. * 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).
  8087. */
  8088. set globalHue(value: number);
  8089. /**
  8090. * Gets the global Density value.
  8091. * 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.
  8092. * Values less than zero provide a filter of opposite hue.
  8093. */
  8094. get globalDensity(): number;
  8095. /**
  8096. * Sets the global 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. set globalDensity(value: number);
  8101. /**
  8102. * Gets the global Saturation value.
  8103. * 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.
  8104. */
  8105. get globalSaturation(): number;
  8106. /**
  8107. * Sets the global Saturation value.
  8108. * 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.
  8109. */
  8110. set globalSaturation(value: number);
  8111. /**
  8112. * Gets the global Exposure value.
  8113. * 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.
  8114. */
  8115. get globalExposure(): number;
  8116. /**
  8117. * Sets the global Exposure value.
  8118. * 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.
  8119. */
  8120. set globalExposure(value: number);
  8121. private _highlightsHue;
  8122. private _highlightsDensity;
  8123. private _highlightsSaturation;
  8124. private _highlightsExposure;
  8125. /**
  8126. * Gets the highlights Hue value.
  8127. * 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).
  8128. */
  8129. get highlightsHue(): number;
  8130. /**
  8131. * Sets the highlights Hue value.
  8132. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8133. */
  8134. set highlightsHue(value: number);
  8135. /**
  8136. * Gets the highlights Density value.
  8137. * 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.
  8138. * Values less than zero provide a filter of opposite hue.
  8139. */
  8140. get highlightsDensity(): number;
  8141. /**
  8142. * Sets the highlights 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. set highlightsDensity(value: number);
  8147. /**
  8148. * Gets the highlights Saturation value.
  8149. * 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.
  8150. */
  8151. get highlightsSaturation(): number;
  8152. /**
  8153. * Sets the highlights Saturation value.
  8154. * 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.
  8155. */
  8156. set highlightsSaturation(value: number);
  8157. /**
  8158. * Gets the highlights Exposure value.
  8159. * 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.
  8160. */
  8161. get highlightsExposure(): number;
  8162. /**
  8163. * Sets the highlights Exposure value.
  8164. * 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.
  8165. */
  8166. set highlightsExposure(value: number);
  8167. private _midtonesHue;
  8168. private _midtonesDensity;
  8169. private _midtonesSaturation;
  8170. private _midtonesExposure;
  8171. /**
  8172. * Gets the midtones Hue value.
  8173. * 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).
  8174. */
  8175. get midtonesHue(): number;
  8176. /**
  8177. * Sets the midtones Hue value.
  8178. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8179. */
  8180. set midtonesHue(value: number);
  8181. /**
  8182. * Gets the midtones Density value.
  8183. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8184. * Values less than zero provide a filter of opposite hue.
  8185. */
  8186. get midtonesDensity(): number;
  8187. /**
  8188. * Sets the midtones 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. set midtonesDensity(value: number);
  8193. /**
  8194. * Gets the midtones Saturation value.
  8195. * 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.
  8196. */
  8197. get midtonesSaturation(): number;
  8198. /**
  8199. * Sets the midtones Saturation value.
  8200. * 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.
  8201. */
  8202. set midtonesSaturation(value: number);
  8203. /**
  8204. * Gets the midtones Exposure value.
  8205. * 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.
  8206. */
  8207. get midtonesExposure(): number;
  8208. /**
  8209. * Sets the midtones Exposure value.
  8210. * 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.
  8211. */
  8212. set midtonesExposure(value: number);
  8213. private _shadowsHue;
  8214. private _shadowsDensity;
  8215. private _shadowsSaturation;
  8216. private _shadowsExposure;
  8217. /**
  8218. * Gets the shadows Hue value.
  8219. * 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).
  8220. */
  8221. get shadowsHue(): number;
  8222. /**
  8223. * Sets the shadows Hue value.
  8224. * 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).
  8225. */
  8226. set shadowsHue(value: number);
  8227. /**
  8228. * Gets the shadows Density value.
  8229. * 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.
  8230. * Values less than zero provide a filter of opposite hue.
  8231. */
  8232. get shadowsDensity(): number;
  8233. /**
  8234. * Sets the shadows Density value.
  8235. * 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.
  8236. * Values less than zero provide a filter of opposite hue.
  8237. */
  8238. set shadowsDensity(value: number);
  8239. /**
  8240. * Gets the shadows Saturation value.
  8241. * 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.
  8242. */
  8243. get shadowsSaturation(): number;
  8244. /**
  8245. * Sets the shadows Saturation value.
  8246. * 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.
  8247. */
  8248. set shadowsSaturation(value: number);
  8249. /**
  8250. * Gets the shadows Exposure value.
  8251. * 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.
  8252. */
  8253. get shadowsExposure(): number;
  8254. /**
  8255. * Sets the shadows Exposure value.
  8256. * 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.
  8257. */
  8258. set shadowsExposure(value: number);
  8259. /**
  8260. * Returns the class name
  8261. * @returns The class name
  8262. */
  8263. getClassName(): string;
  8264. /**
  8265. * Binds the color curves to the shader.
  8266. * @param colorCurves The color curve to bind
  8267. * @param effect The effect to bind to
  8268. * @param positiveUniform The positive uniform shader parameter
  8269. * @param neutralUniform The neutral uniform shader parameter
  8270. * @param negativeUniform The negative uniform shader parameter
  8271. */
  8272. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8273. /**
  8274. * Prepare the list of uniforms associated with the ColorCurves effects.
  8275. * @param uniformsList The list of uniforms used in the effect
  8276. */
  8277. static PrepareUniforms(uniformsList: string[]): void;
  8278. /**
  8279. * Returns color grading data based on a hue, density, saturation and exposure value.
  8280. * @param filterHue The hue of the color filter.
  8281. * @param filterDensity The density of the color filter.
  8282. * @param saturation The saturation.
  8283. * @param exposure The exposure.
  8284. * @param result The result data container.
  8285. */
  8286. private getColorGradingDataToRef;
  8287. /**
  8288. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8289. * @param value The input slider value in range [-100,100].
  8290. * @returns Adjusted value.
  8291. */
  8292. private static applyColorGradingSliderNonlinear;
  8293. /**
  8294. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8295. * @param hue The hue (H) input.
  8296. * @param saturation The saturation (S) input.
  8297. * @param brightness The brightness (B) input.
  8298. * @result An RGBA color represented as Vector4.
  8299. */
  8300. private static fromHSBToRef;
  8301. /**
  8302. * Returns a value clamped between min and max
  8303. * @param value The value to clamp
  8304. * @param min The minimum of value
  8305. * @param max The maximum of value
  8306. * @returns The clamped value.
  8307. */
  8308. private static clamp;
  8309. /**
  8310. * Clones the current color curve instance.
  8311. * @return The cloned curves
  8312. */
  8313. clone(): ColorCurves;
  8314. /**
  8315. * Serializes the current color curve instance to a json representation.
  8316. * @return a JSON representation
  8317. */
  8318. serialize(): any;
  8319. /**
  8320. * Parses the color curve from a json representation.
  8321. * @param source the JSON source to parse
  8322. * @return The parsed curves
  8323. */
  8324. static Parse(source: any): ColorCurves;
  8325. }
  8326. }
  8327. declare module BABYLON {
  8328. /**
  8329. * Interface to follow in your material defines to integrate easily the
  8330. * Image proccessing functions.
  8331. * @hidden
  8332. */
  8333. export interface IImageProcessingConfigurationDefines {
  8334. IMAGEPROCESSING: boolean;
  8335. VIGNETTE: boolean;
  8336. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8337. VIGNETTEBLENDMODEOPAQUE: boolean;
  8338. TONEMAPPING: boolean;
  8339. TONEMAPPING_ACES: boolean;
  8340. CONTRAST: boolean;
  8341. EXPOSURE: boolean;
  8342. COLORCURVES: boolean;
  8343. COLORGRADING: boolean;
  8344. COLORGRADING3D: boolean;
  8345. SAMPLER3DGREENDEPTH: boolean;
  8346. SAMPLER3DBGRMAP: boolean;
  8347. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8348. }
  8349. /**
  8350. * @hidden
  8351. */
  8352. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8353. IMAGEPROCESSING: boolean;
  8354. VIGNETTE: boolean;
  8355. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8356. VIGNETTEBLENDMODEOPAQUE: boolean;
  8357. TONEMAPPING: boolean;
  8358. TONEMAPPING_ACES: boolean;
  8359. CONTRAST: boolean;
  8360. COLORCURVES: boolean;
  8361. COLORGRADING: boolean;
  8362. COLORGRADING3D: boolean;
  8363. SAMPLER3DGREENDEPTH: boolean;
  8364. SAMPLER3DBGRMAP: boolean;
  8365. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8366. EXPOSURE: boolean;
  8367. constructor();
  8368. }
  8369. /**
  8370. * This groups together the common properties used for image processing either in direct forward pass
  8371. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8372. * or not.
  8373. */
  8374. export class ImageProcessingConfiguration {
  8375. /**
  8376. * Default tone mapping applied in BabylonJS.
  8377. */
  8378. static readonly TONEMAPPING_STANDARD: number;
  8379. /**
  8380. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8381. * to other engines rendering to increase portability.
  8382. */
  8383. static readonly TONEMAPPING_ACES: number;
  8384. /**
  8385. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8386. */
  8387. colorCurves: Nullable<ColorCurves>;
  8388. private _colorCurvesEnabled;
  8389. /**
  8390. * Gets wether the color curves effect is enabled.
  8391. */
  8392. get colorCurvesEnabled(): boolean;
  8393. /**
  8394. * Sets wether the color curves effect is enabled.
  8395. */
  8396. set colorCurvesEnabled(value: boolean);
  8397. private _colorGradingTexture;
  8398. /**
  8399. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8400. */
  8401. get colorGradingTexture(): Nullable<BaseTexture>;
  8402. /**
  8403. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8404. */
  8405. set colorGradingTexture(value: Nullable<BaseTexture>);
  8406. private _colorGradingEnabled;
  8407. /**
  8408. * Gets wether the color grading effect is enabled.
  8409. */
  8410. get colorGradingEnabled(): boolean;
  8411. /**
  8412. * Sets wether the color grading effect is enabled.
  8413. */
  8414. set colorGradingEnabled(value: boolean);
  8415. private _colorGradingWithGreenDepth;
  8416. /**
  8417. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8418. */
  8419. get colorGradingWithGreenDepth(): boolean;
  8420. /**
  8421. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8422. */
  8423. set colorGradingWithGreenDepth(value: boolean);
  8424. private _colorGradingBGR;
  8425. /**
  8426. * Gets wether the color grading texture contains BGR values.
  8427. */
  8428. get colorGradingBGR(): boolean;
  8429. /**
  8430. * Sets wether the color grading texture contains BGR values.
  8431. */
  8432. set colorGradingBGR(value: boolean);
  8433. /** @hidden */
  8434. _exposure: number;
  8435. /**
  8436. * Gets the Exposure used in the effect.
  8437. */
  8438. get exposure(): number;
  8439. /**
  8440. * Sets the Exposure used in the effect.
  8441. */
  8442. set exposure(value: number);
  8443. private _toneMappingEnabled;
  8444. /**
  8445. * Gets wether the tone mapping effect is enabled.
  8446. */
  8447. get toneMappingEnabled(): boolean;
  8448. /**
  8449. * Sets wether the tone mapping effect is enabled.
  8450. */
  8451. set toneMappingEnabled(value: boolean);
  8452. private _toneMappingType;
  8453. /**
  8454. * Gets the type of tone mapping effect.
  8455. */
  8456. get toneMappingType(): number;
  8457. /**
  8458. * Sets the type of tone mapping effect used in BabylonJS.
  8459. */
  8460. set toneMappingType(value: number);
  8461. protected _contrast: number;
  8462. /**
  8463. * Gets the contrast used in the effect.
  8464. */
  8465. get contrast(): number;
  8466. /**
  8467. * Sets the contrast used in the effect.
  8468. */
  8469. set contrast(value: number);
  8470. /**
  8471. * Vignette stretch size.
  8472. */
  8473. vignetteStretch: number;
  8474. /**
  8475. * Vignette centre X Offset.
  8476. */
  8477. vignetteCentreX: number;
  8478. /**
  8479. * Vignette centre Y Offset.
  8480. */
  8481. vignetteCentreY: number;
  8482. /**
  8483. * Vignette weight or intensity of the vignette effect.
  8484. */
  8485. vignetteWeight: number;
  8486. /**
  8487. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8488. * if vignetteEnabled is set to true.
  8489. */
  8490. vignetteColor: Color4;
  8491. /**
  8492. * Camera field of view used by the Vignette effect.
  8493. */
  8494. vignetteCameraFov: number;
  8495. private _vignetteBlendMode;
  8496. /**
  8497. * Gets the vignette blend mode allowing different kind of effect.
  8498. */
  8499. get vignetteBlendMode(): number;
  8500. /**
  8501. * Sets the vignette blend mode allowing different kind of effect.
  8502. */
  8503. set vignetteBlendMode(value: number);
  8504. private _vignetteEnabled;
  8505. /**
  8506. * Gets wether the vignette effect is enabled.
  8507. */
  8508. get vignetteEnabled(): boolean;
  8509. /**
  8510. * Sets wether the vignette effect is enabled.
  8511. */
  8512. set vignetteEnabled(value: boolean);
  8513. private _applyByPostProcess;
  8514. /**
  8515. * Gets wether the image processing is applied through a post process or not.
  8516. */
  8517. get applyByPostProcess(): boolean;
  8518. /**
  8519. * Sets wether the image processing is applied through a post process or not.
  8520. */
  8521. set applyByPostProcess(value: boolean);
  8522. private _isEnabled;
  8523. /**
  8524. * Gets wether the image processing is enabled or not.
  8525. */
  8526. get isEnabled(): boolean;
  8527. /**
  8528. * Sets wether the image processing is enabled or not.
  8529. */
  8530. set isEnabled(value: boolean);
  8531. /**
  8532. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8533. */
  8534. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8535. /**
  8536. * Method called each time the image processing information changes requires to recompile the effect.
  8537. */
  8538. protected _updateParameters(): void;
  8539. /**
  8540. * Gets the current class name.
  8541. * @return "ImageProcessingConfiguration"
  8542. */
  8543. getClassName(): string;
  8544. /**
  8545. * Prepare the list of uniforms associated with the Image Processing effects.
  8546. * @param uniforms The list of uniforms used in the effect
  8547. * @param defines the list of defines currently in use
  8548. */
  8549. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8550. /**
  8551. * Prepare the list of samplers associated with the Image Processing effects.
  8552. * @param samplersList The list of uniforms used in the effect
  8553. * @param defines the list of defines currently in use
  8554. */
  8555. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8556. /**
  8557. * Prepare the list of defines associated to the shader.
  8558. * @param defines the list of defines to complete
  8559. * @param forPostProcess Define if we are currently in post process mode or not
  8560. */
  8561. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8562. /**
  8563. * Returns true if all the image processing information are ready.
  8564. * @returns True if ready, otherwise, false
  8565. */
  8566. isReady(): boolean;
  8567. /**
  8568. * Binds the image processing to the shader.
  8569. * @param effect The effect to bind to
  8570. * @param overrideAspectRatio Override the aspect ratio of the effect
  8571. */
  8572. bind(effect: Effect, overrideAspectRatio?: number): void;
  8573. /**
  8574. * Clones the current image processing instance.
  8575. * @return The cloned image processing
  8576. */
  8577. clone(): ImageProcessingConfiguration;
  8578. /**
  8579. * Serializes the current image processing instance to a json representation.
  8580. * @return a JSON representation
  8581. */
  8582. serialize(): any;
  8583. /**
  8584. * Parses the image processing from a json representation.
  8585. * @param source the JSON source to parse
  8586. * @return The parsed image processing
  8587. */
  8588. static Parse(source: any): ImageProcessingConfiguration;
  8589. private static _VIGNETTEMODE_MULTIPLY;
  8590. private static _VIGNETTEMODE_OPAQUE;
  8591. /**
  8592. * Used to apply the vignette as a mix with the pixel color.
  8593. */
  8594. static get VIGNETTEMODE_MULTIPLY(): number;
  8595. /**
  8596. * Used to apply the vignette as a replacement of the pixel color.
  8597. */
  8598. static get VIGNETTEMODE_OPAQUE(): number;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /** @hidden */
  8603. export var postprocessVertexShader: {
  8604. name: string;
  8605. shader: string;
  8606. };
  8607. }
  8608. declare module BABYLON {
  8609. interface ThinEngine {
  8610. /**
  8611. * Creates a new render target texture
  8612. * @param size defines the size of the texture
  8613. * @param options defines the options used to create the texture
  8614. * @returns a new render target texture stored in an InternalTexture
  8615. */
  8616. createRenderTargetTexture(size: number | {
  8617. width: number;
  8618. height: number;
  8619. layers?: number;
  8620. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8621. /**
  8622. * Creates a depth stencil texture.
  8623. * This is only available in WebGL 2 or with the depth texture extension available.
  8624. * @param size The size of face edge in the texture.
  8625. * @param options The options defining the texture.
  8626. * @returns The texture
  8627. */
  8628. createDepthStencilTexture(size: number | {
  8629. width: number;
  8630. height: number;
  8631. layers?: number;
  8632. }, options: DepthTextureCreationOptions): InternalTexture;
  8633. /** @hidden */
  8634. _createDepthStencilTexture(size: number | {
  8635. width: number;
  8636. height: number;
  8637. layers?: number;
  8638. }, options: DepthTextureCreationOptions): InternalTexture;
  8639. }
  8640. }
  8641. declare module BABYLON {
  8642. /**
  8643. * Defines the kind of connection point for node based material
  8644. */
  8645. export enum NodeMaterialBlockConnectionPointTypes {
  8646. /** Float */
  8647. Float = 1,
  8648. /** Int */
  8649. Int = 2,
  8650. /** Vector2 */
  8651. Vector2 = 4,
  8652. /** Vector3 */
  8653. Vector3 = 8,
  8654. /** Vector4 */
  8655. Vector4 = 16,
  8656. /** Color3 */
  8657. Color3 = 32,
  8658. /** Color4 */
  8659. Color4 = 64,
  8660. /** Matrix */
  8661. Matrix = 128,
  8662. /** Custom object */
  8663. Object = 256,
  8664. /** Detect type based on connection */
  8665. AutoDetect = 1024,
  8666. /** Output type that will be defined by input type */
  8667. BasedOnInput = 2048
  8668. }
  8669. }
  8670. declare module BABYLON {
  8671. /**
  8672. * Enum used to define the target of a block
  8673. */
  8674. export enum NodeMaterialBlockTargets {
  8675. /** Vertex shader */
  8676. Vertex = 1,
  8677. /** Fragment shader */
  8678. Fragment = 2,
  8679. /** Neutral */
  8680. Neutral = 4,
  8681. /** Vertex and Fragment */
  8682. VertexAndFragment = 3
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /**
  8687. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8688. */
  8689. export enum NodeMaterialBlockConnectionPointMode {
  8690. /** Value is an uniform */
  8691. Uniform = 0,
  8692. /** Value is a mesh attribute */
  8693. Attribute = 1,
  8694. /** Value is a varying between vertex and fragment shaders */
  8695. Varying = 2,
  8696. /** Mode is undefined */
  8697. Undefined = 3
  8698. }
  8699. }
  8700. declare module BABYLON {
  8701. /**
  8702. * Enum used to define system values e.g. values automatically provided by the system
  8703. */
  8704. export enum NodeMaterialSystemValues {
  8705. /** World */
  8706. World = 1,
  8707. /** View */
  8708. View = 2,
  8709. /** Projection */
  8710. Projection = 3,
  8711. /** ViewProjection */
  8712. ViewProjection = 4,
  8713. /** WorldView */
  8714. WorldView = 5,
  8715. /** WorldViewProjection */
  8716. WorldViewProjection = 6,
  8717. /** CameraPosition */
  8718. CameraPosition = 7,
  8719. /** Fog Color */
  8720. FogColor = 8,
  8721. /** Delta time */
  8722. DeltaTime = 9
  8723. }
  8724. }
  8725. declare module BABYLON {
  8726. /** Defines supported spaces */
  8727. export enum Space {
  8728. /** Local (object) space */
  8729. LOCAL = 0,
  8730. /** World space */
  8731. WORLD = 1,
  8732. /** Bone space */
  8733. BONE = 2
  8734. }
  8735. /** Defines the 3 main axes */
  8736. export class Axis {
  8737. /** X axis */
  8738. static X: Vector3;
  8739. /** Y axis */
  8740. static Y: Vector3;
  8741. /** Z axis */
  8742. static Z: Vector3;
  8743. }
  8744. }
  8745. declare module BABYLON {
  8746. /**
  8747. * Represents a camera frustum
  8748. */
  8749. export class Frustum {
  8750. /**
  8751. * Gets the planes representing the frustum
  8752. * @param transform matrix to be applied to the returned planes
  8753. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8754. */
  8755. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8756. /**
  8757. * Gets the near frustum plane transformed by the transform matrix
  8758. * @param transform transformation matrix to be applied to the resulting frustum plane
  8759. * @param frustumPlane the resuling frustum plane
  8760. */
  8761. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8762. /**
  8763. * Gets the far frustum plane transformed by the transform matrix
  8764. * @param transform transformation matrix to be applied to the resulting frustum plane
  8765. * @param frustumPlane the resuling frustum plane
  8766. */
  8767. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8768. /**
  8769. * Gets the left frustum plane transformed by the transform matrix
  8770. * @param transform transformation matrix to be applied to the resulting frustum plane
  8771. * @param frustumPlane the resuling frustum plane
  8772. */
  8773. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8774. /**
  8775. * Gets the right frustum plane transformed by the transform matrix
  8776. * @param transform transformation matrix to be applied to the resulting frustum plane
  8777. * @param frustumPlane the resuling frustum plane
  8778. */
  8779. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8780. /**
  8781. * Gets the top frustum plane transformed by the transform matrix
  8782. * @param transform transformation matrix to be applied to the resulting frustum plane
  8783. * @param frustumPlane the resuling frustum plane
  8784. */
  8785. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8786. /**
  8787. * Gets the bottom frustum plane transformed by the transform matrix
  8788. * @param transform transformation matrix to be applied to the resulting frustum plane
  8789. * @param frustumPlane the resuling frustum plane
  8790. */
  8791. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8792. /**
  8793. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8794. * @param transform transformation matrix to be applied to the resulting frustum planes
  8795. * @param frustumPlanes the resuling frustum planes
  8796. */
  8797. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8798. }
  8799. }
  8800. declare module BABYLON {
  8801. /**
  8802. * Interface for the size containing width and height
  8803. */
  8804. export interface ISize {
  8805. /**
  8806. * Width
  8807. */
  8808. width: number;
  8809. /**
  8810. * Heighht
  8811. */
  8812. height: number;
  8813. }
  8814. /**
  8815. * Size containing widht and height
  8816. */
  8817. export class Size implements ISize {
  8818. /**
  8819. * Width
  8820. */
  8821. width: number;
  8822. /**
  8823. * Height
  8824. */
  8825. height: number;
  8826. /**
  8827. * Creates a Size object from the given width and height (floats).
  8828. * @param width width of the new size
  8829. * @param height height of the new size
  8830. */
  8831. constructor(width: number, height: number);
  8832. /**
  8833. * Returns a string with the Size width and height
  8834. * @returns a string with the Size width and height
  8835. */
  8836. toString(): string;
  8837. /**
  8838. * "Size"
  8839. * @returns the string "Size"
  8840. */
  8841. getClassName(): string;
  8842. /**
  8843. * Returns the Size hash code.
  8844. * @returns a hash code for a unique width and height
  8845. */
  8846. getHashCode(): number;
  8847. /**
  8848. * Updates the current size from the given one.
  8849. * @param src the given size
  8850. */
  8851. copyFrom(src: Size): void;
  8852. /**
  8853. * Updates in place the current Size from the given floats.
  8854. * @param width width of the new size
  8855. * @param height height of the new size
  8856. * @returns the updated Size.
  8857. */
  8858. copyFromFloats(width: number, height: number): Size;
  8859. /**
  8860. * Updates in place the current Size from the given floats.
  8861. * @param width width to set
  8862. * @param height height to set
  8863. * @returns the updated Size.
  8864. */
  8865. set(width: number, height: number): Size;
  8866. /**
  8867. * Multiplies the width and height by numbers
  8868. * @param w factor to multiple the width by
  8869. * @param h factor to multiple the height by
  8870. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8871. */
  8872. multiplyByFloats(w: number, h: number): Size;
  8873. /**
  8874. * Clones the size
  8875. * @returns a new Size copied from the given one.
  8876. */
  8877. clone(): Size;
  8878. /**
  8879. * True if the current Size and the given one width and height are strictly equal.
  8880. * @param other the other size to compare against
  8881. * @returns True if the current Size and the given one width and height are strictly equal.
  8882. */
  8883. equals(other: Size): boolean;
  8884. /**
  8885. * The surface of the Size : width * height (float).
  8886. */
  8887. get surface(): number;
  8888. /**
  8889. * Create a new size of zero
  8890. * @returns a new Size set to (0.0, 0.0)
  8891. */
  8892. static Zero(): Size;
  8893. /**
  8894. * Sums the width and height of two sizes
  8895. * @param otherSize size to add to this size
  8896. * @returns a new Size set as the addition result of the current Size and the given one.
  8897. */
  8898. add(otherSize: Size): Size;
  8899. /**
  8900. * Subtracts the width and height of two
  8901. * @param otherSize size to subtract to this size
  8902. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8903. */
  8904. subtract(otherSize: Size): Size;
  8905. /**
  8906. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8907. * @param start starting size to lerp between
  8908. * @param end end size to lerp between
  8909. * @param amount amount to lerp between the start and end values
  8910. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8911. */
  8912. static Lerp(start: Size, end: Size, amount: number): Size;
  8913. }
  8914. }
  8915. declare module BABYLON {
  8916. /**
  8917. * Contains position and normal vectors for a vertex
  8918. */
  8919. export class PositionNormalVertex {
  8920. /** the position of the vertex (defaut: 0,0,0) */
  8921. position: Vector3;
  8922. /** the normal of the vertex (defaut: 0,1,0) */
  8923. normal: Vector3;
  8924. /**
  8925. * Creates a PositionNormalVertex
  8926. * @param position the position of the vertex (defaut: 0,0,0)
  8927. * @param normal the normal of the vertex (defaut: 0,1,0)
  8928. */
  8929. constructor(
  8930. /** the position of the vertex (defaut: 0,0,0) */
  8931. position?: Vector3,
  8932. /** the normal of the vertex (defaut: 0,1,0) */
  8933. normal?: Vector3);
  8934. /**
  8935. * Clones the PositionNormalVertex
  8936. * @returns the cloned PositionNormalVertex
  8937. */
  8938. clone(): PositionNormalVertex;
  8939. }
  8940. /**
  8941. * Contains position, normal and uv vectors for a vertex
  8942. */
  8943. export class PositionNormalTextureVertex {
  8944. /** the position of the vertex (defaut: 0,0,0) */
  8945. position: Vector3;
  8946. /** the normal of the vertex (defaut: 0,1,0) */
  8947. normal: Vector3;
  8948. /** the uv of the vertex (default: 0,0) */
  8949. uv: Vector2;
  8950. /**
  8951. * Creates a PositionNormalTextureVertex
  8952. * @param position the position of the vertex (defaut: 0,0,0)
  8953. * @param normal the normal of the vertex (defaut: 0,1,0)
  8954. * @param uv the uv of the vertex (default: 0,0)
  8955. */
  8956. constructor(
  8957. /** the position of the vertex (defaut: 0,0,0) */
  8958. position?: Vector3,
  8959. /** the normal of the vertex (defaut: 0,1,0) */
  8960. normal?: Vector3,
  8961. /** the uv of the vertex (default: 0,0) */
  8962. uv?: Vector2);
  8963. /**
  8964. * Clones the PositionNormalTextureVertex
  8965. * @returns the cloned PositionNormalTextureVertex
  8966. */
  8967. clone(): PositionNormalTextureVertex;
  8968. }
  8969. }
  8970. declare module BABYLON {
  8971. /**
  8972. * Enum defining the type of animations supported by InputBlock
  8973. */
  8974. export enum AnimatedInputBlockTypes {
  8975. /** No animation */
  8976. None = 0,
  8977. /** Time based animation. Will only work for floats */
  8978. Time = 1
  8979. }
  8980. }
  8981. declare module BABYLON {
  8982. /**
  8983. * Interface describing all the common properties and methods a shadow light needs to implement.
  8984. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8985. * as well as binding the different shadow properties to the effects.
  8986. */
  8987. export interface IShadowLight extends Light {
  8988. /**
  8989. * The light id in the scene (used in scene.findLighById for instance)
  8990. */
  8991. id: string;
  8992. /**
  8993. * The position the shdow will be casted from.
  8994. */
  8995. position: Vector3;
  8996. /**
  8997. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8998. */
  8999. direction: Vector3;
  9000. /**
  9001. * The transformed position. Position of the light in world space taking parenting in account.
  9002. */
  9003. transformedPosition: Vector3;
  9004. /**
  9005. * The transformed direction. Direction of the light in world space taking parenting in account.
  9006. */
  9007. transformedDirection: Vector3;
  9008. /**
  9009. * The friendly name of the light in the scene.
  9010. */
  9011. name: string;
  9012. /**
  9013. * Defines the shadow projection clipping minimum z value.
  9014. */
  9015. shadowMinZ: number;
  9016. /**
  9017. * Defines the shadow projection clipping maximum z value.
  9018. */
  9019. shadowMaxZ: number;
  9020. /**
  9021. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9022. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9023. */
  9024. computeTransformedInformation(): boolean;
  9025. /**
  9026. * Gets the scene the light belongs to.
  9027. * @returns The scene
  9028. */
  9029. getScene(): Scene;
  9030. /**
  9031. * Callback defining a custom Projection Matrix Builder.
  9032. * This can be used to override the default projection matrix computation.
  9033. */
  9034. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9035. /**
  9036. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9037. * @param matrix The materix to updated with the projection information
  9038. * @param viewMatrix The transform matrix of the light
  9039. * @param renderList The list of mesh to render in the map
  9040. * @returns The current light
  9041. */
  9042. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9043. /**
  9044. * Gets the current depth scale used in ESM.
  9045. * @returns The scale
  9046. */
  9047. getDepthScale(): number;
  9048. /**
  9049. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9050. * @returns true if a cube texture needs to be use
  9051. */
  9052. needCube(): boolean;
  9053. /**
  9054. * Detects if the projection matrix requires to be recomputed this frame.
  9055. * @returns true if it requires to be recomputed otherwise, false.
  9056. */
  9057. needProjectionMatrixCompute(): boolean;
  9058. /**
  9059. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9060. */
  9061. forceProjectionMatrixCompute(): void;
  9062. /**
  9063. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9064. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9065. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9066. */
  9067. getShadowDirection(faceIndex?: number): Vector3;
  9068. /**
  9069. * Gets the minZ used for shadow according to both the scene and the light.
  9070. * @param activeCamera The camera we are returning the min for
  9071. * @returns the depth min z
  9072. */
  9073. getDepthMinZ(activeCamera: Camera): number;
  9074. /**
  9075. * Gets the maxZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the max for
  9077. * @returns the depth max z
  9078. */
  9079. getDepthMaxZ(activeCamera: Camera): number;
  9080. }
  9081. /**
  9082. * Base implementation IShadowLight
  9083. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9084. */
  9085. export abstract class ShadowLight extends Light implements IShadowLight {
  9086. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9087. protected _position: Vector3;
  9088. protected _setPosition(value: Vector3): void;
  9089. /**
  9090. * Sets the position the shadow will be casted from. Also use as the light position for both
  9091. * point and spot lights.
  9092. */
  9093. get position(): Vector3;
  9094. /**
  9095. * Sets the position the shadow will be casted from. Also use as the light position for both
  9096. * point and spot lights.
  9097. */
  9098. set position(value: Vector3);
  9099. protected _direction: Vector3;
  9100. protected _setDirection(value: Vector3): void;
  9101. /**
  9102. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9103. * Also use as the light direction on spot and directional lights.
  9104. */
  9105. get direction(): Vector3;
  9106. /**
  9107. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9108. * Also use as the light direction on spot and directional lights.
  9109. */
  9110. set direction(value: Vector3);
  9111. protected _shadowMinZ: number;
  9112. /**
  9113. * Gets the shadow projection clipping minimum z value.
  9114. */
  9115. get shadowMinZ(): number;
  9116. /**
  9117. * Sets the shadow projection clipping minimum z value.
  9118. */
  9119. set shadowMinZ(value: number);
  9120. protected _shadowMaxZ: number;
  9121. /**
  9122. * Sets the shadow projection clipping maximum z value.
  9123. */
  9124. get shadowMaxZ(): number;
  9125. /**
  9126. * Gets the shadow projection clipping maximum z value.
  9127. */
  9128. set shadowMaxZ(value: number);
  9129. /**
  9130. * Callback defining a custom Projection Matrix Builder.
  9131. * This can be used to override the default projection matrix computation.
  9132. */
  9133. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9134. /**
  9135. * The transformed position. Position of the light in world space taking parenting in account.
  9136. */
  9137. transformedPosition: Vector3;
  9138. /**
  9139. * The transformed direction. Direction of the light in world space taking parenting in account.
  9140. */
  9141. transformedDirection: Vector3;
  9142. private _needProjectionMatrixCompute;
  9143. /**
  9144. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9145. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9146. */
  9147. computeTransformedInformation(): boolean;
  9148. /**
  9149. * Return the depth scale used for the shadow map.
  9150. * @returns the depth scale.
  9151. */
  9152. getDepthScale(): number;
  9153. /**
  9154. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9155. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9156. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9157. */
  9158. getShadowDirection(faceIndex?: number): Vector3;
  9159. /**
  9160. * Returns the ShadowLight absolute position in the World.
  9161. * @returns the position vector in world space
  9162. */
  9163. getAbsolutePosition(): Vector3;
  9164. /**
  9165. * Sets the ShadowLight direction toward the passed target.
  9166. * @param target The point to target in local space
  9167. * @returns the updated ShadowLight direction
  9168. */
  9169. setDirectionToTarget(target: Vector3): Vector3;
  9170. /**
  9171. * Returns the light rotation in euler definition.
  9172. * @returns the x y z rotation in local space.
  9173. */
  9174. getRotation(): Vector3;
  9175. /**
  9176. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9177. * @returns true if a cube texture needs to be use
  9178. */
  9179. needCube(): boolean;
  9180. /**
  9181. * Detects if the projection matrix requires to be recomputed this frame.
  9182. * @returns true if it requires to be recomputed otherwise, false.
  9183. */
  9184. needProjectionMatrixCompute(): boolean;
  9185. /**
  9186. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9187. */
  9188. forceProjectionMatrixCompute(): void;
  9189. /** @hidden */
  9190. _initCache(): void;
  9191. /** @hidden */
  9192. _isSynchronized(): boolean;
  9193. /**
  9194. * Computes the world matrix of the node
  9195. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9196. * @returns the world matrix
  9197. */
  9198. computeWorldMatrix(force?: boolean): Matrix;
  9199. /**
  9200. * Gets the minZ used for shadow according to both the scene and the light.
  9201. * @param activeCamera The camera we are returning the min for
  9202. * @returns the depth min z
  9203. */
  9204. getDepthMinZ(activeCamera: Camera): number;
  9205. /**
  9206. * Gets the maxZ used for shadow according to both the scene and the light.
  9207. * @param activeCamera The camera we are returning the max for
  9208. * @returns the depth max z
  9209. */
  9210. getDepthMaxZ(activeCamera: Camera): number;
  9211. /**
  9212. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9213. * @param matrix The materix to updated with the projection information
  9214. * @param viewMatrix The transform matrix of the light
  9215. * @param renderList The list of mesh to render in the map
  9216. * @returns The current light
  9217. */
  9218. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9219. }
  9220. }
  9221. declare module BABYLON {
  9222. /** @hidden */
  9223. export var packingFunctions: {
  9224. name: string;
  9225. shader: string;
  9226. };
  9227. }
  9228. declare module BABYLON {
  9229. /** @hidden */
  9230. export var bayerDitherFunctions: {
  9231. name: string;
  9232. shader: string;
  9233. };
  9234. }
  9235. declare module BABYLON {
  9236. /** @hidden */
  9237. export var shadowMapFragmentDeclaration: {
  9238. name: string;
  9239. shader: string;
  9240. };
  9241. }
  9242. declare module BABYLON {
  9243. /** @hidden */
  9244. export var clipPlaneFragmentDeclaration: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module BABYLON {
  9250. /** @hidden */
  9251. export var clipPlaneFragment: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module BABYLON {
  9257. /** @hidden */
  9258. export var shadowMapFragment: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module BABYLON {
  9264. /** @hidden */
  9265. export var shadowMapPixelShader: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module BABYLON {
  9271. /** @hidden */
  9272. export var bonesDeclaration: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module BABYLON {
  9278. /** @hidden */
  9279. export var morphTargetsVertexGlobalDeclaration: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module BABYLON {
  9285. /** @hidden */
  9286. export var morphTargetsVertexDeclaration: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var instancesDeclaration: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /** @hidden */
  9300. export var helperFunctions: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module BABYLON {
  9306. /** @hidden */
  9307. export var shadowMapVertexDeclaration: {
  9308. name: string;
  9309. shader: string;
  9310. };
  9311. }
  9312. declare module BABYLON {
  9313. /** @hidden */
  9314. export var clipPlaneVertexDeclaration: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module BABYLON {
  9320. /** @hidden */
  9321. export var morphTargetsVertex: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module BABYLON {
  9327. /** @hidden */
  9328. export var instancesVertex: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var bonesVertex: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var shadowMapVertexNormalBias: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var shadowMapVertexMetric: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var clipPlaneVertex: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var shadowMapVertexShader: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var depthBoxBlurPixelShader: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var shadowMapFragmentSoftTransparentShadow: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /**
  9384. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9385. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9386. */
  9387. export class EffectFallbacks implements IEffectFallbacks {
  9388. private _defines;
  9389. private _currentRank;
  9390. private _maxRank;
  9391. private _mesh;
  9392. /**
  9393. * Removes the fallback from the bound mesh.
  9394. */
  9395. unBindMesh(): void;
  9396. /**
  9397. * Adds a fallback on the specified property.
  9398. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9399. * @param define The name of the define in the shader
  9400. */
  9401. addFallback(rank: number, define: string): void;
  9402. /**
  9403. * Sets the mesh to use CPU skinning when needing to fallback.
  9404. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9405. * @param mesh The mesh to use the fallbacks.
  9406. */
  9407. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9408. /**
  9409. * Checks to see if more fallbacks are still availible.
  9410. */
  9411. get hasMoreFallbacks(): boolean;
  9412. /**
  9413. * Removes the defines that should be removed when falling back.
  9414. * @param currentDefines defines the current define statements for the shader.
  9415. * @param effect defines the current effect we try to compile
  9416. * @returns The resulting defines with defines of the current rank removed.
  9417. */
  9418. reduce(currentDefines: string, effect: Effect): string;
  9419. }
  9420. }
  9421. declare module BABYLON {
  9422. /**
  9423. * Interface used to define Action
  9424. */
  9425. export interface IAction {
  9426. /**
  9427. * Trigger for the action
  9428. */
  9429. trigger: number;
  9430. /** Options of the trigger */
  9431. triggerOptions: any;
  9432. /**
  9433. * Gets the trigger parameters
  9434. * @returns the trigger parameters
  9435. */
  9436. getTriggerParameter(): any;
  9437. /**
  9438. * Internal only - executes current action event
  9439. * @hidden
  9440. */
  9441. _executeCurrent(evt?: ActionEvent): void;
  9442. /**
  9443. * Serialize placeholder for child classes
  9444. * @param parent of child
  9445. * @returns the serialized object
  9446. */
  9447. serialize(parent: any): any;
  9448. /**
  9449. * Internal only
  9450. * @hidden
  9451. */
  9452. _prepare(): void;
  9453. /**
  9454. * Internal only - manager for action
  9455. * @hidden
  9456. */
  9457. _actionManager: Nullable<AbstractActionManager>;
  9458. /**
  9459. * Adds action to chain of actions, may be a DoNothingAction
  9460. * @param action defines the next action to execute
  9461. * @returns The action passed in
  9462. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9463. */
  9464. then(action: IAction): IAction;
  9465. }
  9466. /**
  9467. * The action to be carried out following a trigger
  9468. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9469. */
  9470. export class Action implements IAction {
  9471. /** the trigger, with or without parameters, for the action */
  9472. triggerOptions: any;
  9473. /**
  9474. * Trigger for the action
  9475. */
  9476. trigger: number;
  9477. /**
  9478. * Internal only - manager for action
  9479. * @hidden
  9480. */
  9481. _actionManager: ActionManager;
  9482. private _nextActiveAction;
  9483. private _child;
  9484. private _condition?;
  9485. private _triggerParameter;
  9486. /**
  9487. * An event triggered prior to action being executed.
  9488. */
  9489. onBeforeExecuteObservable: Observable<Action>;
  9490. /**
  9491. * Creates a new Action
  9492. * @param triggerOptions the trigger, with or without parameters, for the action
  9493. * @param condition an optional determinant of action
  9494. */
  9495. constructor(
  9496. /** the trigger, with or without parameters, for the action */
  9497. triggerOptions: any, condition?: Condition);
  9498. /**
  9499. * Internal only
  9500. * @hidden
  9501. */
  9502. _prepare(): void;
  9503. /**
  9504. * Gets the trigger parameters
  9505. * @returns the trigger parameters
  9506. */
  9507. getTriggerParameter(): any;
  9508. /**
  9509. * Internal only - executes current action event
  9510. * @hidden
  9511. */
  9512. _executeCurrent(evt?: ActionEvent): void;
  9513. /**
  9514. * Execute placeholder for child classes
  9515. * @param evt optional action event
  9516. */
  9517. execute(evt?: ActionEvent): void;
  9518. /**
  9519. * Skips to next active action
  9520. */
  9521. skipToNextActiveAction(): void;
  9522. /**
  9523. * Adds action to chain of actions, may be a DoNothingAction
  9524. * @param action defines the next action to execute
  9525. * @returns The action passed in
  9526. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9527. */
  9528. then(action: Action): Action;
  9529. /**
  9530. * Internal only
  9531. * @hidden
  9532. */
  9533. _getProperty(propertyPath: string): string;
  9534. /**
  9535. * Internal only
  9536. * @hidden
  9537. */
  9538. _getEffectiveTarget(target: any, propertyPath: string): any;
  9539. /**
  9540. * Serialize placeholder for child classes
  9541. * @param parent of child
  9542. * @returns the serialized object
  9543. */
  9544. serialize(parent: any): any;
  9545. /**
  9546. * Internal only called by serialize
  9547. * @hidden
  9548. */
  9549. protected _serialize(serializedAction: any, parent?: any): any;
  9550. /**
  9551. * Internal only
  9552. * @hidden
  9553. */
  9554. static _SerializeValueAsString: (value: any) => string;
  9555. /**
  9556. * Internal only
  9557. * @hidden
  9558. */
  9559. static _GetTargetProperty: (target: Scene | Node) => {
  9560. name: string;
  9561. targetType: string;
  9562. value: string;
  9563. };
  9564. }
  9565. }
  9566. declare module BABYLON {
  9567. /**
  9568. * A Condition applied to an Action
  9569. */
  9570. export class Condition {
  9571. /**
  9572. * Internal only - manager for action
  9573. * @hidden
  9574. */
  9575. _actionManager: ActionManager;
  9576. /**
  9577. * Internal only
  9578. * @hidden
  9579. */
  9580. _evaluationId: number;
  9581. /**
  9582. * Internal only
  9583. * @hidden
  9584. */
  9585. _currentResult: boolean;
  9586. /**
  9587. * Creates a new Condition
  9588. * @param actionManager the manager of the action the condition is applied to
  9589. */
  9590. constructor(actionManager: ActionManager);
  9591. /**
  9592. * Check if the current condition is valid
  9593. * @returns a boolean
  9594. */
  9595. isValid(): boolean;
  9596. /**
  9597. * Internal only
  9598. * @hidden
  9599. */
  9600. _getProperty(propertyPath: string): string;
  9601. /**
  9602. * Internal only
  9603. * @hidden
  9604. */
  9605. _getEffectiveTarget(target: any, propertyPath: string): any;
  9606. /**
  9607. * Serialize placeholder for child classes
  9608. * @returns the serialized object
  9609. */
  9610. serialize(): any;
  9611. /**
  9612. * Internal only
  9613. * @hidden
  9614. */
  9615. protected _serialize(serializedCondition: any): any;
  9616. }
  9617. /**
  9618. * Defines specific conditional operators as extensions of Condition
  9619. */
  9620. export class ValueCondition extends Condition {
  9621. /** path to specify the property of the target the conditional operator uses */
  9622. propertyPath: string;
  9623. /** the value compared by the conditional operator against the current value of the property */
  9624. value: any;
  9625. /** the conditional operator, default ValueCondition.IsEqual */
  9626. operator: number;
  9627. /**
  9628. * Internal only
  9629. * @hidden
  9630. */
  9631. private static _IsEqual;
  9632. /**
  9633. * Internal only
  9634. * @hidden
  9635. */
  9636. private static _IsDifferent;
  9637. /**
  9638. * Internal only
  9639. * @hidden
  9640. */
  9641. private static _IsGreater;
  9642. /**
  9643. * Internal only
  9644. * @hidden
  9645. */
  9646. private static _IsLesser;
  9647. /**
  9648. * returns the number for IsEqual
  9649. */
  9650. static get IsEqual(): number;
  9651. /**
  9652. * Returns the number for IsDifferent
  9653. */
  9654. static get IsDifferent(): number;
  9655. /**
  9656. * Returns the number for IsGreater
  9657. */
  9658. static get IsGreater(): number;
  9659. /**
  9660. * Returns the number for IsLesser
  9661. */
  9662. static get IsLesser(): number;
  9663. /**
  9664. * Internal only The action manager for the condition
  9665. * @hidden
  9666. */
  9667. _actionManager: ActionManager;
  9668. /**
  9669. * Internal only
  9670. * @hidden
  9671. */
  9672. private _target;
  9673. /**
  9674. * Internal only
  9675. * @hidden
  9676. */
  9677. private _effectiveTarget;
  9678. /**
  9679. * Internal only
  9680. * @hidden
  9681. */
  9682. private _property;
  9683. /**
  9684. * Creates a new ValueCondition
  9685. * @param actionManager manager for the action the condition applies to
  9686. * @param target for the action
  9687. * @param propertyPath path to specify the property of the target the conditional operator uses
  9688. * @param value the value compared by the conditional operator against the current value of the property
  9689. * @param operator the conditional operator, default ValueCondition.IsEqual
  9690. */
  9691. constructor(actionManager: ActionManager, target: any,
  9692. /** path to specify the property of the target the conditional operator uses */
  9693. propertyPath: string,
  9694. /** the value compared by the conditional operator against the current value of the property */
  9695. value: any,
  9696. /** the conditional operator, default ValueCondition.IsEqual */
  9697. operator?: number);
  9698. /**
  9699. * Compares the given value with the property value for the specified conditional operator
  9700. * @returns the result of the comparison
  9701. */
  9702. isValid(): boolean;
  9703. /**
  9704. * Serialize the ValueCondition into a JSON compatible object
  9705. * @returns serialization object
  9706. */
  9707. serialize(): any;
  9708. /**
  9709. * Gets the name of the conditional operator for the ValueCondition
  9710. * @param operator the conditional operator
  9711. * @returns the name
  9712. */
  9713. static GetOperatorName(operator: number): string;
  9714. }
  9715. /**
  9716. * Defines a predicate condition as an extension of Condition
  9717. */
  9718. export class PredicateCondition extends Condition {
  9719. /** defines the predicate function used to validate the condition */
  9720. predicate: () => boolean;
  9721. /**
  9722. * Internal only - manager for action
  9723. * @hidden
  9724. */
  9725. _actionManager: ActionManager;
  9726. /**
  9727. * Creates a new PredicateCondition
  9728. * @param actionManager manager for the action the condition applies to
  9729. * @param predicate defines the predicate function used to validate the condition
  9730. */
  9731. constructor(actionManager: ActionManager,
  9732. /** defines the predicate function used to validate the condition */
  9733. predicate: () => boolean);
  9734. /**
  9735. * @returns the validity of the predicate condition
  9736. */
  9737. isValid(): boolean;
  9738. }
  9739. /**
  9740. * Defines a state condition as an extension of Condition
  9741. */
  9742. export class StateCondition extends Condition {
  9743. /** Value to compare with target state */
  9744. value: string;
  9745. /**
  9746. * Internal only - manager for action
  9747. * @hidden
  9748. */
  9749. _actionManager: ActionManager;
  9750. /**
  9751. * Internal only
  9752. * @hidden
  9753. */
  9754. private _target;
  9755. /**
  9756. * Creates a new StateCondition
  9757. * @param actionManager manager for the action the condition applies to
  9758. * @param target of the condition
  9759. * @param value to compare with target state
  9760. */
  9761. constructor(actionManager: ActionManager, target: any,
  9762. /** Value to compare with target state */
  9763. value: string);
  9764. /**
  9765. * Gets a boolean indicating if the current condition is met
  9766. * @returns the validity of the state
  9767. */
  9768. isValid(): boolean;
  9769. /**
  9770. * Serialize the StateCondition into a JSON compatible object
  9771. * @returns serialization object
  9772. */
  9773. serialize(): any;
  9774. }
  9775. }
  9776. declare module BABYLON {
  9777. /**
  9778. * This defines an action responsible to toggle a boolean once triggered.
  9779. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9780. */
  9781. export class SwitchBooleanAction extends Action {
  9782. /**
  9783. * The path to the boolean property in the target object
  9784. */
  9785. propertyPath: string;
  9786. private _target;
  9787. private _effectiveTarget;
  9788. private _property;
  9789. /**
  9790. * Instantiate the action
  9791. * @param triggerOptions defines the trigger options
  9792. * @param target defines the object containing the boolean
  9793. * @param propertyPath defines the path to the boolean property in the target object
  9794. * @param condition defines the trigger related conditions
  9795. */
  9796. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9797. /** @hidden */
  9798. _prepare(): void;
  9799. /**
  9800. * Execute the action toggle the boolean value.
  9801. */
  9802. execute(): void;
  9803. /**
  9804. * Serializes the actions and its related information.
  9805. * @param parent defines the object to serialize in
  9806. * @returns the serialized object
  9807. */
  9808. serialize(parent: any): any;
  9809. }
  9810. /**
  9811. * This defines an action responsible to set a the state field of the target
  9812. * to a desired value once triggered.
  9813. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9814. */
  9815. export class SetStateAction extends Action {
  9816. /**
  9817. * The value to store in the state field.
  9818. */
  9819. value: string;
  9820. private _target;
  9821. /**
  9822. * Instantiate the action
  9823. * @param triggerOptions defines the trigger options
  9824. * @param target defines the object containing the state property
  9825. * @param value defines the value to store in the state field
  9826. * @param condition defines the trigger related conditions
  9827. */
  9828. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9829. /**
  9830. * Execute the action and store the value on the target state property.
  9831. */
  9832. execute(): void;
  9833. /**
  9834. * Serializes the actions and its related information.
  9835. * @param parent defines the object to serialize in
  9836. * @returns the serialized object
  9837. */
  9838. serialize(parent: any): any;
  9839. }
  9840. /**
  9841. * This defines an action responsible to set a property of the target
  9842. * to a desired value once triggered.
  9843. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9844. */
  9845. export class SetValueAction extends Action {
  9846. /**
  9847. * The path of the property to set in the target.
  9848. */
  9849. propertyPath: string;
  9850. /**
  9851. * The value to set in the property
  9852. */
  9853. value: any;
  9854. private _target;
  9855. private _effectiveTarget;
  9856. private _property;
  9857. /**
  9858. * Instantiate the action
  9859. * @param triggerOptions defines the trigger options
  9860. * @param target defines the object containing the property
  9861. * @param propertyPath defines the path of the property to set in the target
  9862. * @param value defines the value to set in the property
  9863. * @param condition defines the trigger related conditions
  9864. */
  9865. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9866. /** @hidden */
  9867. _prepare(): void;
  9868. /**
  9869. * Execute the action and set the targetted property to the desired value.
  9870. */
  9871. execute(): void;
  9872. /**
  9873. * Serializes the actions and its related information.
  9874. * @param parent defines the object to serialize in
  9875. * @returns the serialized object
  9876. */
  9877. serialize(parent: any): any;
  9878. }
  9879. /**
  9880. * This defines an action responsible to increment the target value
  9881. * to a desired value once triggered.
  9882. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9883. */
  9884. export class IncrementValueAction extends Action {
  9885. /**
  9886. * The path of the property to increment in the target.
  9887. */
  9888. propertyPath: string;
  9889. /**
  9890. * The value we should increment the property by.
  9891. */
  9892. value: any;
  9893. private _target;
  9894. private _effectiveTarget;
  9895. private _property;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the object containing the property
  9900. * @param propertyPath defines the path of the property to increment in the target
  9901. * @param value defines the value value we should increment the property by
  9902. * @param condition defines the trigger related conditions
  9903. */
  9904. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9905. /** @hidden */
  9906. _prepare(): void;
  9907. /**
  9908. * Execute the action and increment the target of the value amount.
  9909. */
  9910. execute(): void;
  9911. /**
  9912. * Serializes the actions and its related information.
  9913. * @param parent defines the object to serialize in
  9914. * @returns the serialized object
  9915. */
  9916. serialize(parent: any): any;
  9917. }
  9918. /**
  9919. * This defines an action responsible to start an animation once triggered.
  9920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9921. */
  9922. export class PlayAnimationAction extends Action {
  9923. /**
  9924. * Where the animation should start (animation frame)
  9925. */
  9926. from: number;
  9927. /**
  9928. * Where the animation should stop (animation frame)
  9929. */
  9930. to: number;
  9931. /**
  9932. * Define if the animation should loop or stop after the first play.
  9933. */
  9934. loop?: boolean;
  9935. private _target;
  9936. /**
  9937. * Instantiate the action
  9938. * @param triggerOptions defines the trigger options
  9939. * @param target defines the target animation or animation name
  9940. * @param from defines from where the animation should start (animation frame)
  9941. * @param end defines where the animation should stop (animation frame)
  9942. * @param loop defines if the animation should loop or stop after the first play
  9943. * @param condition defines the trigger related conditions
  9944. */
  9945. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9946. /** @hidden */
  9947. _prepare(): void;
  9948. /**
  9949. * Execute the action and play the animation.
  9950. */
  9951. execute(): void;
  9952. /**
  9953. * Serializes the actions and its related information.
  9954. * @param parent defines the object to serialize in
  9955. * @returns the serialized object
  9956. */
  9957. serialize(parent: any): any;
  9958. }
  9959. /**
  9960. * This defines an action responsible to stop an animation once triggered.
  9961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9962. */
  9963. export class StopAnimationAction extends Action {
  9964. private _target;
  9965. /**
  9966. * Instantiate the action
  9967. * @param triggerOptions defines the trigger options
  9968. * @param target defines the target animation or animation name
  9969. * @param condition defines the trigger related conditions
  9970. */
  9971. constructor(triggerOptions: any, target: any, condition?: Condition);
  9972. /** @hidden */
  9973. _prepare(): void;
  9974. /**
  9975. * Execute the action and stop the animation.
  9976. */
  9977. execute(): void;
  9978. /**
  9979. * Serializes the actions and its related information.
  9980. * @param parent defines the object to serialize in
  9981. * @returns the serialized object
  9982. */
  9983. serialize(parent: any): any;
  9984. }
  9985. /**
  9986. * This defines an action responsible that does nothing once triggered.
  9987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9988. */
  9989. export class DoNothingAction extends Action {
  9990. /**
  9991. * Instantiate the action
  9992. * @param triggerOptions defines the trigger options
  9993. * @param condition defines the trigger related conditions
  9994. */
  9995. constructor(triggerOptions?: any, condition?: Condition);
  9996. /**
  9997. * Execute the action and do nothing.
  9998. */
  9999. execute(): void;
  10000. /**
  10001. * Serializes the actions and its related information.
  10002. * @param parent defines the object to serialize in
  10003. * @returns the serialized object
  10004. */
  10005. serialize(parent: any): any;
  10006. }
  10007. /**
  10008. * This defines an action responsible to trigger several actions once triggered.
  10009. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10010. */
  10011. export class CombineAction extends Action {
  10012. /**
  10013. * The list of aggregated animations to run.
  10014. */
  10015. children: Action[];
  10016. /**
  10017. * Instantiate the action
  10018. * @param triggerOptions defines the trigger options
  10019. * @param children defines the list of aggregated animations to run
  10020. * @param condition defines the trigger related conditions
  10021. */
  10022. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10023. /** @hidden */
  10024. _prepare(): void;
  10025. /**
  10026. * Execute the action and executes all the aggregated actions.
  10027. */
  10028. execute(evt: ActionEvent): void;
  10029. /**
  10030. * Serializes the actions and its related information.
  10031. * @param parent defines the object to serialize in
  10032. * @returns the serialized object
  10033. */
  10034. serialize(parent: any): any;
  10035. }
  10036. /**
  10037. * This defines an action responsible to run code (external event) once triggered.
  10038. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10039. */
  10040. export class ExecuteCodeAction extends Action {
  10041. /**
  10042. * The callback function to run.
  10043. */
  10044. func: (evt: ActionEvent) => void;
  10045. /**
  10046. * Instantiate the action
  10047. * @param triggerOptions defines the trigger options
  10048. * @param func defines the callback function to run
  10049. * @param condition defines the trigger related conditions
  10050. */
  10051. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10052. /**
  10053. * Execute the action and run the attached code.
  10054. */
  10055. execute(evt: ActionEvent): void;
  10056. }
  10057. /**
  10058. * This defines an action responsible to set the parent property of the target once triggered.
  10059. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10060. */
  10061. export class SetParentAction extends Action {
  10062. private _parent;
  10063. private _target;
  10064. /**
  10065. * Instantiate the action
  10066. * @param triggerOptions defines the trigger options
  10067. * @param target defines the target containing the parent property
  10068. * @param parent defines from where the animation should start (animation frame)
  10069. * @param condition defines the trigger related conditions
  10070. */
  10071. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10072. /** @hidden */
  10073. _prepare(): void;
  10074. /**
  10075. * Execute the action and set the parent property.
  10076. */
  10077. execute(): void;
  10078. /**
  10079. * Serializes the actions and its related information.
  10080. * @param parent defines the object to serialize in
  10081. * @returns the serialized object
  10082. */
  10083. serialize(parent: any): any;
  10084. }
  10085. }
  10086. declare module BABYLON {
  10087. /**
  10088. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10089. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10091. */
  10092. export class ActionManager extends AbstractActionManager {
  10093. /**
  10094. * Nothing
  10095. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10096. */
  10097. static readonly NothingTrigger: number;
  10098. /**
  10099. * On pick
  10100. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10101. */
  10102. static readonly OnPickTrigger: number;
  10103. /**
  10104. * On left pick
  10105. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10106. */
  10107. static readonly OnLeftPickTrigger: number;
  10108. /**
  10109. * On right pick
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10111. */
  10112. static readonly OnRightPickTrigger: number;
  10113. /**
  10114. * On center pick
  10115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10116. */
  10117. static readonly OnCenterPickTrigger: number;
  10118. /**
  10119. * On pick down
  10120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10121. */
  10122. static readonly OnPickDownTrigger: number;
  10123. /**
  10124. * On double pick
  10125. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10126. */
  10127. static readonly OnDoublePickTrigger: number;
  10128. /**
  10129. * On pick up
  10130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10131. */
  10132. static readonly OnPickUpTrigger: number;
  10133. /**
  10134. * On pick out.
  10135. * This trigger will only be raised if you also declared a OnPickDown
  10136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10137. */
  10138. static readonly OnPickOutTrigger: number;
  10139. /**
  10140. * On long press
  10141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10142. */
  10143. static readonly OnLongPressTrigger: number;
  10144. /**
  10145. * On pointer over
  10146. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10147. */
  10148. static readonly OnPointerOverTrigger: number;
  10149. /**
  10150. * On pointer out
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10152. */
  10153. static readonly OnPointerOutTrigger: number;
  10154. /**
  10155. * On every frame
  10156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10157. */
  10158. static readonly OnEveryFrameTrigger: number;
  10159. /**
  10160. * On intersection enter
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10162. */
  10163. static readonly OnIntersectionEnterTrigger: number;
  10164. /**
  10165. * On intersection exit
  10166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10167. */
  10168. static readonly OnIntersectionExitTrigger: number;
  10169. /**
  10170. * On key down
  10171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10172. */
  10173. static readonly OnKeyDownTrigger: number;
  10174. /**
  10175. * On key up
  10176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10177. */
  10178. static readonly OnKeyUpTrigger: number;
  10179. private _scene;
  10180. /**
  10181. * Creates a new action manager
  10182. * @param scene defines the hosting scene
  10183. */
  10184. constructor(scene: Scene);
  10185. /**
  10186. * Releases all associated resources
  10187. */
  10188. dispose(): void;
  10189. /**
  10190. * Gets hosting scene
  10191. * @returns the hosting scene
  10192. */
  10193. getScene(): Scene;
  10194. /**
  10195. * Does this action manager handles actions of any of the given triggers
  10196. * @param triggers defines the triggers to be tested
  10197. * @return a boolean indicating whether one (or more) of the triggers is handled
  10198. */
  10199. hasSpecificTriggers(triggers: number[]): boolean;
  10200. /**
  10201. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10202. * speed.
  10203. * @param triggerA defines the trigger to be tested
  10204. * @param triggerB defines the trigger to be tested
  10205. * @return a boolean indicating whether one (or more) of the triggers is handled
  10206. */
  10207. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10208. /**
  10209. * Does this action manager handles actions of a given trigger
  10210. * @param trigger defines the trigger to be tested
  10211. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10212. * @return whether the trigger is handled
  10213. */
  10214. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10215. /**
  10216. * Does this action manager has pointer triggers
  10217. */
  10218. get hasPointerTriggers(): boolean;
  10219. /**
  10220. * Does this action manager has pick triggers
  10221. */
  10222. get hasPickTriggers(): boolean;
  10223. /**
  10224. * Registers an action to this action manager
  10225. * @param action defines the action to be registered
  10226. * @return the action amended (prepared) after registration
  10227. */
  10228. registerAction(action: IAction): Nullable<IAction>;
  10229. /**
  10230. * Unregisters an action to this action manager
  10231. * @param action defines the action to be unregistered
  10232. * @return a boolean indicating whether the action has been unregistered
  10233. */
  10234. unregisterAction(action: IAction): Boolean;
  10235. /**
  10236. * Process a specific trigger
  10237. * @param trigger defines the trigger to process
  10238. * @param evt defines the event details to be processed
  10239. */
  10240. processTrigger(trigger: number, evt?: IActionEvent): void;
  10241. /** @hidden */
  10242. _getEffectiveTarget(target: any, propertyPath: string): any;
  10243. /** @hidden */
  10244. _getProperty(propertyPath: string): string;
  10245. /**
  10246. * Serialize this manager to a JSON object
  10247. * @param name defines the property name to store this manager
  10248. * @returns a JSON representation of this manager
  10249. */
  10250. serialize(name: string): any;
  10251. /**
  10252. * Creates a new ActionManager from a JSON data
  10253. * @param parsedActions defines the JSON data to read from
  10254. * @param object defines the hosting mesh
  10255. * @param scene defines the hosting scene
  10256. */
  10257. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10258. /**
  10259. * Get a trigger name by index
  10260. * @param trigger defines the trigger index
  10261. * @returns a trigger name
  10262. */
  10263. static GetTriggerName(trigger: number): string;
  10264. }
  10265. }
  10266. declare module BABYLON {
  10267. /**
  10268. * Class used to represent a sprite
  10269. * @see https://doc.babylonjs.com/babylon101/sprites
  10270. */
  10271. export class Sprite implements IAnimatable {
  10272. /** defines the name */
  10273. name: string;
  10274. /** Gets or sets the current world position */
  10275. position: Vector3;
  10276. /** Gets or sets the main color */
  10277. color: Color4;
  10278. /** Gets or sets the width */
  10279. width: number;
  10280. /** Gets or sets the height */
  10281. height: number;
  10282. /** Gets or sets rotation angle */
  10283. angle: number;
  10284. /** Gets or sets the cell index in the sprite sheet */
  10285. cellIndex: number;
  10286. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10287. cellRef: string;
  10288. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10289. invertU: boolean;
  10290. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10291. invertV: boolean;
  10292. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10293. disposeWhenFinishedAnimating: boolean;
  10294. /** Gets the list of attached animations */
  10295. animations: Nullable<Array<Animation>>;
  10296. /** Gets or sets a boolean indicating if the sprite can be picked */
  10297. isPickable: boolean;
  10298. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10299. useAlphaForPicking: boolean;
  10300. /** @hidden */
  10301. _xOffset: number;
  10302. /** @hidden */
  10303. _yOffset: number;
  10304. /** @hidden */
  10305. _xSize: number;
  10306. /** @hidden */
  10307. _ySize: number;
  10308. /**
  10309. * Gets or sets the associated action manager
  10310. */
  10311. actionManager: Nullable<ActionManager>;
  10312. /**
  10313. * An event triggered when the control has been disposed
  10314. */
  10315. onDisposeObservable: Observable<Sprite>;
  10316. private _animationStarted;
  10317. private _loopAnimation;
  10318. private _fromIndex;
  10319. private _toIndex;
  10320. private _delay;
  10321. private _direction;
  10322. private _manager;
  10323. private _time;
  10324. private _onAnimationEnd;
  10325. /**
  10326. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10327. */
  10328. isVisible: boolean;
  10329. /**
  10330. * Gets or sets the sprite size
  10331. */
  10332. get size(): number;
  10333. set size(value: number);
  10334. /**
  10335. * Returns a boolean indicating if the animation is started
  10336. */
  10337. get animationStarted(): boolean;
  10338. /**
  10339. * Gets or sets the unique id of the sprite
  10340. */
  10341. uniqueId: number;
  10342. /**
  10343. * Gets the manager of this sprite
  10344. */
  10345. get manager(): ISpriteManager;
  10346. /**
  10347. * Creates a new Sprite
  10348. * @param name defines the name
  10349. * @param manager defines the manager
  10350. */
  10351. constructor(
  10352. /** defines the name */
  10353. name: string, manager: ISpriteManager);
  10354. /**
  10355. * Returns the string "Sprite"
  10356. * @returns "Sprite"
  10357. */
  10358. getClassName(): string;
  10359. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10360. get fromIndex(): number;
  10361. set fromIndex(value: number);
  10362. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10363. get toIndex(): number;
  10364. set toIndex(value: number);
  10365. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10366. get loopAnimation(): boolean;
  10367. set loopAnimation(value: boolean);
  10368. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10369. get delay(): number;
  10370. set delay(value: number);
  10371. /**
  10372. * Starts an animation
  10373. * @param from defines the initial key
  10374. * @param to defines the end key
  10375. * @param loop defines if the animation must loop
  10376. * @param delay defines the start delay (in ms)
  10377. * @param onAnimationEnd defines a callback to call when animation ends
  10378. */
  10379. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10380. /** Stops current animation (if any) */
  10381. stopAnimation(): void;
  10382. /** @hidden */
  10383. _animate(deltaTime: number): void;
  10384. /** Release associated resources */
  10385. dispose(): void;
  10386. /**
  10387. * Serializes the sprite to a JSON object
  10388. * @returns the JSON object
  10389. */
  10390. serialize(): any;
  10391. /**
  10392. * Parses a JSON object to create a new sprite
  10393. * @param parsedSprite The JSON object to parse
  10394. * @param manager defines the hosting manager
  10395. * @returns the new sprite
  10396. */
  10397. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10398. }
  10399. }
  10400. declare module BABYLON {
  10401. /**
  10402. * Information about the result of picking within a scene
  10403. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10404. */
  10405. export class PickingInfo {
  10406. /** @hidden */
  10407. _pickingUnavailable: boolean;
  10408. /**
  10409. * If the pick collided with an object
  10410. */
  10411. hit: boolean;
  10412. /**
  10413. * Distance away where the pick collided
  10414. */
  10415. distance: number;
  10416. /**
  10417. * The location of pick collision
  10418. */
  10419. pickedPoint: Nullable<Vector3>;
  10420. /**
  10421. * The mesh corresponding the the pick collision
  10422. */
  10423. pickedMesh: Nullable<AbstractMesh>;
  10424. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10425. bu: number;
  10426. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10427. bv: number;
  10428. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10429. faceId: number;
  10430. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10431. subMeshFaceId: number;
  10432. /** Id of the the submesh that was picked */
  10433. subMeshId: number;
  10434. /** If a sprite was picked, this will be the sprite the pick collided with */
  10435. pickedSprite: Nullable<Sprite>;
  10436. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10437. thinInstanceIndex: number;
  10438. /**
  10439. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10440. */
  10441. originMesh: Nullable<AbstractMesh>;
  10442. /**
  10443. * The ray that was used to perform the picking.
  10444. */
  10445. ray: Nullable<Ray>;
  10446. /**
  10447. * Gets the normal correspodning to the face the pick collided with
  10448. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10449. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10450. * @returns The normal correspodning to the face the pick collided with
  10451. */
  10452. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10453. /**
  10454. * Gets the texture coordinates of where the pick occured
  10455. * @returns the vector containing the coordnates of the texture
  10456. */
  10457. getTextureCoordinates(): Nullable<Vector2>;
  10458. }
  10459. }
  10460. declare module BABYLON {
  10461. /**
  10462. * Class representing a ray with position and direction
  10463. */
  10464. export class Ray {
  10465. /** origin point */
  10466. origin: Vector3;
  10467. /** direction */
  10468. direction: Vector3;
  10469. /** length of the ray */
  10470. length: number;
  10471. private static readonly _TmpVector3;
  10472. private _tmpRay;
  10473. /**
  10474. * Creates a new ray
  10475. * @param origin origin point
  10476. * @param direction direction
  10477. * @param length length of the ray
  10478. */
  10479. constructor(
  10480. /** origin point */
  10481. origin: Vector3,
  10482. /** direction */
  10483. direction: Vector3,
  10484. /** length of the ray */
  10485. length?: number);
  10486. /**
  10487. * Checks if the ray intersects a box
  10488. * This does not account for the ray lenght by design to improve perfs.
  10489. * @param minimum bound of the box
  10490. * @param maximum bound of the box
  10491. * @param intersectionTreshold extra extend to be added to the box in all direction
  10492. * @returns if the box was hit
  10493. */
  10494. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10495. /**
  10496. * Checks if the ray intersects a box
  10497. * This does not account for the ray lenght by design to improve perfs.
  10498. * @param box the bounding box to check
  10499. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10500. * @returns if the box was hit
  10501. */
  10502. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10503. /**
  10504. * If the ray hits a sphere
  10505. * @param sphere the bounding sphere to check
  10506. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10507. * @returns true if it hits the sphere
  10508. */
  10509. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10510. /**
  10511. * If the ray hits a triange
  10512. * @param vertex0 triangle vertex
  10513. * @param vertex1 triangle vertex
  10514. * @param vertex2 triangle vertex
  10515. * @returns intersection information if hit
  10516. */
  10517. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10518. /**
  10519. * Checks if ray intersects a plane
  10520. * @param plane the plane to check
  10521. * @returns the distance away it was hit
  10522. */
  10523. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10524. /**
  10525. * Calculate the intercept of a ray on a given axis
  10526. * @param axis to check 'x' | 'y' | 'z'
  10527. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10528. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10529. */
  10530. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10531. /**
  10532. * Checks if ray intersects a mesh
  10533. * @param mesh the mesh to check
  10534. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10535. * @returns picking info of the intersecton
  10536. */
  10537. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10538. /**
  10539. * Checks if ray intersects a mesh
  10540. * @param meshes the meshes to check
  10541. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10542. * @param results array to store result in
  10543. * @returns Array of picking infos
  10544. */
  10545. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10546. private _comparePickingInfo;
  10547. private static smallnum;
  10548. private static rayl;
  10549. /**
  10550. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10551. * @param sega the first point of the segment to test the intersection against
  10552. * @param segb the second point of the segment to test the intersection against
  10553. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10554. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10555. */
  10556. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10557. /**
  10558. * Update the ray from viewport position
  10559. * @param x position
  10560. * @param y y position
  10561. * @param viewportWidth viewport width
  10562. * @param viewportHeight viewport height
  10563. * @param world world matrix
  10564. * @param view view matrix
  10565. * @param projection projection matrix
  10566. * @returns this ray updated
  10567. */
  10568. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10569. /**
  10570. * Creates a ray with origin and direction of 0,0,0
  10571. * @returns the new ray
  10572. */
  10573. static Zero(): Ray;
  10574. /**
  10575. * Creates a new ray from screen space and viewport
  10576. * @param x position
  10577. * @param y y position
  10578. * @param viewportWidth viewport width
  10579. * @param viewportHeight viewport height
  10580. * @param world world matrix
  10581. * @param view view matrix
  10582. * @param projection projection matrix
  10583. * @returns new ray
  10584. */
  10585. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10586. /**
  10587. * 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
  10588. * transformed to the given world matrix.
  10589. * @param origin The origin point
  10590. * @param end The end point
  10591. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10592. * @returns the new ray
  10593. */
  10594. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10595. /**
  10596. * Transforms a ray by a matrix
  10597. * @param ray ray to transform
  10598. * @param matrix matrix to apply
  10599. * @returns the resulting new ray
  10600. */
  10601. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10602. /**
  10603. * Transforms a ray by a matrix
  10604. * @param ray ray to transform
  10605. * @param matrix matrix to apply
  10606. * @param result ray to store result in
  10607. */
  10608. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10609. /**
  10610. * Unproject a ray from screen space to object space
  10611. * @param sourceX defines the screen space x coordinate to use
  10612. * @param sourceY defines the screen space y coordinate to use
  10613. * @param viewportWidth defines the current width of the viewport
  10614. * @param viewportHeight defines the current height of the viewport
  10615. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10616. * @param view defines the view matrix to use
  10617. * @param projection defines the projection matrix to use
  10618. */
  10619. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10620. }
  10621. /**
  10622. * Type used to define predicate used to select faces when a mesh intersection is detected
  10623. */
  10624. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10625. interface Scene {
  10626. /** @hidden */
  10627. _tempPickingRay: Nullable<Ray>;
  10628. /** @hidden */
  10629. _cachedRayForTransform: Ray;
  10630. /** @hidden */
  10631. _pickWithRayInverseMatrix: Matrix;
  10632. /** @hidden */
  10633. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10634. /** @hidden */
  10635. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10636. /** @hidden */
  10637. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10638. }
  10639. }
  10640. declare module BABYLON {
  10641. /**
  10642. * Groups all the scene component constants in one place to ease maintenance.
  10643. * @hidden
  10644. */
  10645. export class SceneComponentConstants {
  10646. static readonly NAME_EFFECTLAYER: string;
  10647. static readonly NAME_LAYER: string;
  10648. static readonly NAME_LENSFLARESYSTEM: string;
  10649. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10650. static readonly NAME_PARTICLESYSTEM: string;
  10651. static readonly NAME_GAMEPAD: string;
  10652. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10653. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10654. static readonly NAME_PREPASSRENDERER: string;
  10655. static readonly NAME_DEPTHRENDERER: string;
  10656. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10657. static readonly NAME_SPRITE: string;
  10658. static readonly NAME_OUTLINERENDERER: string;
  10659. static readonly NAME_PROCEDURALTEXTURE: string;
  10660. static readonly NAME_SHADOWGENERATOR: string;
  10661. static readonly NAME_OCTREE: string;
  10662. static readonly NAME_PHYSICSENGINE: string;
  10663. static readonly NAME_AUDIO: string;
  10664. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10665. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10666. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10667. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10668. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10669. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10670. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10671. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10672. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10673. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10674. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10675. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10676. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10677. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10678. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10679. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10680. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10681. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10682. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10683. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10684. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10685. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10686. static readonly STEP_AFTERRENDER_AUDIO: number;
  10687. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10688. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10689. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10690. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10691. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10692. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10693. static readonly STEP_POINTERMOVE_SPRITE: number;
  10694. static readonly STEP_POINTERDOWN_SPRITE: number;
  10695. static readonly STEP_POINTERUP_SPRITE: number;
  10696. }
  10697. /**
  10698. * This represents a scene component.
  10699. *
  10700. * This is used to decouple the dependency the scene is having on the different workloads like
  10701. * layers, post processes...
  10702. */
  10703. export interface ISceneComponent {
  10704. /**
  10705. * The name of the component. Each component must have a unique name.
  10706. */
  10707. name: string;
  10708. /**
  10709. * The scene the component belongs to.
  10710. */
  10711. scene: Scene;
  10712. /**
  10713. * Register the component to one instance of a scene.
  10714. */
  10715. register(): void;
  10716. /**
  10717. * Rebuilds the elements related to this component in case of
  10718. * context lost for instance.
  10719. */
  10720. rebuild(): void;
  10721. /**
  10722. * Disposes the component and the associated ressources.
  10723. */
  10724. dispose(): void;
  10725. }
  10726. /**
  10727. * This represents a SERIALIZABLE scene component.
  10728. *
  10729. * This extends Scene Component to add Serialization methods on top.
  10730. */
  10731. export interface ISceneSerializableComponent extends ISceneComponent {
  10732. /**
  10733. * Adds all the elements from the container to the scene
  10734. * @param container the container holding the elements
  10735. */
  10736. addFromContainer(container: AbstractScene): void;
  10737. /**
  10738. * Removes all the elements in the container from the scene
  10739. * @param container contains the elements to remove
  10740. * @param dispose if the removed element should be disposed (default: false)
  10741. */
  10742. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10743. /**
  10744. * Serializes the component data to the specified json object
  10745. * @param serializationObject The object to serialize to
  10746. */
  10747. serialize(serializationObject: any): void;
  10748. }
  10749. /**
  10750. * Strong typing of a Mesh related stage step action
  10751. */
  10752. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10753. /**
  10754. * Strong typing of a Evaluate Sub Mesh related stage step action
  10755. */
  10756. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10757. /**
  10758. * Strong typing of a Active Mesh related stage step action
  10759. */
  10760. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10761. /**
  10762. * Strong typing of a Camera related stage step action
  10763. */
  10764. export type CameraStageAction = (camera: Camera) => void;
  10765. /**
  10766. * Strong typing of a Camera Frame buffer related stage step action
  10767. */
  10768. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10769. /**
  10770. * Strong typing of a Render Target related stage step action
  10771. */
  10772. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10773. /**
  10774. * Strong typing of a RenderingGroup related stage step action
  10775. */
  10776. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10777. /**
  10778. * Strong typing of a Mesh Render related stage step action
  10779. */
  10780. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10781. /**
  10782. * Strong typing of a simple stage step action
  10783. */
  10784. export type SimpleStageAction = () => void;
  10785. /**
  10786. * Strong typing of a render target action.
  10787. */
  10788. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10789. /**
  10790. * Strong typing of a pointer move action.
  10791. */
  10792. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10793. /**
  10794. * Strong typing of a pointer up/down action.
  10795. */
  10796. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10797. /**
  10798. * Representation of a stage in the scene (Basically a list of ordered steps)
  10799. * @hidden
  10800. */
  10801. export class Stage<T extends Function> extends Array<{
  10802. index: number;
  10803. component: ISceneComponent;
  10804. action: T;
  10805. }> {
  10806. /**
  10807. * Hide ctor from the rest of the world.
  10808. * @param items The items to add.
  10809. */
  10810. private constructor();
  10811. /**
  10812. * Creates a new Stage.
  10813. * @returns A new instance of a Stage
  10814. */
  10815. static Create<T extends Function>(): Stage<T>;
  10816. /**
  10817. * Registers a step in an ordered way in the targeted stage.
  10818. * @param index Defines the position to register the step in
  10819. * @param component Defines the component attached to the step
  10820. * @param action Defines the action to launch during the step
  10821. */
  10822. registerStep(index: number, component: ISceneComponent, action: T): void;
  10823. /**
  10824. * Clears all the steps from the stage.
  10825. */
  10826. clear(): void;
  10827. }
  10828. }
  10829. declare module BABYLON {
  10830. interface Scene {
  10831. /** @hidden */
  10832. _pointerOverSprite: Nullable<Sprite>;
  10833. /** @hidden */
  10834. _pickedDownSprite: Nullable<Sprite>;
  10835. /** @hidden */
  10836. _tempSpritePickingRay: Nullable<Ray>;
  10837. /**
  10838. * All of the sprite managers added to this scene
  10839. * @see https://doc.babylonjs.com/babylon101/sprites
  10840. */
  10841. spriteManagers: Array<ISpriteManager>;
  10842. /**
  10843. * An event triggered when sprites rendering is about to start
  10844. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10845. */
  10846. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10847. /**
  10848. * An event triggered when sprites rendering is done
  10849. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10850. */
  10851. onAfterSpritesRenderingObservable: Observable<Scene>;
  10852. /** @hidden */
  10853. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10854. /** Launch a ray to try to pick a sprite in the scene
  10855. * @param x position on screen
  10856. * @param y position on screen
  10857. * @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
  10858. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10859. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10860. * @returns a PickingInfo
  10861. */
  10862. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10863. /** Use the given ray to pick a sprite in the scene
  10864. * @param ray The ray (in world space) to use to pick meshes
  10865. * @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
  10866. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10867. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10868. * @returns a PickingInfo
  10869. */
  10870. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10871. /** @hidden */
  10872. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10873. /** Launch a ray to try to pick sprites in the scene
  10874. * @param x position on screen
  10875. * @param y position on screen
  10876. * @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
  10877. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10878. * @returns a PickingInfo array
  10879. */
  10880. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10881. /** Use the given ray to pick sprites in the scene
  10882. * @param ray The ray (in world space) to use to pick meshes
  10883. * @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
  10884. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10885. * @returns a PickingInfo array
  10886. */
  10887. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10888. /**
  10889. * Force the sprite under the pointer
  10890. * @param sprite defines the sprite to use
  10891. */
  10892. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10893. /**
  10894. * Gets the sprite under the pointer
  10895. * @returns a Sprite or null if no sprite is under the pointer
  10896. */
  10897. getPointerOverSprite(): Nullable<Sprite>;
  10898. }
  10899. /**
  10900. * Defines the sprite scene component responsible to manage sprites
  10901. * in a given scene.
  10902. */
  10903. export class SpriteSceneComponent implements ISceneComponent {
  10904. /**
  10905. * The component name helpfull to identify the component in the list of scene components.
  10906. */
  10907. readonly name: string;
  10908. /**
  10909. * The scene the component belongs to.
  10910. */
  10911. scene: Scene;
  10912. /** @hidden */
  10913. private _spritePredicate;
  10914. /**
  10915. * Creates a new instance of the component for the given scene
  10916. * @param scene Defines the scene to register the component in
  10917. */
  10918. constructor(scene: Scene);
  10919. /**
  10920. * Registers the component in a given scene
  10921. */
  10922. register(): void;
  10923. /**
  10924. * Rebuilds the elements related to this component in case of
  10925. * context lost for instance.
  10926. */
  10927. rebuild(): void;
  10928. /**
  10929. * Disposes the component and the associated ressources.
  10930. */
  10931. dispose(): void;
  10932. private _pickSpriteButKeepRay;
  10933. private _pointerMove;
  10934. private _pointerDown;
  10935. private _pointerUp;
  10936. }
  10937. }
  10938. declare module BABYLON {
  10939. /** @hidden */
  10940. export var fogFragmentDeclaration: {
  10941. name: string;
  10942. shader: string;
  10943. };
  10944. }
  10945. declare module BABYLON {
  10946. /** @hidden */
  10947. export var fogFragment: {
  10948. name: string;
  10949. shader: string;
  10950. };
  10951. }
  10952. declare module BABYLON {
  10953. /** @hidden */
  10954. export var spritesPixelShader: {
  10955. name: string;
  10956. shader: string;
  10957. };
  10958. }
  10959. declare module BABYLON {
  10960. /** @hidden */
  10961. export var fogVertexDeclaration: {
  10962. name: string;
  10963. shader: string;
  10964. };
  10965. }
  10966. declare module BABYLON {
  10967. /** @hidden */
  10968. export var spritesVertexShader: {
  10969. name: string;
  10970. shader: string;
  10971. };
  10972. }
  10973. declare module BABYLON {
  10974. /**
  10975. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10976. */
  10977. export interface ISpriteManager extends IDisposable {
  10978. /**
  10979. * Gets manager's name
  10980. */
  10981. name: string;
  10982. /**
  10983. * Restricts the camera to viewing objects with the same layerMask.
  10984. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10985. */
  10986. layerMask: number;
  10987. /**
  10988. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10989. */
  10990. isPickable: boolean;
  10991. /**
  10992. * Gets the hosting scene
  10993. */
  10994. scene: Scene;
  10995. /**
  10996. * Specifies the rendering group id for this mesh (0 by default)
  10997. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10998. */
  10999. renderingGroupId: number;
  11000. /**
  11001. * Defines the list of sprites managed by the manager.
  11002. */
  11003. sprites: Array<Sprite>;
  11004. /**
  11005. * Gets or sets the spritesheet texture
  11006. */
  11007. texture: Texture;
  11008. /** Defines the default width of a cell in the spritesheet */
  11009. cellWidth: number;
  11010. /** Defines the default height of a cell in the spritesheet */
  11011. cellHeight: number;
  11012. /**
  11013. * Tests the intersection of a sprite with a specific ray.
  11014. * @param ray The ray we are sending to test the collision
  11015. * @param camera The camera space we are sending rays in
  11016. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11017. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11018. * @returns picking info or null.
  11019. */
  11020. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11021. /**
  11022. * Intersects the sprites with a ray
  11023. * @param ray defines the ray to intersect with
  11024. * @param camera defines the current active camera
  11025. * @param predicate defines a predicate used to select candidate sprites
  11026. * @returns null if no hit or a PickingInfo array
  11027. */
  11028. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11029. /**
  11030. * Renders the list of sprites on screen.
  11031. */
  11032. render(): void;
  11033. }
  11034. /**
  11035. * Class used to manage multiple sprites on the same spritesheet
  11036. * @see https://doc.babylonjs.com/babylon101/sprites
  11037. */
  11038. export class SpriteManager implements ISpriteManager {
  11039. /** defines the manager's name */
  11040. name: string;
  11041. /** Define the Url to load snippets */
  11042. static SnippetUrl: string;
  11043. /** Snippet ID if the manager was created from the snippet server */
  11044. snippetId: string;
  11045. /** Gets the list of sprites */
  11046. sprites: Sprite[];
  11047. /** Gets or sets the rendering group id (0 by default) */
  11048. renderingGroupId: number;
  11049. /** Gets or sets camera layer mask */
  11050. layerMask: number;
  11051. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11052. fogEnabled: boolean;
  11053. /** Gets or sets a boolean indicating if the sprites are pickable */
  11054. isPickable: boolean;
  11055. /** Defines the default width of a cell in the spritesheet */
  11056. cellWidth: number;
  11057. /** Defines the default height of a cell in the spritesheet */
  11058. cellHeight: number;
  11059. /** Associative array from JSON sprite data file */
  11060. private _cellData;
  11061. /** Array of sprite names from JSON sprite data file */
  11062. private _spriteMap;
  11063. /** True when packed cell data from JSON file is ready*/
  11064. private _packedAndReady;
  11065. private _textureContent;
  11066. private _useInstancing;
  11067. /**
  11068. * An event triggered when the manager is disposed.
  11069. */
  11070. onDisposeObservable: Observable<SpriteManager>;
  11071. private _onDisposeObserver;
  11072. /**
  11073. * Callback called when the manager is disposed
  11074. */
  11075. set onDispose(callback: () => void);
  11076. private _capacity;
  11077. private _fromPacked;
  11078. private _spriteTexture;
  11079. private _epsilon;
  11080. private _scene;
  11081. private _vertexData;
  11082. private _buffer;
  11083. private _vertexBuffers;
  11084. private _spriteBuffer;
  11085. private _indexBuffer;
  11086. private _effectBase;
  11087. private _effectFog;
  11088. private _vertexBufferSize;
  11089. /**
  11090. * Gets or sets the unique id of the sprite
  11091. */
  11092. uniqueId: number;
  11093. /**
  11094. * Gets the array of sprites
  11095. */
  11096. get children(): Sprite[];
  11097. /**
  11098. * Gets the hosting scene
  11099. */
  11100. get scene(): Scene;
  11101. /**
  11102. * Gets the capacity of the manager
  11103. */
  11104. get capacity(): number;
  11105. /**
  11106. * Gets or sets the spritesheet texture
  11107. */
  11108. get texture(): Texture;
  11109. set texture(value: Texture);
  11110. private _blendMode;
  11111. /**
  11112. * Blend mode use to render the particle, it can be any of
  11113. * the static Constants.ALPHA_x properties provided in this class.
  11114. * Default value is Constants.ALPHA_COMBINE
  11115. */
  11116. get blendMode(): number;
  11117. set blendMode(blendMode: number);
  11118. /** Disables writing to the depth buffer when rendering the sprites.
  11119. * It can be handy to disable depth writing when using textures without alpha channel
  11120. * and setting some specific blend modes.
  11121. */
  11122. disableDepthWrite: boolean;
  11123. /**
  11124. * Creates a new sprite manager
  11125. * @param name defines the manager's name
  11126. * @param imgUrl defines the sprite sheet url
  11127. * @param capacity defines the maximum allowed number of sprites
  11128. * @param cellSize defines the size of a sprite cell
  11129. * @param scene defines the hosting scene
  11130. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11131. * @param samplingMode defines the smapling mode to use with spritesheet
  11132. * @param fromPacked set to false; do not alter
  11133. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11134. */
  11135. constructor(
  11136. /** defines the manager's name */
  11137. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11138. /**
  11139. * Returns the string "SpriteManager"
  11140. * @returns "SpriteManager"
  11141. */
  11142. getClassName(): string;
  11143. private _makePacked;
  11144. private _appendSpriteVertex;
  11145. private _checkTextureAlpha;
  11146. /**
  11147. * Intersects the sprites with a ray
  11148. * @param ray defines the ray to intersect with
  11149. * @param camera defines the current active camera
  11150. * @param predicate defines a predicate used to select candidate sprites
  11151. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11152. * @returns null if no hit or a PickingInfo
  11153. */
  11154. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11155. /**
  11156. * Intersects the sprites with a ray
  11157. * @param ray defines the ray to intersect with
  11158. * @param camera defines the current active camera
  11159. * @param predicate defines a predicate used to select candidate sprites
  11160. * @returns null if no hit or a PickingInfo array
  11161. */
  11162. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11163. /**
  11164. * Render all child sprites
  11165. */
  11166. render(): void;
  11167. /**
  11168. * Release associated resources
  11169. */
  11170. dispose(): void;
  11171. /**
  11172. * Serializes the sprite manager to a JSON object
  11173. * @param serializeTexture defines if the texture must be serialized as well
  11174. * @returns the JSON object
  11175. */
  11176. serialize(serializeTexture?: boolean): any;
  11177. /**
  11178. * Parses a JSON object to create a new sprite manager.
  11179. * @param parsedManager The JSON object to parse
  11180. * @param scene The scene to create the sprite managerin
  11181. * @param rootUrl The root url to use to load external dependencies like texture
  11182. * @returns the new sprite manager
  11183. */
  11184. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11185. /**
  11186. * Creates a sprite manager from a snippet saved in a remote file
  11187. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11188. * @param url defines the url to load from
  11189. * @param scene defines the hosting scene
  11190. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11191. * @returns a promise that will resolve to the new sprite manager
  11192. */
  11193. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11194. /**
  11195. * Creates a sprite manager from a snippet saved by the sprite editor
  11196. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11197. * @param scene defines the hosting scene
  11198. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11199. * @returns a promise that will resolve to the new sprite manager
  11200. */
  11201. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11202. }
  11203. }
  11204. declare module BABYLON {
  11205. /** Interface used by value gradients (color, factor, ...) */
  11206. export interface IValueGradient {
  11207. /**
  11208. * Gets or sets the gradient value (between 0 and 1)
  11209. */
  11210. gradient: number;
  11211. }
  11212. /** Class used to store color4 gradient */
  11213. export class ColorGradient implements IValueGradient {
  11214. /**
  11215. * Gets or sets the gradient value (between 0 and 1)
  11216. */
  11217. gradient: number;
  11218. /**
  11219. * Gets or sets first associated color
  11220. */
  11221. color1: Color4;
  11222. /**
  11223. * Gets or sets second associated color
  11224. */
  11225. color2?: Color4 | undefined;
  11226. /**
  11227. * Creates a new color4 gradient
  11228. * @param gradient gets or sets the gradient value (between 0 and 1)
  11229. * @param color1 gets or sets first associated color
  11230. * @param color2 gets or sets first second color
  11231. */
  11232. constructor(
  11233. /**
  11234. * Gets or sets the gradient value (between 0 and 1)
  11235. */
  11236. gradient: number,
  11237. /**
  11238. * Gets or sets first associated color
  11239. */
  11240. color1: Color4,
  11241. /**
  11242. * Gets or sets second associated color
  11243. */
  11244. color2?: Color4 | undefined);
  11245. /**
  11246. * Will get a color picked randomly between color1 and color2.
  11247. * If color2 is undefined then color1 will be used
  11248. * @param result defines the target Color4 to store the result in
  11249. */
  11250. getColorToRef(result: Color4): void;
  11251. }
  11252. /** Class used to store color 3 gradient */
  11253. export class Color3Gradient implements IValueGradient {
  11254. /**
  11255. * Gets or sets the gradient value (between 0 and 1)
  11256. */
  11257. gradient: number;
  11258. /**
  11259. * Gets or sets the associated color
  11260. */
  11261. color: Color3;
  11262. /**
  11263. * Creates a new color3 gradient
  11264. * @param gradient gets or sets the gradient value (between 0 and 1)
  11265. * @param color gets or sets associated color
  11266. */
  11267. constructor(
  11268. /**
  11269. * Gets or sets the gradient value (between 0 and 1)
  11270. */
  11271. gradient: number,
  11272. /**
  11273. * Gets or sets the associated color
  11274. */
  11275. color: Color3);
  11276. }
  11277. /** Class used to store factor gradient */
  11278. export class FactorGradient implements IValueGradient {
  11279. /**
  11280. * Gets or sets the gradient value (between 0 and 1)
  11281. */
  11282. gradient: number;
  11283. /**
  11284. * Gets or sets first associated factor
  11285. */
  11286. factor1: number;
  11287. /**
  11288. * Gets or sets second associated factor
  11289. */
  11290. factor2?: number | undefined;
  11291. /**
  11292. * Creates a new factor gradient
  11293. * @param gradient gets or sets the gradient value (between 0 and 1)
  11294. * @param factor1 gets or sets first associated factor
  11295. * @param factor2 gets or sets second associated factor
  11296. */
  11297. constructor(
  11298. /**
  11299. * Gets or sets the gradient value (between 0 and 1)
  11300. */
  11301. gradient: number,
  11302. /**
  11303. * Gets or sets first associated factor
  11304. */
  11305. factor1: number,
  11306. /**
  11307. * Gets or sets second associated factor
  11308. */
  11309. factor2?: number | undefined);
  11310. /**
  11311. * Will get a number picked randomly between factor1 and factor2.
  11312. * If factor2 is undefined then factor1 will be used
  11313. * @returns the picked number
  11314. */
  11315. getFactor(): number;
  11316. }
  11317. /**
  11318. * Helper used to simplify some generic gradient tasks
  11319. */
  11320. export class GradientHelper {
  11321. /**
  11322. * Gets the current gradient from an array of IValueGradient
  11323. * @param ratio defines the current ratio to get
  11324. * @param gradients defines the array of IValueGradient
  11325. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11326. */
  11327. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11328. }
  11329. }
  11330. declare module BABYLON {
  11331. interface ThinEngine {
  11332. /**
  11333. * Creates a raw texture
  11334. * @param data defines the data to store in the texture
  11335. * @param width defines the width of the texture
  11336. * @param height defines the height of the texture
  11337. * @param format defines the format of the data
  11338. * @param generateMipMaps defines if the engine should generate the mip levels
  11339. * @param invertY defines if data must be stored with Y axis inverted
  11340. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11341. * @param compression defines the compression used (null by default)
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. * @returns the raw texture inside an InternalTexture
  11344. */
  11345. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11346. /**
  11347. * Update a raw texture
  11348. * @param texture defines the texture to update
  11349. * @param data defines the data to store in the texture
  11350. * @param format defines the format of the data
  11351. * @param invertY defines if data must be stored with Y axis inverted
  11352. */
  11353. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11354. /**
  11355. * Update a raw texture
  11356. * @param texture defines the texture to update
  11357. * @param data defines the data to store in the texture
  11358. * @param format defines the format of the data
  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 type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11362. */
  11363. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11364. /**
  11365. * Creates a new raw cube texture
  11366. * @param data defines the array of data to use to create each face
  11367. * @param size defines the size of the textures
  11368. * @param format defines the format of the data
  11369. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11370. * @param generateMipMaps defines if the engine should generate the mip levels
  11371. * @param invertY defines if data must be stored with Y axis inverted
  11372. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11373. * @param compression defines the compression used (null by default)
  11374. * @returns the cube texture as an InternalTexture
  11375. */
  11376. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11377. /**
  11378. * Update a raw cube texture
  11379. * @param texture defines the texture to udpdate
  11380. * @param data defines the data to store
  11381. * @param format defines the data format
  11382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11383. * @param invertY defines if data must be stored with Y axis inverted
  11384. */
  11385. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11386. /**
  11387. * Update a raw cube texture
  11388. * @param texture defines the texture to udpdate
  11389. * @param data defines the data to store
  11390. * @param format defines the data format
  11391. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11392. * @param invertY defines if data must be stored with Y axis inverted
  11393. * @param compression defines the compression used (null by default)
  11394. */
  11395. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11396. /**
  11397. * Update a raw cube texture
  11398. * @param texture defines the texture to udpdate
  11399. * @param data defines the data to store
  11400. * @param format defines the data format
  11401. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11402. * @param invertY defines if data must be stored with Y axis inverted
  11403. * @param compression defines the compression used (null by default)
  11404. * @param level defines which level of the texture to update
  11405. */
  11406. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11407. /**
  11408. * Creates a new raw cube texture from a specified url
  11409. * @param url defines the url where the data is located
  11410. * @param scene defines the current scene
  11411. * @param size defines the size of the textures
  11412. * @param format defines the format of the data
  11413. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11414. * @param noMipmap defines if the engine should avoid generating the mip levels
  11415. * @param callback defines a callback used to extract texture data from loaded data
  11416. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11417. * @param onLoad defines a callback called when texture is loaded
  11418. * @param onError defines a callback called if there is an error
  11419. * @returns the cube texture as an InternalTexture
  11420. */
  11421. 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;
  11422. /**
  11423. * Creates a new raw cube texture from a specified url
  11424. * @param url defines the url where the data is located
  11425. * @param scene defines the current scene
  11426. * @param size defines the size of the textures
  11427. * @param format defines the format of the data
  11428. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11429. * @param noMipmap defines if the engine should avoid generating the mip levels
  11430. * @param callback defines a callback used to extract texture data from loaded data
  11431. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11432. * @param onLoad defines a callback called when texture is loaded
  11433. * @param onError defines a callback called if there is an error
  11434. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11435. * @param invertY defines if data must be stored with Y axis inverted
  11436. * @returns the cube texture as an InternalTexture
  11437. */
  11438. 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;
  11439. /**
  11440. * Creates a new raw 3D texture
  11441. * @param data defines the data used to create the texture
  11442. * @param width defines the width of the texture
  11443. * @param height defines the height of the texture
  11444. * @param depth defines the depth of the texture
  11445. * @param format defines the format of the texture
  11446. * @param generateMipMaps defines if the engine must generate mip levels
  11447. * @param invertY defines if data must be stored with Y axis inverted
  11448. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11449. * @param compression defines the compressed used (can be null)
  11450. * @param textureType defines the compressed used (can be null)
  11451. * @returns a new raw 3D texture (stored in an InternalTexture)
  11452. */
  11453. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11454. /**
  11455. * Update a raw 3D texture
  11456. * @param texture defines the texture to update
  11457. * @param data defines the data to store
  11458. * @param format defines the data format
  11459. * @param invertY defines if data must be stored with Y axis inverted
  11460. */
  11461. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11462. /**
  11463. * Update a raw 3D texture
  11464. * @param texture defines the texture to update
  11465. * @param data defines the data to store
  11466. * @param format defines the data format
  11467. * @param invertY defines if data must be stored with Y axis inverted
  11468. * @param compression defines the used compression (can be null)
  11469. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11470. */
  11471. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11472. /**
  11473. * Creates a new raw 2D array texture
  11474. * @param data defines the data used to create the texture
  11475. * @param width defines the width of the texture
  11476. * @param height defines the height of the texture
  11477. * @param depth defines the number of layers of the texture
  11478. * @param format defines the format of the texture
  11479. * @param generateMipMaps defines if the engine must generate mip levels
  11480. * @param invertY defines if data must be stored with Y axis inverted
  11481. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11482. * @param compression defines the compressed used (can be null)
  11483. * @param textureType defines the compressed used (can be null)
  11484. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11485. */
  11486. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11487. /**
  11488. * Update a raw 2D array texture
  11489. * @param texture defines the texture to update
  11490. * @param data defines the data to store
  11491. * @param format defines the data format
  11492. * @param invertY defines if data must be stored with Y axis inverted
  11493. */
  11494. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11495. /**
  11496. * Update a raw 2D array texture
  11497. * @param texture defines the texture to update
  11498. * @param data defines the data to store
  11499. * @param format defines the data format
  11500. * @param invertY defines if data must be stored with Y axis inverted
  11501. * @param compression defines the used compression (can be null)
  11502. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11503. */
  11504. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11505. }
  11506. }
  11507. declare module BABYLON {
  11508. /**
  11509. * Raw texture can help creating a texture directly from an array of data.
  11510. * This can be super useful if you either get the data from an uncompressed source or
  11511. * if you wish to create your texture pixel by pixel.
  11512. */
  11513. export class RawTexture extends Texture {
  11514. /**
  11515. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11516. */
  11517. format: number;
  11518. /**
  11519. * Instantiates a new RawTexture.
  11520. * Raw texture can help creating a texture directly from an array of data.
  11521. * This can be super useful if you either get the data from an uncompressed source or
  11522. * if you wish to create your texture pixel by pixel.
  11523. * @param data define the array of data to use to create the texture
  11524. * @param width define the width of the texture
  11525. * @param height define the height of the texture
  11526. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11527. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11528. * @param generateMipMaps define whether mip maps should be generated or not
  11529. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11530. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11531. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11532. */
  11533. constructor(data: ArrayBufferView, width: number, height: number,
  11534. /**
  11535. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11536. */
  11537. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11538. /**
  11539. * Updates the texture underlying data.
  11540. * @param data Define the new data of the texture
  11541. */
  11542. update(data: ArrayBufferView): void;
  11543. /**
  11544. * Creates a luminance texture from some data.
  11545. * @param data Define the texture data
  11546. * @param width Define the width of the texture
  11547. * @param height Define the height of the texture
  11548. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11549. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11550. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11551. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11552. * @returns the luminance texture
  11553. */
  11554. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11555. /**
  11556. * Creates a luminance alpha texture from some data.
  11557. * @param data Define the texture data
  11558. * @param width Define the width of the texture
  11559. * @param height Define the height of the texture
  11560. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11561. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11562. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11563. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11564. * @returns the luminance alpha texture
  11565. */
  11566. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11567. /**
  11568. * Creates an alpha texture from some data.
  11569. * @param data Define the texture data
  11570. * @param width Define the width of the texture
  11571. * @param height Define the height of the texture
  11572. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11573. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11574. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11575. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11576. * @returns the alpha texture
  11577. */
  11578. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11579. /**
  11580. * Creates a RGB texture from some data.
  11581. * @param data Define the texture data
  11582. * @param width Define the width of the texture
  11583. * @param height Define the height of the texture
  11584. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11585. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11586. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11587. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11588. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11589. * @returns the RGB alpha texture
  11590. */
  11591. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11592. /**
  11593. * Creates a RGBA texture from some data.
  11594. * @param data Define the texture data
  11595. * @param width Define the width of the texture
  11596. * @param height Define the height of the texture
  11597. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11598. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11599. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11600. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11601. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11602. * @returns the RGBA texture
  11603. */
  11604. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11605. /**
  11606. * Creates a R texture from some data.
  11607. * @param data Define the texture data
  11608. * @param width Define the width of the texture
  11609. * @param height Define the height of the texture
  11610. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11611. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11612. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11613. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11614. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11615. * @returns the R texture
  11616. */
  11617. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11618. }
  11619. }
  11620. declare module BABYLON {
  11621. interface ThinEngine {
  11622. /**
  11623. * Update a dynamic index buffer
  11624. * @param indexBuffer defines the target index buffer
  11625. * @param indices defines the data to update
  11626. * @param offset defines the offset in the target index buffer where update should start
  11627. */
  11628. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11629. /**
  11630. * Updates a dynamic vertex buffer.
  11631. * @param vertexBuffer the vertex buffer to update
  11632. * @param data the data used to update the vertex buffer
  11633. * @param byteOffset the byte offset of the data
  11634. * @param byteLength the byte length of the data
  11635. */
  11636. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11637. }
  11638. }
  11639. declare module BABYLON {
  11640. interface AbstractScene {
  11641. /**
  11642. * The list of procedural textures added to the scene
  11643. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11644. */
  11645. proceduralTextures: Array<ProceduralTexture>;
  11646. }
  11647. /**
  11648. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11649. * in a given scene.
  11650. */
  11651. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11652. /**
  11653. * The component name helpfull to identify the component in the list of scene components.
  11654. */
  11655. readonly name: string;
  11656. /**
  11657. * The scene the component belongs to.
  11658. */
  11659. scene: Scene;
  11660. /**
  11661. * Creates a new instance of the component for the given scene
  11662. * @param scene Defines the scene to register the component in
  11663. */
  11664. constructor(scene: Scene);
  11665. /**
  11666. * Registers the component in a given scene
  11667. */
  11668. register(): void;
  11669. /**
  11670. * Rebuilds the elements related to this component in case of
  11671. * context lost for instance.
  11672. */
  11673. rebuild(): void;
  11674. /**
  11675. * Disposes the component and the associated ressources.
  11676. */
  11677. dispose(): void;
  11678. private _beforeClear;
  11679. }
  11680. }
  11681. declare module BABYLON {
  11682. interface ThinEngine {
  11683. /**
  11684. * Creates a new render target cube texture
  11685. * @param size defines the size of the texture
  11686. * @param options defines the options used to create the texture
  11687. * @returns a new render target cube texture stored in an InternalTexture
  11688. */
  11689. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11690. }
  11691. }
  11692. declare module BABYLON {
  11693. /** @hidden */
  11694. export var proceduralVertexShader: {
  11695. name: string;
  11696. shader: string;
  11697. };
  11698. }
  11699. declare module BABYLON {
  11700. /**
  11701. * 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.
  11702. * This is the base class of any Procedural texture and contains most of the shareable code.
  11703. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11704. */
  11705. export class ProceduralTexture extends Texture {
  11706. /**
  11707. * Define if the texture is enabled or not (disabled texture will not render)
  11708. */
  11709. isEnabled: boolean;
  11710. /**
  11711. * Define if the texture must be cleared before rendering (default is true)
  11712. */
  11713. autoClear: boolean;
  11714. /**
  11715. * Callback called when the texture is generated
  11716. */
  11717. onGenerated: () => void;
  11718. /**
  11719. * Event raised when the texture is generated
  11720. */
  11721. onGeneratedObservable: Observable<ProceduralTexture>;
  11722. /** @hidden */
  11723. _generateMipMaps: boolean;
  11724. /** @hidden **/
  11725. _effect: Effect;
  11726. /** @hidden */
  11727. _textures: {
  11728. [key: string]: Texture;
  11729. };
  11730. /** @hidden */
  11731. protected _fallbackTexture: Nullable<Texture>;
  11732. private _size;
  11733. private _currentRefreshId;
  11734. private _frameId;
  11735. private _refreshRate;
  11736. private _vertexBuffers;
  11737. private _indexBuffer;
  11738. private _uniforms;
  11739. private _samplers;
  11740. private _fragment;
  11741. private _floats;
  11742. private _ints;
  11743. private _floatsArrays;
  11744. private _colors3;
  11745. private _colors4;
  11746. private _vectors2;
  11747. private _vectors3;
  11748. private _matrices;
  11749. private _fallbackTextureUsed;
  11750. private _fullEngine;
  11751. private _cachedDefines;
  11752. private _contentUpdateId;
  11753. private _contentData;
  11754. /**
  11755. * Instantiates a new procedural texture.
  11756. * 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.
  11757. * This is the base class of any Procedural texture and contains most of the shareable code.
  11758. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11759. * @param name Define the name of the texture
  11760. * @param size Define the size of the texture to create
  11761. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11762. * @param scene Define the scene the texture belongs to
  11763. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11764. * @param generateMipMaps Define if the texture should creates mip maps or not
  11765. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11766. */
  11767. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11768. /**
  11769. * The effect that is created when initializing the post process.
  11770. * @returns The created effect corresponding the the postprocess.
  11771. */
  11772. getEffect(): Effect;
  11773. /**
  11774. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11775. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11776. */
  11777. getContent(): Nullable<ArrayBufferView>;
  11778. private _createIndexBuffer;
  11779. /** @hidden */
  11780. _rebuild(): void;
  11781. /**
  11782. * Resets the texture in order to recreate its associated resources.
  11783. * This can be called in case of context loss
  11784. */
  11785. reset(): void;
  11786. protected _getDefines(): string;
  11787. /**
  11788. * Is the texture ready to be used ? (rendered at least once)
  11789. * @returns true if ready, otherwise, false.
  11790. */
  11791. isReady(): boolean;
  11792. /**
  11793. * Resets the refresh counter of the texture and start bak from scratch.
  11794. * Could be useful to regenerate the texture if it is setup to render only once.
  11795. */
  11796. resetRefreshCounter(): void;
  11797. /**
  11798. * Set the fragment shader to use in order to render the texture.
  11799. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11800. */
  11801. setFragment(fragment: any): void;
  11802. /**
  11803. * Define the refresh rate of the texture or the rendering frequency.
  11804. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11805. */
  11806. get refreshRate(): number;
  11807. set refreshRate(value: number);
  11808. /** @hidden */
  11809. _shouldRender(): boolean;
  11810. /**
  11811. * Get the size the texture is rendering at.
  11812. * @returns the size (texture is always squared)
  11813. */
  11814. getRenderSize(): number;
  11815. /**
  11816. * Resize the texture to new value.
  11817. * @param size Define the new size the texture should have
  11818. * @param generateMipMaps Define whether the new texture should create mip maps
  11819. */
  11820. resize(size: number, generateMipMaps: boolean): void;
  11821. private _checkUniform;
  11822. /**
  11823. * Set a texture in the shader program used to render.
  11824. * @param name Define the name of the uniform samplers as defined in the shader
  11825. * @param texture Define the texture to bind to this sampler
  11826. * @return the texture itself allowing "fluent" like uniform updates
  11827. */
  11828. setTexture(name: string, texture: Texture): ProceduralTexture;
  11829. /**
  11830. * Set a float in the shader.
  11831. * @param name Define the name of the uniform as defined in the shader
  11832. * @param value Define the value to give to the uniform
  11833. * @return the texture itself allowing "fluent" like uniform updates
  11834. */
  11835. setFloat(name: string, value: number): ProceduralTexture;
  11836. /**
  11837. * Set a int in the shader.
  11838. * @param name Define the name of the uniform as defined in the shader
  11839. * @param value Define the value to give to the uniform
  11840. * @return the texture itself allowing "fluent" like uniform updates
  11841. */
  11842. setInt(name: string, value: number): ProceduralTexture;
  11843. /**
  11844. * Set an array of floats in the shader.
  11845. * @param name Define the name of the uniform as defined in the shader
  11846. * @param value Define the value to give to the uniform
  11847. * @return the texture itself allowing "fluent" like uniform updates
  11848. */
  11849. setFloats(name: string, value: number[]): ProceduralTexture;
  11850. /**
  11851. * Set a vec3 in the shader from a Color3.
  11852. * @param name Define the name of the uniform as defined in the shader
  11853. * @param value Define the value to give to the uniform
  11854. * @return the texture itself allowing "fluent" like uniform updates
  11855. */
  11856. setColor3(name: string, value: Color3): ProceduralTexture;
  11857. /**
  11858. * Set a vec4 in the shader from a Color4.
  11859. * @param name Define the name of the uniform as defined in the shader
  11860. * @param value Define the value to give to the uniform
  11861. * @return the texture itself allowing "fluent" like uniform updates
  11862. */
  11863. setColor4(name: string, value: Color4): ProceduralTexture;
  11864. /**
  11865. * Set a vec2 in the shader from a Vector2.
  11866. * @param name Define the name of the uniform as defined in the shader
  11867. * @param value Define the value to give to the uniform
  11868. * @return the texture itself allowing "fluent" like uniform updates
  11869. */
  11870. setVector2(name: string, value: Vector2): ProceduralTexture;
  11871. /**
  11872. * Set a vec3 in the shader from a Vector3.
  11873. * @param name Define the name of the uniform as defined in the shader
  11874. * @param value Define the value to give to the uniform
  11875. * @return the texture itself allowing "fluent" like uniform updates
  11876. */
  11877. setVector3(name: string, value: Vector3): ProceduralTexture;
  11878. /**
  11879. * Set a mat4 in the shader from a MAtrix.
  11880. * @param name Define the name of the uniform as defined in the shader
  11881. * @param value Define the value to give to the uniform
  11882. * @return the texture itself allowing "fluent" like uniform updates
  11883. */
  11884. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11885. /**
  11886. * Render the texture to its associated render target.
  11887. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11888. */
  11889. render(useCameraPostProcess?: boolean): void;
  11890. /**
  11891. * Clone the texture.
  11892. * @returns the cloned texture
  11893. */
  11894. clone(): ProceduralTexture;
  11895. /**
  11896. * Dispose the texture and release its asoociated resources.
  11897. */
  11898. dispose(): void;
  11899. }
  11900. }
  11901. declare module BABYLON {
  11902. /**
  11903. * This represents the base class for particle system in Babylon.
  11904. * 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.
  11905. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11906. * @example https://doc.babylonjs.com/babylon101/particles
  11907. */
  11908. export class BaseParticleSystem {
  11909. /**
  11910. * Source color is added to the destination color without alpha affecting the result
  11911. */
  11912. static BLENDMODE_ONEONE: number;
  11913. /**
  11914. * Blend current color and particle color using particle’s alpha
  11915. */
  11916. static BLENDMODE_STANDARD: number;
  11917. /**
  11918. * Add current color and particle color multiplied by particle’s alpha
  11919. */
  11920. static BLENDMODE_ADD: number;
  11921. /**
  11922. * Multiply current color with particle color
  11923. */
  11924. static BLENDMODE_MULTIPLY: number;
  11925. /**
  11926. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11927. */
  11928. static BLENDMODE_MULTIPLYADD: number;
  11929. /**
  11930. * List of animations used by the particle system.
  11931. */
  11932. animations: Animation[];
  11933. /**
  11934. * Gets or sets the unique id of the particle system
  11935. */
  11936. uniqueId: number;
  11937. /**
  11938. * The id of the Particle system.
  11939. */
  11940. id: string;
  11941. /**
  11942. * The friendly name of the Particle system.
  11943. */
  11944. name: string;
  11945. /**
  11946. * Snippet ID if the particle system was created from the snippet server
  11947. */
  11948. snippetId: string;
  11949. /**
  11950. * The rendering group used by the Particle system to chose when to render.
  11951. */
  11952. renderingGroupId: number;
  11953. /**
  11954. * The emitter represents the Mesh or position we are attaching the particle system to.
  11955. */
  11956. emitter: Nullable<AbstractMesh | Vector3>;
  11957. /**
  11958. * The maximum number of particles to emit per frame
  11959. */
  11960. emitRate: number;
  11961. /**
  11962. * If you want to launch only a few particles at once, that can be done, as well.
  11963. */
  11964. manualEmitCount: number;
  11965. /**
  11966. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11967. */
  11968. updateSpeed: number;
  11969. /**
  11970. * The amount of time the particle system is running (depends of the overall update speed).
  11971. */
  11972. targetStopDuration: number;
  11973. /**
  11974. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11975. */
  11976. disposeOnStop: boolean;
  11977. /**
  11978. * Minimum power of emitting particles.
  11979. */
  11980. minEmitPower: number;
  11981. /**
  11982. * Maximum power of emitting particles.
  11983. */
  11984. maxEmitPower: number;
  11985. /**
  11986. * Minimum life time of emitting particles.
  11987. */
  11988. minLifeTime: number;
  11989. /**
  11990. * Maximum life time of emitting particles.
  11991. */
  11992. maxLifeTime: number;
  11993. /**
  11994. * Minimum Size of emitting particles.
  11995. */
  11996. minSize: number;
  11997. /**
  11998. * Maximum Size of emitting particles.
  11999. */
  12000. maxSize: number;
  12001. /**
  12002. * Minimum scale of emitting particles on X axis.
  12003. */
  12004. minScaleX: number;
  12005. /**
  12006. * Maximum scale of emitting particles on X axis.
  12007. */
  12008. maxScaleX: number;
  12009. /**
  12010. * Minimum scale of emitting particles on Y axis.
  12011. */
  12012. minScaleY: number;
  12013. /**
  12014. * Maximum scale of emitting particles on Y axis.
  12015. */
  12016. maxScaleY: number;
  12017. /**
  12018. * Gets or sets the minimal initial rotation in radians.
  12019. */
  12020. minInitialRotation: number;
  12021. /**
  12022. * Gets or sets the maximal initial rotation in radians.
  12023. */
  12024. maxInitialRotation: number;
  12025. /**
  12026. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12027. */
  12028. minAngularSpeed: number;
  12029. /**
  12030. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12031. */
  12032. maxAngularSpeed: number;
  12033. /**
  12034. * The texture used to render each particle. (this can be a spritesheet)
  12035. */
  12036. particleTexture: Nullable<BaseTexture>;
  12037. /**
  12038. * The layer mask we are rendering the particles through.
  12039. */
  12040. layerMask: number;
  12041. /**
  12042. * This can help using your own shader to render the particle system.
  12043. * The according effect will be created
  12044. */
  12045. customShader: any;
  12046. /**
  12047. * By default particle system starts as soon as they are created. This prevents the
  12048. * automatic start to happen and let you decide when to start emitting particles.
  12049. */
  12050. preventAutoStart: boolean;
  12051. private _noiseTexture;
  12052. /**
  12053. * Gets or sets a texture used to add random noise to particle positions
  12054. */
  12055. get noiseTexture(): Nullable<ProceduralTexture>;
  12056. set noiseTexture(value: Nullable<ProceduralTexture>);
  12057. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12058. noiseStrength: Vector3;
  12059. /**
  12060. * Callback triggered when the particle animation is ending.
  12061. */
  12062. onAnimationEnd: Nullable<() => void>;
  12063. /**
  12064. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12065. */
  12066. blendMode: number;
  12067. /**
  12068. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12069. * to override the particles.
  12070. */
  12071. forceDepthWrite: boolean;
  12072. /** 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 */
  12073. preWarmCycles: number;
  12074. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12075. preWarmStepOffset: number;
  12076. /**
  12077. * 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)
  12078. */
  12079. spriteCellChangeSpeed: number;
  12080. /**
  12081. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12082. */
  12083. startSpriteCellID: number;
  12084. /**
  12085. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12086. */
  12087. endSpriteCellID: number;
  12088. /**
  12089. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12090. */
  12091. spriteCellWidth: number;
  12092. /**
  12093. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12094. */
  12095. spriteCellHeight: number;
  12096. /**
  12097. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12098. */
  12099. spriteRandomStartCell: boolean;
  12100. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12101. translationPivot: Vector2;
  12102. /** @hidden */
  12103. protected _isAnimationSheetEnabled: boolean;
  12104. /**
  12105. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12106. */
  12107. beginAnimationOnStart: boolean;
  12108. /**
  12109. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12110. */
  12111. beginAnimationFrom: number;
  12112. /**
  12113. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12114. */
  12115. beginAnimationTo: number;
  12116. /**
  12117. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12118. */
  12119. beginAnimationLoop: boolean;
  12120. /**
  12121. * Gets or sets a world offset applied to all particles
  12122. */
  12123. worldOffset: Vector3;
  12124. /**
  12125. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12126. */
  12127. get isAnimationSheetEnabled(): boolean;
  12128. set isAnimationSheetEnabled(value: boolean);
  12129. /**
  12130. * Get hosting scene
  12131. * @returns the scene
  12132. */
  12133. getScene(): Nullable<Scene>;
  12134. /**
  12135. * You can use gravity if you want to give an orientation to your particles.
  12136. */
  12137. gravity: Vector3;
  12138. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12139. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12140. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12141. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12142. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12143. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12144. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12145. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12146. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12147. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12148. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12149. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12150. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12151. /**
  12152. * Defines the delay in milliseconds before starting the system (0 by default)
  12153. */
  12154. startDelay: number;
  12155. /**
  12156. * Gets the current list of drag gradients.
  12157. * You must use addDragGradient and removeDragGradient to udpate this list
  12158. * @returns the list of drag gradients
  12159. */
  12160. getDragGradients(): Nullable<Array<FactorGradient>>;
  12161. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12162. limitVelocityDamping: number;
  12163. /**
  12164. * Gets the current list of limit velocity gradients.
  12165. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12166. * @returns the list of limit velocity gradients
  12167. */
  12168. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12169. /**
  12170. * Gets the current list of color gradients.
  12171. * You must use addColorGradient and removeColorGradient to udpate this list
  12172. * @returns the list of color gradients
  12173. */
  12174. getColorGradients(): Nullable<Array<ColorGradient>>;
  12175. /**
  12176. * Gets the current list of size gradients.
  12177. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12178. * @returns the list of size gradients
  12179. */
  12180. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12181. /**
  12182. * Gets the current list of color remap gradients.
  12183. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12184. * @returns the list of color remap gradients
  12185. */
  12186. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12187. /**
  12188. * Gets the current list of alpha remap gradients.
  12189. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12190. * @returns the list of alpha remap gradients
  12191. */
  12192. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12193. /**
  12194. * Gets the current list of life time gradients.
  12195. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12196. * @returns the list of life time gradients
  12197. */
  12198. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12199. /**
  12200. * Gets the current list of angular speed gradients.
  12201. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12202. * @returns the list of angular speed gradients
  12203. */
  12204. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12205. /**
  12206. * Gets the current list of velocity gradients.
  12207. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12208. * @returns the list of velocity gradients
  12209. */
  12210. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12211. /**
  12212. * Gets the current list of start size gradients.
  12213. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12214. * @returns the list of start size gradients
  12215. */
  12216. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12217. /**
  12218. * Gets the current list of emit rate gradients.
  12219. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12220. * @returns the list of emit rate gradients
  12221. */
  12222. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12223. /**
  12224. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12225. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12226. */
  12227. get direction1(): Vector3;
  12228. set direction1(value: Vector3);
  12229. /**
  12230. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12231. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12232. */
  12233. get direction2(): Vector3;
  12234. set direction2(value: Vector3);
  12235. /**
  12236. * 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.
  12237. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12238. */
  12239. get minEmitBox(): Vector3;
  12240. set minEmitBox(value: Vector3);
  12241. /**
  12242. * 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.
  12243. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12244. */
  12245. get maxEmitBox(): Vector3;
  12246. set maxEmitBox(value: Vector3);
  12247. /**
  12248. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12249. */
  12250. color1: Color4;
  12251. /**
  12252. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12253. */
  12254. color2: Color4;
  12255. /**
  12256. * Color the particle will have at the end of its lifetime
  12257. */
  12258. colorDead: Color4;
  12259. /**
  12260. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12261. */
  12262. textureMask: Color4;
  12263. /**
  12264. * The particle emitter type defines the emitter used by the particle system.
  12265. * It can be for example box, sphere, or cone...
  12266. */
  12267. particleEmitterType: IParticleEmitterType;
  12268. /** @hidden */
  12269. _isSubEmitter: boolean;
  12270. /**
  12271. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12272. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12273. */
  12274. billboardMode: number;
  12275. protected _isBillboardBased: boolean;
  12276. /**
  12277. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12278. */
  12279. get isBillboardBased(): boolean;
  12280. set isBillboardBased(value: boolean);
  12281. /**
  12282. * The scene the particle system belongs to.
  12283. */
  12284. protected _scene: Nullable<Scene>;
  12285. /**
  12286. * The engine the particle system belongs to.
  12287. */
  12288. protected _engine: ThinEngine;
  12289. /**
  12290. * Local cache of defines for image processing.
  12291. */
  12292. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12293. /**
  12294. * Default configuration related to image processing available in the standard Material.
  12295. */
  12296. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12297. /**
  12298. * Gets the image processing configuration used either in this material.
  12299. */
  12300. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12301. /**
  12302. * Sets the Default image processing configuration used either in the this material.
  12303. *
  12304. * If sets to null, the scene one is in use.
  12305. */
  12306. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12307. /**
  12308. * Attaches a new image processing configuration to the Standard Material.
  12309. * @param configuration
  12310. */
  12311. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12312. /** @hidden */
  12313. protected _reset(): void;
  12314. /** @hidden */
  12315. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12316. /**
  12317. * Instantiates a particle system.
  12318. * 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.
  12319. * @param name The name of the particle system
  12320. */
  12321. constructor(name: string);
  12322. /**
  12323. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12324. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12325. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12326. * @returns the emitter
  12327. */
  12328. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12329. /**
  12330. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12331. * @param radius The radius of the hemisphere to emit from
  12332. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12333. * @returns the emitter
  12334. */
  12335. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12336. /**
  12337. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12338. * @param radius The radius of the sphere to emit from
  12339. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12340. * @returns the emitter
  12341. */
  12342. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12343. /**
  12344. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12345. * @param radius The radius of the sphere to emit from
  12346. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12347. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12348. * @returns the emitter
  12349. */
  12350. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12351. /**
  12352. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12353. * @param radius The radius of the emission cylinder
  12354. * @param height The height of the emission cylinder
  12355. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12356. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12357. * @returns the emitter
  12358. */
  12359. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12360. /**
  12361. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12362. * @param radius The radius of the cylinder to emit from
  12363. * @param height The height of the emission cylinder
  12364. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12365. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12366. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12367. * @returns the emitter
  12368. */
  12369. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12370. /**
  12371. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12372. * @param radius The radius of the cone to emit from
  12373. * @param angle The base angle of the cone
  12374. * @returns the emitter
  12375. */
  12376. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12377. /**
  12378. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12379. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12380. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12381. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12382. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12383. * @returns the emitter
  12384. */
  12385. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12386. }
  12387. }
  12388. declare module BABYLON {
  12389. /**
  12390. * Type of sub emitter
  12391. */
  12392. export enum SubEmitterType {
  12393. /**
  12394. * Attached to the particle over it's lifetime
  12395. */
  12396. ATTACHED = 0,
  12397. /**
  12398. * Created when the particle dies
  12399. */
  12400. END = 1
  12401. }
  12402. /**
  12403. * Sub emitter class used to emit particles from an existing particle
  12404. */
  12405. export class SubEmitter {
  12406. /**
  12407. * the particle system to be used by the sub emitter
  12408. */
  12409. particleSystem: ParticleSystem;
  12410. /**
  12411. * Type of the submitter (Default: END)
  12412. */
  12413. type: SubEmitterType;
  12414. /**
  12415. * 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)
  12416. * Note: This only is supported when using an emitter of type Mesh
  12417. */
  12418. inheritDirection: boolean;
  12419. /**
  12420. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12421. */
  12422. inheritedVelocityAmount: number;
  12423. /**
  12424. * Creates a sub emitter
  12425. * @param particleSystem the particle system to be used by the sub emitter
  12426. */
  12427. constructor(
  12428. /**
  12429. * the particle system to be used by the sub emitter
  12430. */
  12431. particleSystem: ParticleSystem);
  12432. /**
  12433. * Clones the sub emitter
  12434. * @returns the cloned sub emitter
  12435. */
  12436. clone(): SubEmitter;
  12437. /**
  12438. * Serialize current object to a JSON object
  12439. * @returns the serialized object
  12440. */
  12441. serialize(): any;
  12442. /** @hidden */
  12443. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12444. /**
  12445. * Creates a new SubEmitter from a serialized JSON version
  12446. * @param serializationObject defines the JSON object to read from
  12447. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12448. * @param rootUrl defines the rootUrl for data loading
  12449. * @returns a new SubEmitter
  12450. */
  12451. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12452. /** Release associated resources */
  12453. dispose(): void;
  12454. }
  12455. }
  12456. declare module BABYLON {
  12457. /** @hidden */
  12458. export var imageProcessingDeclaration: {
  12459. name: string;
  12460. shader: string;
  12461. };
  12462. }
  12463. declare module BABYLON {
  12464. /** @hidden */
  12465. export var imageProcessingFunctions: {
  12466. name: string;
  12467. shader: string;
  12468. };
  12469. }
  12470. declare module BABYLON {
  12471. /** @hidden */
  12472. export var particlesPixelShader: {
  12473. name: string;
  12474. shader: string;
  12475. };
  12476. }
  12477. declare module BABYLON {
  12478. /** @hidden */
  12479. export var particlesVertexShader: {
  12480. name: string;
  12481. shader: string;
  12482. };
  12483. }
  12484. declare module BABYLON {
  12485. /**
  12486. * Interface used to define entities containing multiple clip planes
  12487. */
  12488. export interface IClipPlanesHolder {
  12489. /**
  12490. * Gets or sets the active clipplane 1
  12491. */
  12492. clipPlane: Nullable<Plane>;
  12493. /**
  12494. * Gets or sets the active clipplane 2
  12495. */
  12496. clipPlane2: Nullable<Plane>;
  12497. /**
  12498. * Gets or sets the active clipplane 3
  12499. */
  12500. clipPlane3: Nullable<Plane>;
  12501. /**
  12502. * Gets or sets the active clipplane 4
  12503. */
  12504. clipPlane4: Nullable<Plane>;
  12505. /**
  12506. * Gets or sets the active clipplane 5
  12507. */
  12508. clipPlane5: Nullable<Plane>;
  12509. /**
  12510. * Gets or sets the active clipplane 6
  12511. */
  12512. clipPlane6: Nullable<Plane>;
  12513. }
  12514. }
  12515. declare module BABYLON {
  12516. /**
  12517. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12518. *
  12519. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12520. *
  12521. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12522. */
  12523. export class ThinMaterialHelper {
  12524. /**
  12525. * Binds the clip plane information from the holder to the effect.
  12526. * @param effect The effect we are binding the data to
  12527. * @param holder The entity containing the clip plane information
  12528. */
  12529. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12530. }
  12531. }
  12532. declare module BABYLON {
  12533. interface ThinEngine {
  12534. /**
  12535. * Sets alpha constants used by some alpha blending modes
  12536. * @param r defines the red component
  12537. * @param g defines the green component
  12538. * @param b defines the blue component
  12539. * @param a defines the alpha component
  12540. */
  12541. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12542. /**
  12543. * Sets the current alpha mode
  12544. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12545. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12546. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12547. */
  12548. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12549. /**
  12550. * Gets the current alpha mode
  12551. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12552. * @returns the current alpha mode
  12553. */
  12554. getAlphaMode(): number;
  12555. /**
  12556. * Sets the current alpha equation
  12557. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12558. */
  12559. setAlphaEquation(equation: number): void;
  12560. /**
  12561. * Gets the current alpha equation.
  12562. * @returns the current alpha equation
  12563. */
  12564. getAlphaEquation(): number;
  12565. }
  12566. }
  12567. declare module BABYLON {
  12568. /**
  12569. * This represents a particle system in Babylon.
  12570. * 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.
  12571. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12572. * @example https://doc.babylonjs.com/babylon101/particles
  12573. */
  12574. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12575. /**
  12576. * Billboard mode will only apply to Y axis
  12577. */
  12578. static readonly BILLBOARDMODE_Y: number;
  12579. /**
  12580. * Billboard mode will apply to all axes
  12581. */
  12582. static readonly BILLBOARDMODE_ALL: number;
  12583. /**
  12584. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12585. */
  12586. static readonly BILLBOARDMODE_STRETCHED: number;
  12587. /**
  12588. * This function can be defined to provide custom update for active particles.
  12589. * This function will be called instead of regular update (age, position, color, etc.).
  12590. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12591. */
  12592. updateFunction: (particles: Particle[]) => void;
  12593. private _emitterWorldMatrix;
  12594. /**
  12595. * This function can be defined to specify initial direction for every new particle.
  12596. * It by default use the emitterType defined function
  12597. */
  12598. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12599. /**
  12600. * This function can be defined to specify initial position for every new particle.
  12601. * It by default use the emitterType defined function
  12602. */
  12603. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12604. /**
  12605. * @hidden
  12606. */
  12607. _inheritedVelocityOffset: Vector3;
  12608. /**
  12609. * An event triggered when the system is disposed
  12610. */
  12611. onDisposeObservable: Observable<IParticleSystem>;
  12612. private _onDisposeObserver;
  12613. /**
  12614. * Sets a callback that will be triggered when the system is disposed
  12615. */
  12616. set onDispose(callback: () => void);
  12617. private _particles;
  12618. private _epsilon;
  12619. private _capacity;
  12620. private _stockParticles;
  12621. private _newPartsExcess;
  12622. private _vertexData;
  12623. private _vertexBuffer;
  12624. private _vertexBuffers;
  12625. private _spriteBuffer;
  12626. private _indexBuffer;
  12627. private _effect;
  12628. private _customEffect;
  12629. private _cachedDefines;
  12630. private _scaledColorStep;
  12631. private _colorDiff;
  12632. private _scaledDirection;
  12633. private _scaledGravity;
  12634. private _currentRenderId;
  12635. private _alive;
  12636. private _useInstancing;
  12637. private _started;
  12638. private _stopped;
  12639. private _actualFrame;
  12640. private _scaledUpdateSpeed;
  12641. private _vertexBufferSize;
  12642. /** @hidden */
  12643. _currentEmitRateGradient: Nullable<FactorGradient>;
  12644. /** @hidden */
  12645. _currentEmitRate1: number;
  12646. /** @hidden */
  12647. _currentEmitRate2: number;
  12648. /** @hidden */
  12649. _currentStartSizeGradient: Nullable<FactorGradient>;
  12650. /** @hidden */
  12651. _currentStartSize1: number;
  12652. /** @hidden */
  12653. _currentStartSize2: number;
  12654. private readonly _rawTextureWidth;
  12655. private _rampGradientsTexture;
  12656. private _useRampGradients;
  12657. /** Gets or sets a matrix to use to compute projection */
  12658. defaultProjectionMatrix: Matrix;
  12659. /** Gets or sets a matrix to use to compute view */
  12660. defaultViewMatrix: Matrix;
  12661. /** Gets or sets a boolean indicating that ramp gradients must be used
  12662. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12663. */
  12664. get useRampGradients(): boolean;
  12665. set useRampGradients(value: boolean);
  12666. /**
  12667. * 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.
  12668. * 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: [])
  12669. */
  12670. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12671. private _subEmitters;
  12672. /**
  12673. * @hidden
  12674. * If the particle systems emitter should be disposed when the particle system is disposed
  12675. */
  12676. _disposeEmitterOnDispose: boolean;
  12677. /**
  12678. * The current active Sub-systems, this property is used by the root particle system only.
  12679. */
  12680. activeSubSystems: Array<ParticleSystem>;
  12681. /**
  12682. * Specifies if the particles are updated in emitter local space or world space
  12683. */
  12684. isLocal: boolean;
  12685. private _rootParticleSystem;
  12686. /**
  12687. * Gets the current list of active particles
  12688. */
  12689. get particles(): Particle[];
  12690. /**
  12691. * Gets the number of particles active at the same time.
  12692. * @returns The number of active particles.
  12693. */
  12694. getActiveCount(): number;
  12695. /**
  12696. * Returns the string "ParticleSystem"
  12697. * @returns a string containing the class name
  12698. */
  12699. getClassName(): string;
  12700. /**
  12701. * Gets a boolean indicating that the system is stopping
  12702. * @returns true if the system is currently stopping
  12703. */
  12704. isStopping(): boolean;
  12705. /**
  12706. * Gets the custom effect used to render the particles
  12707. * @param blendMode Blend mode for which the effect should be retrieved
  12708. * @returns The effect
  12709. */
  12710. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12711. /**
  12712. * Sets the custom effect used to render the particles
  12713. * @param effect The effect to set
  12714. * @param blendMode Blend mode for which the effect should be set
  12715. */
  12716. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12717. /** @hidden */
  12718. private _onBeforeDrawParticlesObservable;
  12719. /**
  12720. * Observable that will be called just before the particles are drawn
  12721. */
  12722. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12723. /**
  12724. * Gets the name of the particle vertex shader
  12725. */
  12726. get vertexShaderName(): string;
  12727. /**
  12728. * Instantiates a particle system.
  12729. * 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.
  12730. * @param name The name of the particle system
  12731. * @param capacity The max number of particles alive at the same time
  12732. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12733. * @param customEffect a custom effect used to change the way particles are rendered by default
  12734. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12735. * @param epsilon Offset used to render the particles
  12736. */
  12737. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12738. private _addFactorGradient;
  12739. private _removeFactorGradient;
  12740. /**
  12741. * Adds a new life time gradient
  12742. * @param gradient defines the gradient to use (between 0 and 1)
  12743. * @param factor defines the life time factor to affect to the specified gradient
  12744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12745. * @returns the current particle system
  12746. */
  12747. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12748. /**
  12749. * Remove a specific life time gradient
  12750. * @param gradient defines the gradient to remove
  12751. * @returns the current particle system
  12752. */
  12753. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12754. /**
  12755. * Adds a new size gradient
  12756. * @param gradient defines the gradient to use (between 0 and 1)
  12757. * @param factor defines the size factor to affect to the specified gradient
  12758. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12759. * @returns the current particle system
  12760. */
  12761. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12762. /**
  12763. * Remove a specific size gradient
  12764. * @param gradient defines the gradient to remove
  12765. * @returns the current particle system
  12766. */
  12767. removeSizeGradient(gradient: number): IParticleSystem;
  12768. /**
  12769. * Adds a new color remap gradient
  12770. * @param gradient defines the gradient to use (between 0 and 1)
  12771. * @param min defines the color remap minimal range
  12772. * @param max defines the color remap maximal range
  12773. * @returns the current particle system
  12774. */
  12775. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12776. /**
  12777. * Remove a specific color remap gradient
  12778. * @param gradient defines the gradient to remove
  12779. * @returns the current particle system
  12780. */
  12781. removeColorRemapGradient(gradient: number): IParticleSystem;
  12782. /**
  12783. * Adds a new alpha remap gradient
  12784. * @param gradient defines the gradient to use (between 0 and 1)
  12785. * @param min defines the alpha remap minimal range
  12786. * @param max defines the alpha remap maximal range
  12787. * @returns the current particle system
  12788. */
  12789. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12790. /**
  12791. * Remove a specific alpha remap gradient
  12792. * @param gradient defines the gradient to remove
  12793. * @returns the current particle system
  12794. */
  12795. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12796. /**
  12797. * Adds a new angular speed gradient
  12798. * @param gradient defines the gradient to use (between 0 and 1)
  12799. * @param factor defines the angular speed to affect to the specified gradient
  12800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12801. * @returns the current particle system
  12802. */
  12803. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12804. /**
  12805. * Remove a specific angular speed gradient
  12806. * @param gradient defines the gradient to remove
  12807. * @returns the current particle system
  12808. */
  12809. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12810. /**
  12811. * Adds a new velocity gradient
  12812. * @param gradient defines the gradient to use (between 0 and 1)
  12813. * @param factor defines the velocity to affect to the specified gradient
  12814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12815. * @returns the current particle system
  12816. */
  12817. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12818. /**
  12819. * Remove a specific velocity gradient
  12820. * @param gradient defines the gradient to remove
  12821. * @returns the current particle system
  12822. */
  12823. removeVelocityGradient(gradient: number): IParticleSystem;
  12824. /**
  12825. * Adds a new limit velocity gradient
  12826. * @param gradient defines the gradient to use (between 0 and 1)
  12827. * @param factor defines the limit velocity value to affect to the specified gradient
  12828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12829. * @returns the current particle system
  12830. */
  12831. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12832. /**
  12833. * Remove a specific limit velocity gradient
  12834. * @param gradient defines the gradient to remove
  12835. * @returns the current particle system
  12836. */
  12837. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12838. /**
  12839. * Adds a new drag gradient
  12840. * @param gradient defines the gradient to use (between 0 and 1)
  12841. * @param factor defines the drag value to affect to the specified gradient
  12842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12843. * @returns the current particle system
  12844. */
  12845. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12846. /**
  12847. * Remove a specific drag gradient
  12848. * @param gradient defines the gradient to remove
  12849. * @returns the current particle system
  12850. */
  12851. removeDragGradient(gradient: number): IParticleSystem;
  12852. /**
  12853. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12854. * @param gradient defines the gradient to use (between 0 and 1)
  12855. * @param factor defines the emit rate value to affect to the specified gradient
  12856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12857. * @returns the current particle system
  12858. */
  12859. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12860. /**
  12861. * Remove a specific emit rate gradient
  12862. * @param gradient defines the gradient to remove
  12863. * @returns the current particle system
  12864. */
  12865. removeEmitRateGradient(gradient: number): IParticleSystem;
  12866. /**
  12867. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12868. * @param gradient defines the gradient to use (between 0 and 1)
  12869. * @param factor defines the start size value to affect to the specified gradient
  12870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12871. * @returns the current particle system
  12872. */
  12873. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12874. /**
  12875. * Remove a specific start size gradient
  12876. * @param gradient defines the gradient to remove
  12877. * @returns the current particle system
  12878. */
  12879. removeStartSizeGradient(gradient: number): IParticleSystem;
  12880. private _createRampGradientTexture;
  12881. /**
  12882. * Gets the current list of ramp gradients.
  12883. * You must use addRampGradient and removeRampGradient to udpate this list
  12884. * @returns the list of ramp gradients
  12885. */
  12886. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12887. /** Force the system to rebuild all gradients that need to be resync */
  12888. forceRefreshGradients(): void;
  12889. private _syncRampGradientTexture;
  12890. /**
  12891. * Adds a new ramp gradient used to remap particle colors
  12892. * @param gradient defines the gradient to use (between 0 and 1)
  12893. * @param color defines the color to affect to the specified gradient
  12894. * @returns the current particle system
  12895. */
  12896. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12897. /**
  12898. * Remove a specific ramp gradient
  12899. * @param gradient defines the gradient to remove
  12900. * @returns the current particle system
  12901. */
  12902. removeRampGradient(gradient: number): ParticleSystem;
  12903. /**
  12904. * Adds a new color gradient
  12905. * @param gradient defines the gradient to use (between 0 and 1)
  12906. * @param color1 defines the color to affect to the specified gradient
  12907. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12908. * @returns this particle system
  12909. */
  12910. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12911. /**
  12912. * Remove a specific color gradient
  12913. * @param gradient defines the gradient to remove
  12914. * @returns this particle system
  12915. */
  12916. removeColorGradient(gradient: number): IParticleSystem;
  12917. private _fetchR;
  12918. protected _reset(): void;
  12919. private _resetEffect;
  12920. private _createVertexBuffers;
  12921. private _createIndexBuffer;
  12922. /**
  12923. * Gets the maximum number of particles active at the same time.
  12924. * @returns The max number of active particles.
  12925. */
  12926. getCapacity(): number;
  12927. /**
  12928. * Gets whether there are still active particles in the system.
  12929. * @returns True if it is alive, otherwise false.
  12930. */
  12931. isAlive(): boolean;
  12932. /**
  12933. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12934. * @returns True if it has been started, otherwise false.
  12935. */
  12936. isStarted(): boolean;
  12937. private _prepareSubEmitterInternalArray;
  12938. /**
  12939. * Starts the particle system and begins to emit
  12940. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12941. */
  12942. start(delay?: number): void;
  12943. /**
  12944. * Stops the particle system.
  12945. * @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.
  12946. */
  12947. stop(stopSubEmitters?: boolean): void;
  12948. /**
  12949. * Remove all active particles
  12950. */
  12951. reset(): void;
  12952. /**
  12953. * @hidden (for internal use only)
  12954. */
  12955. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12956. /**
  12957. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12958. * Its lifetime will start back at 0.
  12959. */
  12960. recycleParticle: (particle: Particle) => void;
  12961. private _stopSubEmitters;
  12962. private _createParticle;
  12963. private _removeFromRoot;
  12964. private _emitFromParticle;
  12965. private _update;
  12966. /** @hidden */
  12967. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12968. /** @hidden */
  12969. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12970. /**
  12971. * Fill the defines array according to the current settings of the particle system
  12972. * @param defines Array to be updated
  12973. * @param blendMode blend mode to take into account when updating the array
  12974. */
  12975. fillDefines(defines: Array<string>, blendMode: number): void;
  12976. /**
  12977. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12978. * @param uniforms Uniforms array to fill
  12979. * @param attributes Attributes array to fill
  12980. * @param samplers Samplers array to fill
  12981. */
  12982. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12983. /** @hidden */
  12984. private _getEffect;
  12985. /**
  12986. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12987. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12988. */
  12989. animate(preWarmOnly?: boolean): void;
  12990. private _appendParticleVertices;
  12991. /**
  12992. * Rebuilds the particle system.
  12993. */
  12994. rebuild(): void;
  12995. /**
  12996. * Is this system ready to be used/rendered
  12997. * @return true if the system is ready
  12998. */
  12999. isReady(): boolean;
  13000. private _render;
  13001. /**
  13002. * Renders the particle system in its current state.
  13003. * @returns the current number of particles
  13004. */
  13005. render(): number;
  13006. /**
  13007. * Disposes the particle system and free the associated resources
  13008. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13009. */
  13010. dispose(disposeTexture?: boolean): void;
  13011. /**
  13012. * Clones the particle system.
  13013. * @param name The name of the cloned object
  13014. * @param newEmitter The new emitter to use
  13015. * @returns the cloned particle system
  13016. */
  13017. clone(name: string, newEmitter: any): ParticleSystem;
  13018. /**
  13019. * Serializes the particle system to a JSON object
  13020. * @param serializeTexture defines if the texture must be serialized as well
  13021. * @returns the JSON object
  13022. */
  13023. serialize(serializeTexture?: boolean): any;
  13024. /** @hidden */
  13025. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13026. /** @hidden */
  13027. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13028. /**
  13029. * Parses a JSON object to create a particle system.
  13030. * @param parsedParticleSystem The JSON object to parse
  13031. * @param sceneOrEngine The scene or the engine to create the particle system in
  13032. * @param rootUrl The root url to use to load external dependencies like texture
  13033. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13034. * @returns the Parsed particle system
  13035. */
  13036. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13037. }
  13038. }
  13039. declare module BABYLON {
  13040. /**
  13041. * A particle represents one of the element emitted by a particle system.
  13042. * This is mainly define by its coordinates, direction, velocity and age.
  13043. */
  13044. export class Particle {
  13045. /**
  13046. * The particle system the particle belongs to.
  13047. */
  13048. particleSystem: ParticleSystem;
  13049. private static _Count;
  13050. /**
  13051. * Unique ID of the particle
  13052. */
  13053. id: number;
  13054. /**
  13055. * The world position of the particle in the scene.
  13056. */
  13057. position: Vector3;
  13058. /**
  13059. * The world direction of the particle in the scene.
  13060. */
  13061. direction: Vector3;
  13062. /**
  13063. * The color of the particle.
  13064. */
  13065. color: Color4;
  13066. /**
  13067. * The color change of the particle per step.
  13068. */
  13069. colorStep: Color4;
  13070. /**
  13071. * Defines how long will the life of the particle be.
  13072. */
  13073. lifeTime: number;
  13074. /**
  13075. * The current age of the particle.
  13076. */
  13077. age: number;
  13078. /**
  13079. * The current size of the particle.
  13080. */
  13081. size: number;
  13082. /**
  13083. * The current scale of the particle.
  13084. */
  13085. scale: Vector2;
  13086. /**
  13087. * The current angle of the particle.
  13088. */
  13089. angle: number;
  13090. /**
  13091. * Defines how fast is the angle changing.
  13092. */
  13093. angularSpeed: number;
  13094. /**
  13095. * Defines the cell index used by the particle to be rendered from a sprite.
  13096. */
  13097. cellIndex: number;
  13098. /**
  13099. * The information required to support color remapping
  13100. */
  13101. remapData: Vector4;
  13102. /** @hidden */
  13103. _randomCellOffset?: number;
  13104. /** @hidden */
  13105. _initialDirection: Nullable<Vector3>;
  13106. /** @hidden */
  13107. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13108. /** @hidden */
  13109. _initialStartSpriteCellID: number;
  13110. /** @hidden */
  13111. _initialEndSpriteCellID: number;
  13112. /** @hidden */
  13113. _currentColorGradient: Nullable<ColorGradient>;
  13114. /** @hidden */
  13115. _currentColor1: Color4;
  13116. /** @hidden */
  13117. _currentColor2: Color4;
  13118. /** @hidden */
  13119. _currentSizeGradient: Nullable<FactorGradient>;
  13120. /** @hidden */
  13121. _currentSize1: number;
  13122. /** @hidden */
  13123. _currentSize2: number;
  13124. /** @hidden */
  13125. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13126. /** @hidden */
  13127. _currentAngularSpeed1: number;
  13128. /** @hidden */
  13129. _currentAngularSpeed2: number;
  13130. /** @hidden */
  13131. _currentVelocityGradient: Nullable<FactorGradient>;
  13132. /** @hidden */
  13133. _currentVelocity1: number;
  13134. /** @hidden */
  13135. _currentVelocity2: number;
  13136. /** @hidden */
  13137. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13138. /** @hidden */
  13139. _currentLimitVelocity1: number;
  13140. /** @hidden */
  13141. _currentLimitVelocity2: number;
  13142. /** @hidden */
  13143. _currentDragGradient: Nullable<FactorGradient>;
  13144. /** @hidden */
  13145. _currentDrag1: number;
  13146. /** @hidden */
  13147. _currentDrag2: number;
  13148. /** @hidden */
  13149. _randomNoiseCoordinates1: Vector3;
  13150. /** @hidden */
  13151. _randomNoiseCoordinates2: Vector3;
  13152. /** @hidden */
  13153. _localPosition?: Vector3;
  13154. /**
  13155. * Creates a new instance Particle
  13156. * @param particleSystem the particle system the particle belongs to
  13157. */
  13158. constructor(
  13159. /**
  13160. * The particle system the particle belongs to.
  13161. */
  13162. particleSystem: ParticleSystem);
  13163. private updateCellInfoFromSystem;
  13164. /**
  13165. * Defines how the sprite cell index is updated for the particle
  13166. */
  13167. updateCellIndex(): void;
  13168. /** @hidden */
  13169. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13170. /** @hidden */
  13171. _inheritParticleInfoToSubEmitters(): void;
  13172. /** @hidden */
  13173. _reset(): void;
  13174. /**
  13175. * Copy the properties of particle to another one.
  13176. * @param other the particle to copy the information to.
  13177. */
  13178. copyTo(other: Particle): void;
  13179. }
  13180. }
  13181. declare module BABYLON {
  13182. /**
  13183. * Particle emitter represents a volume emitting particles.
  13184. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13185. */
  13186. export interface IParticleEmitterType {
  13187. /**
  13188. * Called by the particle System when the direction is computed for the created particle.
  13189. * @param worldMatrix is the world matrix of the particle system
  13190. * @param directionToUpdate is the direction vector to update with the result
  13191. * @param particle is the particle we are computed the direction for
  13192. * @param isLocal defines if the direction should be set in local space
  13193. */
  13194. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13195. /**
  13196. * Called by the particle System when the position is computed for the created particle.
  13197. * @param worldMatrix is the world matrix of the particle system
  13198. * @param positionToUpdate is the position vector to update with the result
  13199. * @param particle is the particle we are computed the position for
  13200. * @param isLocal defines if the position should be set in local space
  13201. */
  13202. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13203. /**
  13204. * Clones the current emitter and returns a copy of it
  13205. * @returns the new emitter
  13206. */
  13207. clone(): IParticleEmitterType;
  13208. /**
  13209. * Called by the GPUParticleSystem to setup the update shader
  13210. * @param effect defines the update shader
  13211. */
  13212. applyToShader(effect: Effect): void;
  13213. /**
  13214. * Returns a string to use to update the GPU particles update shader
  13215. * @returns the effect defines string
  13216. */
  13217. getEffectDefines(): string;
  13218. /**
  13219. * Returns a string representing the class name
  13220. * @returns a string containing the class name
  13221. */
  13222. getClassName(): string;
  13223. /**
  13224. * Serializes the particle system to a JSON object.
  13225. * @returns the JSON object
  13226. */
  13227. serialize(): any;
  13228. /**
  13229. * Parse properties from a JSON object
  13230. * @param serializationObject defines the JSON object
  13231. * @param scene defines the hosting scene
  13232. */
  13233. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13234. }
  13235. }
  13236. declare module BABYLON {
  13237. /**
  13238. * Particle emitter emitting particles from the inside of a box.
  13239. * It emits the particles randomly between 2 given directions.
  13240. */
  13241. export class BoxParticleEmitter implements IParticleEmitterType {
  13242. /**
  13243. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13244. */
  13245. direction1: Vector3;
  13246. /**
  13247. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13248. */
  13249. direction2: Vector3;
  13250. /**
  13251. * 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.
  13252. */
  13253. minEmitBox: Vector3;
  13254. /**
  13255. * 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.
  13256. */
  13257. maxEmitBox: Vector3;
  13258. /**
  13259. * Creates a new instance BoxParticleEmitter
  13260. */
  13261. constructor();
  13262. /**
  13263. * Called by the particle System when the direction is computed for the created particle.
  13264. * @param worldMatrix is the world matrix of the particle system
  13265. * @param directionToUpdate is the direction vector to update with the result
  13266. * @param particle is the particle we are computed the direction for
  13267. * @param isLocal defines if the direction should be set in local space
  13268. */
  13269. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13270. /**
  13271. * Called by the particle System when the position is computed for the created particle.
  13272. * @param worldMatrix is the world matrix of the particle system
  13273. * @param positionToUpdate is the position vector to update with the result
  13274. * @param particle is the particle we are computed the position for
  13275. * @param isLocal defines if the position should be set in local space
  13276. */
  13277. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13278. /**
  13279. * Clones the current emitter and returns a copy of it
  13280. * @returns the new emitter
  13281. */
  13282. clone(): BoxParticleEmitter;
  13283. /**
  13284. * Called by the GPUParticleSystem to setup the update shader
  13285. * @param effect defines the update shader
  13286. */
  13287. applyToShader(effect: Effect): void;
  13288. /**
  13289. * Returns a string to use to update the GPU particles update shader
  13290. * @returns a string containng the defines string
  13291. */
  13292. getEffectDefines(): string;
  13293. /**
  13294. * Returns the string "BoxParticleEmitter"
  13295. * @returns a string containing the class name
  13296. */
  13297. getClassName(): string;
  13298. /**
  13299. * Serializes the particle system to a JSON object.
  13300. * @returns the JSON object
  13301. */
  13302. serialize(): any;
  13303. /**
  13304. * Parse properties from a JSON object
  13305. * @param serializationObject defines the JSON object
  13306. */
  13307. parse(serializationObject: any): void;
  13308. }
  13309. }
  13310. declare module BABYLON {
  13311. /**
  13312. * Particle emitter emitting particles from the inside of a cone.
  13313. * It emits the particles alongside the cone volume from the base to the particle.
  13314. * The emission direction might be randomized.
  13315. */
  13316. export class ConeParticleEmitter implements IParticleEmitterType {
  13317. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13318. directionRandomizer: number;
  13319. private _radius;
  13320. private _angle;
  13321. private _height;
  13322. /**
  13323. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13324. */
  13325. radiusRange: number;
  13326. /**
  13327. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13328. */
  13329. heightRange: number;
  13330. /**
  13331. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13332. */
  13333. emitFromSpawnPointOnly: boolean;
  13334. /**
  13335. * Gets or sets the radius of the emission cone
  13336. */
  13337. get radius(): number;
  13338. set radius(value: number);
  13339. /**
  13340. * Gets or sets the angle of the emission cone
  13341. */
  13342. get angle(): number;
  13343. set angle(value: number);
  13344. private _buildHeight;
  13345. /**
  13346. * Creates a new instance ConeParticleEmitter
  13347. * @param radius the radius of the emission cone (1 by default)
  13348. * @param angle the cone base angle (PI by default)
  13349. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13350. */
  13351. constructor(radius?: number, angle?: number,
  13352. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13353. directionRandomizer?: number);
  13354. /**
  13355. * Called by the particle System when the direction is computed for the created particle.
  13356. * @param worldMatrix is the world matrix of the particle system
  13357. * @param directionToUpdate is the direction vector to update with the result
  13358. * @param particle is the particle we are computed the direction for
  13359. * @param isLocal defines if the direction should be set in local space
  13360. */
  13361. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13362. /**
  13363. * Called by the particle System when the position is computed for the created particle.
  13364. * @param worldMatrix is the world matrix of the particle system
  13365. * @param positionToUpdate is the position vector to update with the result
  13366. * @param particle is the particle we are computed the position for
  13367. * @param isLocal defines if the position should be set in local space
  13368. */
  13369. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13370. /**
  13371. * Clones the current emitter and returns a copy of it
  13372. * @returns the new emitter
  13373. */
  13374. clone(): ConeParticleEmitter;
  13375. /**
  13376. * Called by the GPUParticleSystem to setup the update shader
  13377. * @param effect defines the update shader
  13378. */
  13379. applyToShader(effect: Effect): void;
  13380. /**
  13381. * Returns a string to use to update the GPU particles update shader
  13382. * @returns a string containng the defines string
  13383. */
  13384. getEffectDefines(): string;
  13385. /**
  13386. * Returns the string "ConeParticleEmitter"
  13387. * @returns a string containing the class name
  13388. */
  13389. getClassName(): string;
  13390. /**
  13391. * Serializes the particle system to a JSON object.
  13392. * @returns the JSON object
  13393. */
  13394. serialize(): any;
  13395. /**
  13396. * Parse properties from a JSON object
  13397. * @param serializationObject defines the JSON object
  13398. */
  13399. parse(serializationObject: any): void;
  13400. }
  13401. }
  13402. declare module BABYLON {
  13403. /**
  13404. * Particle emitter emitting particles from the inside of a cylinder.
  13405. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13406. */
  13407. export class CylinderParticleEmitter implements IParticleEmitterType {
  13408. /**
  13409. * The radius of the emission cylinder.
  13410. */
  13411. radius: number;
  13412. /**
  13413. * The height of the emission cylinder.
  13414. */
  13415. height: number;
  13416. /**
  13417. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13418. */
  13419. radiusRange: number;
  13420. /**
  13421. * How much to randomize the particle direction [0-1].
  13422. */
  13423. directionRandomizer: number;
  13424. /**
  13425. * Creates a new instance CylinderParticleEmitter
  13426. * @param radius the radius of the emission cylinder (1 by default)
  13427. * @param height the height of the emission cylinder (1 by default)
  13428. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13429. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13430. */
  13431. constructor(
  13432. /**
  13433. * The radius of the emission cylinder.
  13434. */
  13435. radius?: number,
  13436. /**
  13437. * The height of the emission cylinder.
  13438. */
  13439. height?: number,
  13440. /**
  13441. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13442. */
  13443. radiusRange?: number,
  13444. /**
  13445. * How much to randomize the particle direction [0-1].
  13446. */
  13447. directionRandomizer?: number);
  13448. /**
  13449. * Called by the particle System when the direction is computed for the created particle.
  13450. * @param worldMatrix is the world matrix of the particle system
  13451. * @param directionToUpdate is the direction vector to update with the result
  13452. * @param particle is the particle we are computed the direction for
  13453. * @param isLocal defines if the direction should be set in local space
  13454. */
  13455. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13456. /**
  13457. * Called by the particle System when the position is computed for the created particle.
  13458. * @param worldMatrix is the world matrix of the particle system
  13459. * @param positionToUpdate is the position vector to update with the result
  13460. * @param particle is the particle we are computed the position for
  13461. * @param isLocal defines if the position should be set in local space
  13462. */
  13463. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13464. /**
  13465. * Clones the current emitter and returns a copy of it
  13466. * @returns the new emitter
  13467. */
  13468. clone(): CylinderParticleEmitter;
  13469. /**
  13470. * Called by the GPUParticleSystem to setup the update shader
  13471. * @param effect defines the update shader
  13472. */
  13473. applyToShader(effect: Effect): void;
  13474. /**
  13475. * Returns a string to use to update the GPU particles update shader
  13476. * @returns a string containng the defines string
  13477. */
  13478. getEffectDefines(): string;
  13479. /**
  13480. * Returns the string "CylinderParticleEmitter"
  13481. * @returns a string containing the class name
  13482. */
  13483. getClassName(): string;
  13484. /**
  13485. * Serializes the particle system to a JSON object.
  13486. * @returns the JSON object
  13487. */
  13488. serialize(): any;
  13489. /**
  13490. * Parse properties from a JSON object
  13491. * @param serializationObject defines the JSON object
  13492. */
  13493. parse(serializationObject: any): void;
  13494. }
  13495. /**
  13496. * Particle emitter emitting particles from the inside of a cylinder.
  13497. * It emits the particles randomly between two vectors.
  13498. */
  13499. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13500. /**
  13501. * The min limit of the emission direction.
  13502. */
  13503. direction1: Vector3;
  13504. /**
  13505. * The max limit of the emission direction.
  13506. */
  13507. direction2: Vector3;
  13508. /**
  13509. * Creates a new instance CylinderDirectedParticleEmitter
  13510. * @param radius the radius of the emission cylinder (1 by default)
  13511. * @param height the height of the emission cylinder (1 by default)
  13512. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13513. * @param direction1 the min limit of the emission direction (up vector by default)
  13514. * @param direction2 the max limit of the emission direction (up vector by default)
  13515. */
  13516. constructor(radius?: number, height?: number, radiusRange?: number,
  13517. /**
  13518. * The min limit of the emission direction.
  13519. */
  13520. direction1?: Vector3,
  13521. /**
  13522. * The max limit of the emission direction.
  13523. */
  13524. direction2?: Vector3);
  13525. /**
  13526. * Called by the particle System when the direction is computed for the created particle.
  13527. * @param worldMatrix is the world matrix of the particle system
  13528. * @param directionToUpdate is the direction vector to update with the result
  13529. * @param particle is the particle we are computed the direction for
  13530. */
  13531. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13532. /**
  13533. * Clones the current emitter and returns a copy of it
  13534. * @returns the new emitter
  13535. */
  13536. clone(): CylinderDirectedParticleEmitter;
  13537. /**
  13538. * Called by the GPUParticleSystem to setup the update shader
  13539. * @param effect defines the update shader
  13540. */
  13541. applyToShader(effect: Effect): void;
  13542. /**
  13543. * Returns a string to use to update the GPU particles update shader
  13544. * @returns a string containng the defines string
  13545. */
  13546. getEffectDefines(): string;
  13547. /**
  13548. * Returns the string "CylinderDirectedParticleEmitter"
  13549. * @returns a string containing the class name
  13550. */
  13551. getClassName(): string;
  13552. /**
  13553. * Serializes the particle system to a JSON object.
  13554. * @returns the JSON object
  13555. */
  13556. serialize(): any;
  13557. /**
  13558. * Parse properties from a JSON object
  13559. * @param serializationObject defines the JSON object
  13560. */
  13561. parse(serializationObject: any): void;
  13562. }
  13563. }
  13564. declare module BABYLON {
  13565. /**
  13566. * Particle emitter emitting particles from the inside of a hemisphere.
  13567. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13568. */
  13569. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13570. /**
  13571. * The radius of the emission hemisphere.
  13572. */
  13573. radius: number;
  13574. /**
  13575. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13576. */
  13577. radiusRange: number;
  13578. /**
  13579. * How much to randomize the particle direction [0-1].
  13580. */
  13581. directionRandomizer: number;
  13582. /**
  13583. * Creates a new instance HemisphericParticleEmitter
  13584. * @param radius the radius of the emission hemisphere (1 by default)
  13585. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13586. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13587. */
  13588. constructor(
  13589. /**
  13590. * The radius of the emission hemisphere.
  13591. */
  13592. radius?: number,
  13593. /**
  13594. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13595. */
  13596. radiusRange?: number,
  13597. /**
  13598. * How much to randomize the particle direction [0-1].
  13599. */
  13600. directionRandomizer?: number);
  13601. /**
  13602. * Called by the particle System when the direction is computed for the created particle.
  13603. * @param worldMatrix is the world matrix of the particle system
  13604. * @param directionToUpdate is the direction vector to update with the result
  13605. * @param particle is the particle we are computed the direction for
  13606. * @param isLocal defines if the direction should be set in local space
  13607. */
  13608. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13609. /**
  13610. * Called by the particle System when the position is computed for the created particle.
  13611. * @param worldMatrix is the world matrix of the particle system
  13612. * @param positionToUpdate is the position vector to update with the result
  13613. * @param particle is the particle we are computed the position for
  13614. * @param isLocal defines if the position should be set in local space
  13615. */
  13616. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13617. /**
  13618. * Clones the current emitter and returns a copy of it
  13619. * @returns the new emitter
  13620. */
  13621. clone(): HemisphericParticleEmitter;
  13622. /**
  13623. * Called by the GPUParticleSystem to setup the update shader
  13624. * @param effect defines the update shader
  13625. */
  13626. applyToShader(effect: Effect): void;
  13627. /**
  13628. * Returns a string to use to update the GPU particles update shader
  13629. * @returns a string containng the defines string
  13630. */
  13631. getEffectDefines(): string;
  13632. /**
  13633. * Returns the string "HemisphericParticleEmitter"
  13634. * @returns a string containing the class name
  13635. */
  13636. getClassName(): string;
  13637. /**
  13638. * Serializes the particle system to a JSON object.
  13639. * @returns the JSON object
  13640. */
  13641. serialize(): any;
  13642. /**
  13643. * Parse properties from a JSON object
  13644. * @param serializationObject defines the JSON object
  13645. */
  13646. parse(serializationObject: any): void;
  13647. }
  13648. }
  13649. declare module BABYLON {
  13650. /**
  13651. * Particle emitter emitting particles from a point.
  13652. * It emits the particles randomly between 2 given directions.
  13653. */
  13654. export class PointParticleEmitter implements IParticleEmitterType {
  13655. /**
  13656. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13657. */
  13658. direction1: Vector3;
  13659. /**
  13660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13661. */
  13662. direction2: Vector3;
  13663. /**
  13664. * Creates a new instance PointParticleEmitter
  13665. */
  13666. constructor();
  13667. /**
  13668. * Called by the particle System when the direction is computed for the created particle.
  13669. * @param worldMatrix is the world matrix of the particle system
  13670. * @param directionToUpdate is the direction vector to update with the result
  13671. * @param particle is the particle we are computed the direction for
  13672. * @param isLocal defines if the direction should be set in local space
  13673. */
  13674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13675. /**
  13676. * Called by the particle System when the position is computed for the created particle.
  13677. * @param worldMatrix is the world matrix of the particle system
  13678. * @param positionToUpdate is the position vector to update with the result
  13679. * @param particle is the particle we are computed the position for
  13680. * @param isLocal defines if the position should be set in local space
  13681. */
  13682. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13683. /**
  13684. * Clones the current emitter and returns a copy of it
  13685. * @returns the new emitter
  13686. */
  13687. clone(): PointParticleEmitter;
  13688. /**
  13689. * Called by the GPUParticleSystem to setup the update shader
  13690. * @param effect defines the update shader
  13691. */
  13692. applyToShader(effect: Effect): void;
  13693. /**
  13694. * Returns a string to use to update the GPU particles update shader
  13695. * @returns a string containng the defines string
  13696. */
  13697. getEffectDefines(): string;
  13698. /**
  13699. * Returns the string "PointParticleEmitter"
  13700. * @returns a string containing the class name
  13701. */
  13702. getClassName(): string;
  13703. /**
  13704. * Serializes the particle system to a JSON object.
  13705. * @returns the JSON object
  13706. */
  13707. serialize(): any;
  13708. /**
  13709. * Parse properties from a JSON object
  13710. * @param serializationObject defines the JSON object
  13711. */
  13712. parse(serializationObject: any): void;
  13713. }
  13714. }
  13715. declare module BABYLON {
  13716. /**
  13717. * Particle emitter emitting particles from the inside of a sphere.
  13718. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13719. */
  13720. export class SphereParticleEmitter implements IParticleEmitterType {
  13721. /**
  13722. * The radius of the emission sphere.
  13723. */
  13724. radius: number;
  13725. /**
  13726. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13727. */
  13728. radiusRange: number;
  13729. /**
  13730. * How much to randomize the particle direction [0-1].
  13731. */
  13732. directionRandomizer: number;
  13733. /**
  13734. * Creates a new instance SphereParticleEmitter
  13735. * @param radius the radius of the emission sphere (1 by default)
  13736. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13737. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13738. */
  13739. constructor(
  13740. /**
  13741. * The radius of the emission sphere.
  13742. */
  13743. radius?: number,
  13744. /**
  13745. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13746. */
  13747. radiusRange?: number,
  13748. /**
  13749. * How much to randomize the particle direction [0-1].
  13750. */
  13751. directionRandomizer?: number);
  13752. /**
  13753. * Called by the particle System when the direction is computed for the created particle.
  13754. * @param worldMatrix is the world matrix of the particle system
  13755. * @param directionToUpdate is the direction vector to update with the result
  13756. * @param particle is the particle we are computed the direction for
  13757. * @param isLocal defines if the direction should be set in local space
  13758. */
  13759. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13760. /**
  13761. * Called by the particle System when the position is computed for the created particle.
  13762. * @param worldMatrix is the world matrix of the particle system
  13763. * @param positionToUpdate is the position vector to update with the result
  13764. * @param particle is the particle we are computed the position for
  13765. * @param isLocal defines if the position should be set in local space
  13766. */
  13767. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13768. /**
  13769. * Clones the current emitter and returns a copy of it
  13770. * @returns the new emitter
  13771. */
  13772. clone(): SphereParticleEmitter;
  13773. /**
  13774. * Called by the GPUParticleSystem to setup the update shader
  13775. * @param effect defines the update shader
  13776. */
  13777. applyToShader(effect: Effect): void;
  13778. /**
  13779. * Returns a string to use to update the GPU particles update shader
  13780. * @returns a string containng the defines string
  13781. */
  13782. getEffectDefines(): string;
  13783. /**
  13784. * Returns the string "SphereParticleEmitter"
  13785. * @returns a string containing the class name
  13786. */
  13787. getClassName(): string;
  13788. /**
  13789. * Serializes the particle system to a JSON object.
  13790. * @returns the JSON object
  13791. */
  13792. serialize(): any;
  13793. /**
  13794. * Parse properties from a JSON object
  13795. * @param serializationObject defines the JSON object
  13796. */
  13797. parse(serializationObject: any): void;
  13798. }
  13799. /**
  13800. * Particle emitter emitting particles from the inside of a sphere.
  13801. * It emits the particles randomly between two vectors.
  13802. */
  13803. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13804. /**
  13805. * The min limit of the emission direction.
  13806. */
  13807. direction1: Vector3;
  13808. /**
  13809. * The max limit of the emission direction.
  13810. */
  13811. direction2: Vector3;
  13812. /**
  13813. * Creates a new instance SphereDirectedParticleEmitter
  13814. * @param radius the radius of the emission sphere (1 by default)
  13815. * @param direction1 the min limit of the emission direction (up vector by default)
  13816. * @param direction2 the max limit of the emission direction (up vector by default)
  13817. */
  13818. constructor(radius?: number,
  13819. /**
  13820. * The min limit of the emission direction.
  13821. */
  13822. direction1?: Vector3,
  13823. /**
  13824. * The max limit of the emission direction.
  13825. */
  13826. direction2?: Vector3);
  13827. /**
  13828. * Called by the particle System when the direction is computed for the created particle.
  13829. * @param worldMatrix is the world matrix of the particle system
  13830. * @param directionToUpdate is the direction vector to update with the result
  13831. * @param particle is the particle we are computed the direction for
  13832. */
  13833. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13834. /**
  13835. * Clones the current emitter and returns a copy of it
  13836. * @returns the new emitter
  13837. */
  13838. clone(): SphereDirectedParticleEmitter;
  13839. /**
  13840. * Called by the GPUParticleSystem to setup the update shader
  13841. * @param effect defines the update shader
  13842. */
  13843. applyToShader(effect: Effect): void;
  13844. /**
  13845. * Returns a string to use to update the GPU particles update shader
  13846. * @returns a string containng the defines string
  13847. */
  13848. getEffectDefines(): string;
  13849. /**
  13850. * Returns the string "SphereDirectedParticleEmitter"
  13851. * @returns a string containing the class name
  13852. */
  13853. getClassName(): string;
  13854. /**
  13855. * Serializes the particle system to a JSON object.
  13856. * @returns the JSON object
  13857. */
  13858. serialize(): any;
  13859. /**
  13860. * Parse properties from a JSON object
  13861. * @param serializationObject defines the JSON object
  13862. */
  13863. parse(serializationObject: any): void;
  13864. }
  13865. }
  13866. declare module BABYLON {
  13867. /**
  13868. * Particle emitter emitting particles from a custom list of positions.
  13869. */
  13870. export class CustomParticleEmitter implements IParticleEmitterType {
  13871. /**
  13872. * Gets or sets the position generator that will create the inital position of each particle.
  13873. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13874. */
  13875. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13876. /**
  13877. * Gets or sets the destination generator that will create the final destination of each particle.
  13878. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13879. */
  13880. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13881. /**
  13882. * Creates a new instance CustomParticleEmitter
  13883. */
  13884. constructor();
  13885. /**
  13886. * Called by the particle System when the direction is computed for the created particle.
  13887. * @param worldMatrix is the world matrix of the particle system
  13888. * @param directionToUpdate is the direction vector to update with the result
  13889. * @param particle is the particle we are computed the direction for
  13890. * @param isLocal defines if the direction should be set in local space
  13891. */
  13892. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13893. /**
  13894. * Called by the particle System when the position is computed for the created particle.
  13895. * @param worldMatrix is the world matrix of the particle system
  13896. * @param positionToUpdate is the position vector to update with the result
  13897. * @param particle is the particle we are computed the position for
  13898. * @param isLocal defines if the position should be set in local space
  13899. */
  13900. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13901. /**
  13902. * Clones the current emitter and returns a copy of it
  13903. * @returns the new emitter
  13904. */
  13905. clone(): CustomParticleEmitter;
  13906. /**
  13907. * Called by the GPUParticleSystem to setup the update shader
  13908. * @param effect defines the update shader
  13909. */
  13910. applyToShader(effect: Effect): void;
  13911. /**
  13912. * Returns a string to use to update the GPU particles update shader
  13913. * @returns a string containng the defines string
  13914. */
  13915. getEffectDefines(): string;
  13916. /**
  13917. * Returns the string "PointParticleEmitter"
  13918. * @returns a string containing the class name
  13919. */
  13920. getClassName(): string;
  13921. /**
  13922. * Serializes the particle system to a JSON object.
  13923. * @returns the JSON object
  13924. */
  13925. serialize(): any;
  13926. /**
  13927. * Parse properties from a JSON object
  13928. * @param serializationObject defines the JSON object
  13929. */
  13930. parse(serializationObject: any): void;
  13931. }
  13932. }
  13933. declare module BABYLON {
  13934. /**
  13935. * Particle emitter emitting particles from the inside of a box.
  13936. * It emits the particles randomly between 2 given directions.
  13937. */
  13938. export class MeshParticleEmitter implements IParticleEmitterType {
  13939. private _indices;
  13940. private _positions;
  13941. private _normals;
  13942. private _storedNormal;
  13943. private _mesh;
  13944. /**
  13945. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13946. */
  13947. direction1: Vector3;
  13948. /**
  13949. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13950. */
  13951. direction2: Vector3;
  13952. /**
  13953. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13954. */
  13955. useMeshNormalsForDirection: boolean;
  13956. /** Defines the mesh to use as source */
  13957. get mesh(): Nullable<AbstractMesh>;
  13958. set mesh(value: Nullable<AbstractMesh>);
  13959. /**
  13960. * Creates a new instance MeshParticleEmitter
  13961. * @param mesh defines the mesh to use as source
  13962. */
  13963. constructor(mesh?: Nullable<AbstractMesh>);
  13964. /**
  13965. * Called by the particle System when the direction is computed for the created particle.
  13966. * @param worldMatrix is the world matrix of the particle system
  13967. * @param directionToUpdate is the direction vector to update with the result
  13968. * @param particle is the particle we are computed the direction for
  13969. * @param isLocal defines if the direction should be set in local space
  13970. */
  13971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13972. /**
  13973. * Called by the particle System when the position is computed for the created particle.
  13974. * @param worldMatrix is the world matrix of the particle system
  13975. * @param positionToUpdate is the position vector to update with the result
  13976. * @param particle is the particle we are computed the position for
  13977. * @param isLocal defines if the position should be set in local space
  13978. */
  13979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13980. /**
  13981. * Clones the current emitter and returns a copy of it
  13982. * @returns the new emitter
  13983. */
  13984. clone(): MeshParticleEmitter;
  13985. /**
  13986. * Called by the GPUParticleSystem to setup the update shader
  13987. * @param effect defines the update shader
  13988. */
  13989. applyToShader(effect: Effect): void;
  13990. /**
  13991. * Returns a string to use to update the GPU particles update shader
  13992. * @returns a string containng the defines string
  13993. */
  13994. getEffectDefines(): string;
  13995. /**
  13996. * Returns the string "BoxParticleEmitter"
  13997. * @returns a string containing the class name
  13998. */
  13999. getClassName(): string;
  14000. /**
  14001. * Serializes the particle system to a JSON object.
  14002. * @returns the JSON object
  14003. */
  14004. serialize(): any;
  14005. /**
  14006. * Parse properties from a JSON object
  14007. * @param serializationObject defines the JSON object
  14008. * @param scene defines the hosting scene
  14009. */
  14010. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14011. }
  14012. }
  14013. declare module BABYLON {
  14014. /**
  14015. * Interface representing a particle system in Babylon.js.
  14016. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14017. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14018. */
  14019. export interface IParticleSystem {
  14020. /**
  14021. * List of animations used by the particle system.
  14022. */
  14023. animations: Animation[];
  14024. /**
  14025. * The id of the Particle system.
  14026. */
  14027. id: string;
  14028. /**
  14029. * The name of the Particle system.
  14030. */
  14031. name: string;
  14032. /**
  14033. * The emitter represents the Mesh or position we are attaching the particle system to.
  14034. */
  14035. emitter: Nullable<AbstractMesh | Vector3>;
  14036. /**
  14037. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14038. */
  14039. isBillboardBased: boolean;
  14040. /**
  14041. * The rendering group used by the Particle system to chose when to render.
  14042. */
  14043. renderingGroupId: number;
  14044. /**
  14045. * The layer mask we are rendering the particles through.
  14046. */
  14047. layerMask: number;
  14048. /**
  14049. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14050. */
  14051. updateSpeed: number;
  14052. /**
  14053. * The amount of time the particle system is running (depends of the overall update speed).
  14054. */
  14055. targetStopDuration: number;
  14056. /**
  14057. * The texture used to render each particle. (this can be a spritesheet)
  14058. */
  14059. particleTexture: Nullable<BaseTexture>;
  14060. /**
  14061. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14062. */
  14063. blendMode: number;
  14064. /**
  14065. * Minimum life time of emitting particles.
  14066. */
  14067. minLifeTime: number;
  14068. /**
  14069. * Maximum life time of emitting particles.
  14070. */
  14071. maxLifeTime: number;
  14072. /**
  14073. * Minimum Size of emitting particles.
  14074. */
  14075. minSize: number;
  14076. /**
  14077. * Maximum Size of emitting particles.
  14078. */
  14079. maxSize: number;
  14080. /**
  14081. * Minimum scale of emitting particles on X axis.
  14082. */
  14083. minScaleX: number;
  14084. /**
  14085. * Maximum scale of emitting particles on X axis.
  14086. */
  14087. maxScaleX: number;
  14088. /**
  14089. * Minimum scale of emitting particles on Y axis.
  14090. */
  14091. minScaleY: number;
  14092. /**
  14093. * Maximum scale of emitting particles on Y axis.
  14094. */
  14095. maxScaleY: number;
  14096. /**
  14097. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14098. */
  14099. color1: Color4;
  14100. /**
  14101. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14102. */
  14103. color2: Color4;
  14104. /**
  14105. * Color the particle will have at the end of its lifetime.
  14106. */
  14107. colorDead: Color4;
  14108. /**
  14109. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14110. */
  14111. emitRate: number;
  14112. /**
  14113. * You can use gravity if you want to give an orientation to your particles.
  14114. */
  14115. gravity: Vector3;
  14116. /**
  14117. * Minimum power of emitting particles.
  14118. */
  14119. minEmitPower: number;
  14120. /**
  14121. * Maximum power of emitting particles.
  14122. */
  14123. maxEmitPower: number;
  14124. /**
  14125. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14126. */
  14127. minAngularSpeed: number;
  14128. /**
  14129. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14130. */
  14131. maxAngularSpeed: number;
  14132. /**
  14133. * Gets or sets the minimal initial rotation in radians.
  14134. */
  14135. minInitialRotation: number;
  14136. /**
  14137. * Gets or sets the maximal initial rotation in radians.
  14138. */
  14139. maxInitialRotation: number;
  14140. /**
  14141. * The particle emitter type defines the emitter used by the particle system.
  14142. * It can be for example box, sphere, or cone...
  14143. */
  14144. particleEmitterType: Nullable<IParticleEmitterType>;
  14145. /**
  14146. * Defines the delay in milliseconds before starting the system (0 by default)
  14147. */
  14148. startDelay: number;
  14149. /**
  14150. * 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
  14151. */
  14152. preWarmCycles: number;
  14153. /**
  14154. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14155. */
  14156. preWarmStepOffset: number;
  14157. /**
  14158. * 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)
  14159. */
  14160. spriteCellChangeSpeed: number;
  14161. /**
  14162. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14163. */
  14164. startSpriteCellID: number;
  14165. /**
  14166. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14167. */
  14168. endSpriteCellID: number;
  14169. /**
  14170. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14171. */
  14172. spriteCellWidth: number;
  14173. /**
  14174. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14175. */
  14176. spriteCellHeight: number;
  14177. /**
  14178. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14179. */
  14180. spriteRandomStartCell: boolean;
  14181. /**
  14182. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14183. */
  14184. isAnimationSheetEnabled: boolean;
  14185. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14186. translationPivot: Vector2;
  14187. /**
  14188. * Gets or sets a texture used to add random noise to particle positions
  14189. */
  14190. noiseTexture: Nullable<BaseTexture>;
  14191. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14192. noiseStrength: Vector3;
  14193. /**
  14194. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14195. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14196. */
  14197. billboardMode: number;
  14198. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14199. limitVelocityDamping: number;
  14200. /**
  14201. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14202. */
  14203. beginAnimationOnStart: boolean;
  14204. /**
  14205. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14206. */
  14207. beginAnimationFrom: number;
  14208. /**
  14209. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14210. */
  14211. beginAnimationTo: number;
  14212. /**
  14213. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14214. */
  14215. beginAnimationLoop: boolean;
  14216. /**
  14217. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14218. */
  14219. disposeOnStop: boolean;
  14220. /**
  14221. * Specifies if the particles are updated in emitter local space or world space
  14222. */
  14223. isLocal: boolean;
  14224. /** Snippet ID if the particle system was created from the snippet server */
  14225. snippetId: string;
  14226. /** Gets or sets a matrix to use to compute projection */
  14227. defaultProjectionMatrix: Matrix;
  14228. /**
  14229. * Gets the maximum number of particles active at the same time.
  14230. * @returns The max number of active particles.
  14231. */
  14232. getCapacity(): number;
  14233. /**
  14234. * Gets the number of particles active at the same time.
  14235. * @returns The number of active particles.
  14236. */
  14237. getActiveCount(): number;
  14238. /**
  14239. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14240. * @returns True if it has been started, otherwise false.
  14241. */
  14242. isStarted(): boolean;
  14243. /**
  14244. * Animates the particle system for this frame.
  14245. */
  14246. animate(): void;
  14247. /**
  14248. * Renders the particle system in its current state.
  14249. * @returns the current number of particles
  14250. */
  14251. render(): number;
  14252. /**
  14253. * Dispose the particle system and frees its associated resources.
  14254. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14255. */
  14256. dispose(disposeTexture?: boolean): void;
  14257. /**
  14258. * An event triggered when the system is disposed
  14259. */
  14260. onDisposeObservable: Observable<IParticleSystem>;
  14261. /**
  14262. * Clones the particle system.
  14263. * @param name The name of the cloned object
  14264. * @param newEmitter The new emitter to use
  14265. * @returns the cloned particle system
  14266. */
  14267. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14268. /**
  14269. * Serializes the particle system to a JSON object
  14270. * @param serializeTexture defines if the texture must be serialized as well
  14271. * @returns the JSON object
  14272. */
  14273. serialize(serializeTexture: boolean): any;
  14274. /**
  14275. * Rebuild the particle system
  14276. */
  14277. rebuild(): void;
  14278. /** Force the system to rebuild all gradients that need to be resync */
  14279. forceRefreshGradients(): void;
  14280. /**
  14281. * Starts the particle system and begins to emit
  14282. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14283. */
  14284. start(delay?: number): void;
  14285. /**
  14286. * Stops the particle system.
  14287. */
  14288. stop(): void;
  14289. /**
  14290. * Remove all active particles
  14291. */
  14292. reset(): void;
  14293. /**
  14294. * Gets a boolean indicating that the system is stopping
  14295. * @returns true if the system is currently stopping
  14296. */
  14297. isStopping(): boolean;
  14298. /**
  14299. * Is this system ready to be used/rendered
  14300. * @return true if the system is ready
  14301. */
  14302. isReady(): boolean;
  14303. /**
  14304. * Returns the string "ParticleSystem"
  14305. * @returns a string containing the class name
  14306. */
  14307. getClassName(): string;
  14308. /**
  14309. * Gets the custom effect used to render the particles
  14310. * @param blendMode Blend mode for which the effect should be retrieved
  14311. * @returns The effect
  14312. */
  14313. getCustomEffect(blendMode: number): Nullable<Effect>;
  14314. /**
  14315. * Sets the custom effect used to render the particles
  14316. * @param effect The effect to set
  14317. * @param blendMode Blend mode for which the effect should be set
  14318. */
  14319. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14320. /**
  14321. * Fill the defines array according to the current settings of the particle system
  14322. * @param defines Array to be updated
  14323. * @param blendMode blend mode to take into account when updating the array
  14324. */
  14325. fillDefines(defines: Array<string>, blendMode: number): void;
  14326. /**
  14327. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14328. * @param uniforms Uniforms array to fill
  14329. * @param attributes Attributes array to fill
  14330. * @param samplers Samplers array to fill
  14331. */
  14332. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14333. /**
  14334. * Observable that will be called just before the particles are drawn
  14335. */
  14336. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14337. /**
  14338. * Gets the name of the particle vertex shader
  14339. */
  14340. vertexShaderName: string;
  14341. /**
  14342. * Adds a new color gradient
  14343. * @param gradient defines the gradient to use (between 0 and 1)
  14344. * @param color1 defines the color to affect to the specified gradient
  14345. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14346. * @returns the current particle system
  14347. */
  14348. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14349. /**
  14350. * Remove a specific color gradient
  14351. * @param gradient defines the gradient to remove
  14352. * @returns the current particle system
  14353. */
  14354. removeColorGradient(gradient: number): IParticleSystem;
  14355. /**
  14356. * Adds a new size gradient
  14357. * @param gradient defines the gradient to use (between 0 and 1)
  14358. * @param factor defines the size factor to affect to the specified gradient
  14359. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14360. * @returns the current particle system
  14361. */
  14362. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14363. /**
  14364. * Remove a specific size gradient
  14365. * @param gradient defines the gradient to remove
  14366. * @returns the current particle system
  14367. */
  14368. removeSizeGradient(gradient: number): IParticleSystem;
  14369. /**
  14370. * Gets the current list of color gradients.
  14371. * You must use addColorGradient and removeColorGradient to udpate this list
  14372. * @returns the list of color gradients
  14373. */
  14374. getColorGradients(): Nullable<Array<ColorGradient>>;
  14375. /**
  14376. * Gets the current list of size gradients.
  14377. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14378. * @returns the list of size gradients
  14379. */
  14380. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14381. /**
  14382. * Gets the current list of angular speed gradients.
  14383. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14384. * @returns the list of angular speed gradients
  14385. */
  14386. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14387. /**
  14388. * Adds a new angular speed gradient
  14389. * @param gradient defines the gradient to use (between 0 and 1)
  14390. * @param factor defines the angular speed to affect to the specified gradient
  14391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14392. * @returns the current particle system
  14393. */
  14394. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14395. /**
  14396. * Remove a specific angular speed gradient
  14397. * @param gradient defines the gradient to remove
  14398. * @returns the current particle system
  14399. */
  14400. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14401. /**
  14402. * Gets the current list of velocity gradients.
  14403. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14404. * @returns the list of velocity gradients
  14405. */
  14406. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14407. /**
  14408. * Adds a new velocity gradient
  14409. * @param gradient defines the gradient to use (between 0 and 1)
  14410. * @param factor defines the velocity to affect to the specified gradient
  14411. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14412. * @returns the current particle system
  14413. */
  14414. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14415. /**
  14416. * Remove a specific velocity gradient
  14417. * @param gradient defines the gradient to remove
  14418. * @returns the current particle system
  14419. */
  14420. removeVelocityGradient(gradient: number): IParticleSystem;
  14421. /**
  14422. * Gets the current list of limit velocity gradients.
  14423. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14424. * @returns the list of limit velocity gradients
  14425. */
  14426. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14427. /**
  14428. * Adds a new limit velocity gradient
  14429. * @param gradient defines the gradient to use (between 0 and 1)
  14430. * @param factor defines the limit velocity to affect to the specified gradient
  14431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14432. * @returns the current particle system
  14433. */
  14434. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14435. /**
  14436. * Remove a specific limit velocity gradient
  14437. * @param gradient defines the gradient to remove
  14438. * @returns the current particle system
  14439. */
  14440. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14441. /**
  14442. * Adds a new drag gradient
  14443. * @param gradient defines the gradient to use (between 0 and 1)
  14444. * @param factor defines the drag to affect to the specified gradient
  14445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14446. * @returns the current particle system
  14447. */
  14448. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14449. /**
  14450. * Remove a specific drag gradient
  14451. * @param gradient defines the gradient to remove
  14452. * @returns the current particle system
  14453. */
  14454. removeDragGradient(gradient: number): IParticleSystem;
  14455. /**
  14456. * Gets the current list of drag gradients.
  14457. * You must use addDragGradient and removeDragGradient to udpate this list
  14458. * @returns the list of drag gradients
  14459. */
  14460. getDragGradients(): Nullable<Array<FactorGradient>>;
  14461. /**
  14462. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14463. * @param gradient defines the gradient to use (between 0 and 1)
  14464. * @param factor defines the emit rate to affect to the specified gradient
  14465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14466. * @returns the current particle system
  14467. */
  14468. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14469. /**
  14470. * Remove a specific emit rate gradient
  14471. * @param gradient defines the gradient to remove
  14472. * @returns the current particle system
  14473. */
  14474. removeEmitRateGradient(gradient: number): IParticleSystem;
  14475. /**
  14476. * Gets the current list of emit rate gradients.
  14477. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14478. * @returns the list of emit rate gradients
  14479. */
  14480. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14481. /**
  14482. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14483. * @param gradient defines the gradient to use (between 0 and 1)
  14484. * @param factor defines the start size to affect to the specified gradient
  14485. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14486. * @returns the current particle system
  14487. */
  14488. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14489. /**
  14490. * Remove a specific start size gradient
  14491. * @param gradient defines the gradient to remove
  14492. * @returns the current particle system
  14493. */
  14494. removeStartSizeGradient(gradient: number): IParticleSystem;
  14495. /**
  14496. * Gets the current list of start size gradients.
  14497. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14498. * @returns the list of start size gradients
  14499. */
  14500. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14501. /**
  14502. * Adds a new life time gradient
  14503. * @param gradient defines the gradient to use (between 0 and 1)
  14504. * @param factor defines the life time factor to affect to the specified gradient
  14505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14506. * @returns the current particle system
  14507. */
  14508. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14509. /**
  14510. * Remove a specific life time gradient
  14511. * @param gradient defines the gradient to remove
  14512. * @returns the current particle system
  14513. */
  14514. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14515. /**
  14516. * Gets the current list of life time gradients.
  14517. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14518. * @returns the list of life time gradients
  14519. */
  14520. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14521. /**
  14522. * Gets the current list of color gradients.
  14523. * You must use addColorGradient and removeColorGradient to udpate this list
  14524. * @returns the list of color gradients
  14525. */
  14526. getColorGradients(): Nullable<Array<ColorGradient>>;
  14527. /**
  14528. * Adds a new ramp gradient used to remap particle colors
  14529. * @param gradient defines the gradient to use (between 0 and 1)
  14530. * @param color defines the color to affect to the specified gradient
  14531. * @returns the current particle system
  14532. */
  14533. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14534. /**
  14535. * Gets the current list of ramp gradients.
  14536. * You must use addRampGradient and removeRampGradient to udpate this list
  14537. * @returns the list of ramp gradients
  14538. */
  14539. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14540. /** Gets or sets a boolean indicating that ramp gradients must be used
  14541. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14542. */
  14543. useRampGradients: boolean;
  14544. /**
  14545. * Adds a new color remap gradient
  14546. * @param gradient defines the gradient to use (between 0 and 1)
  14547. * @param min defines the color remap minimal range
  14548. * @param max defines the color remap maximal range
  14549. * @returns the current particle system
  14550. */
  14551. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14552. /**
  14553. * Gets the current list of color remap gradients.
  14554. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14555. * @returns the list of color remap gradients
  14556. */
  14557. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14558. /**
  14559. * Adds a new alpha remap gradient
  14560. * @param gradient defines the gradient to use (between 0 and 1)
  14561. * @param min defines the alpha remap minimal range
  14562. * @param max defines the alpha remap maximal range
  14563. * @returns the current particle system
  14564. */
  14565. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14566. /**
  14567. * Gets the current list of alpha remap gradients.
  14568. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14569. * @returns the list of alpha remap gradients
  14570. */
  14571. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14572. /**
  14573. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14574. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14575. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14576. * @returns the emitter
  14577. */
  14578. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14579. /**
  14580. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14581. * @param radius The radius of the hemisphere to emit from
  14582. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14583. * @returns the emitter
  14584. */
  14585. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14586. /**
  14587. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14588. * @param radius The radius of the sphere to emit from
  14589. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14590. * @returns the emitter
  14591. */
  14592. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14593. /**
  14594. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14595. * @param radius The radius of the sphere to emit from
  14596. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14597. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14598. * @returns the emitter
  14599. */
  14600. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14601. /**
  14602. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14603. * @param radius The radius of the emission cylinder
  14604. * @param height The height of the emission cylinder
  14605. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14606. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14607. * @returns the emitter
  14608. */
  14609. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14610. /**
  14611. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14612. * @param radius The radius of the cylinder to emit from
  14613. * @param height The height of the emission cylinder
  14614. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14615. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14616. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14617. * @returns the emitter
  14618. */
  14619. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14620. /**
  14621. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14622. * @param radius The radius of the cone to emit from
  14623. * @param angle The base angle of the cone
  14624. * @returns the emitter
  14625. */
  14626. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14627. /**
  14628. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14629. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14630. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14631. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14632. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14633. * @returns the emitter
  14634. */
  14635. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14636. /**
  14637. * Get hosting scene
  14638. * @returns the scene
  14639. */
  14640. getScene(): Nullable<Scene>;
  14641. }
  14642. }
  14643. declare module BABYLON {
  14644. /**
  14645. * 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.
  14646. * @see https://doc.babylonjs.com/how_to/transformnode
  14647. */
  14648. export class TransformNode extends Node {
  14649. /**
  14650. * Object will not rotate to face the camera
  14651. */
  14652. static BILLBOARDMODE_NONE: number;
  14653. /**
  14654. * Object will rotate to face the camera but only on the x axis
  14655. */
  14656. static BILLBOARDMODE_X: number;
  14657. /**
  14658. * Object will rotate to face the camera but only on the y axis
  14659. */
  14660. static BILLBOARDMODE_Y: number;
  14661. /**
  14662. * Object will rotate to face the camera but only on the z axis
  14663. */
  14664. static BILLBOARDMODE_Z: number;
  14665. /**
  14666. * Object will rotate to face the camera
  14667. */
  14668. static BILLBOARDMODE_ALL: number;
  14669. /**
  14670. * Object will rotate to face the camera's position instead of orientation
  14671. */
  14672. static BILLBOARDMODE_USE_POSITION: number;
  14673. private static _TmpRotation;
  14674. private static _TmpScaling;
  14675. private static _TmpTranslation;
  14676. private _forward;
  14677. private _forwardInverted;
  14678. private _up;
  14679. private _right;
  14680. private _rightInverted;
  14681. private _position;
  14682. private _rotation;
  14683. private _rotationQuaternion;
  14684. protected _scaling: Vector3;
  14685. protected _isDirty: boolean;
  14686. private _transformToBoneReferal;
  14687. private _isAbsoluteSynced;
  14688. private _billboardMode;
  14689. /**
  14690. * Gets or sets the billboard mode. Default is 0.
  14691. *
  14692. * | Value | Type | Description |
  14693. * | --- | --- | --- |
  14694. * | 0 | BILLBOARDMODE_NONE | |
  14695. * | 1 | BILLBOARDMODE_X | |
  14696. * | 2 | BILLBOARDMODE_Y | |
  14697. * | 4 | BILLBOARDMODE_Z | |
  14698. * | 7 | BILLBOARDMODE_ALL | |
  14699. *
  14700. */
  14701. get billboardMode(): number;
  14702. set billboardMode(value: number);
  14703. private _preserveParentRotationForBillboard;
  14704. /**
  14705. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14706. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14707. */
  14708. get preserveParentRotationForBillboard(): boolean;
  14709. set preserveParentRotationForBillboard(value: boolean);
  14710. /**
  14711. * 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
  14712. */
  14713. scalingDeterminant: number;
  14714. private _infiniteDistance;
  14715. /**
  14716. * Gets or sets the distance of the object to max, often used by skybox
  14717. */
  14718. get infiniteDistance(): boolean;
  14719. set infiniteDistance(value: boolean);
  14720. /**
  14721. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14722. * By default the system will update normals to compensate
  14723. */
  14724. ignoreNonUniformScaling: boolean;
  14725. /**
  14726. * 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
  14727. */
  14728. reIntegrateRotationIntoRotationQuaternion: boolean;
  14729. /** @hidden */
  14730. _poseMatrix: Nullable<Matrix>;
  14731. /** @hidden */
  14732. _localMatrix: Matrix;
  14733. private _usePivotMatrix;
  14734. private _absolutePosition;
  14735. private _absoluteScaling;
  14736. private _absoluteRotationQuaternion;
  14737. private _pivotMatrix;
  14738. private _pivotMatrixInverse;
  14739. /** @hidden */
  14740. _postMultiplyPivotMatrix: boolean;
  14741. protected _isWorldMatrixFrozen: boolean;
  14742. /** @hidden */
  14743. _indexInSceneTransformNodesArray: number;
  14744. /**
  14745. * An event triggered after the world matrix is updated
  14746. */
  14747. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14748. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14749. /**
  14750. * Gets a string identifying the name of the class
  14751. * @returns "TransformNode" string
  14752. */
  14753. getClassName(): string;
  14754. /**
  14755. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14756. */
  14757. get position(): Vector3;
  14758. set position(newPosition: Vector3);
  14759. /**
  14760. * 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)).
  14761. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14762. */
  14763. get rotation(): Vector3;
  14764. set rotation(newRotation: Vector3);
  14765. /**
  14766. * 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)).
  14767. */
  14768. get scaling(): Vector3;
  14769. set scaling(newScaling: Vector3);
  14770. /**
  14771. * 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).
  14772. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14773. */
  14774. get rotationQuaternion(): Nullable<Quaternion>;
  14775. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14776. /**
  14777. * The forward direction of that transform in world space.
  14778. */
  14779. get forward(): Vector3;
  14780. /**
  14781. * The up direction of that transform in world space.
  14782. */
  14783. get up(): Vector3;
  14784. /**
  14785. * The right direction of that transform in world space.
  14786. */
  14787. get right(): Vector3;
  14788. /**
  14789. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14790. * @param matrix the matrix to copy the pose from
  14791. * @returns this TransformNode.
  14792. */
  14793. updatePoseMatrix(matrix: Matrix): TransformNode;
  14794. /**
  14795. * Returns the mesh Pose matrix.
  14796. * @returns the pose matrix
  14797. */
  14798. getPoseMatrix(): Matrix;
  14799. /** @hidden */
  14800. _isSynchronized(): boolean;
  14801. /** @hidden */
  14802. _initCache(): void;
  14803. /**
  14804. * Flag the transform node as dirty (Forcing it to update everything)
  14805. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14806. * @returns this transform node
  14807. */
  14808. markAsDirty(property: string): TransformNode;
  14809. /**
  14810. * Returns the current mesh absolute position.
  14811. * Returns a Vector3.
  14812. */
  14813. get absolutePosition(): Vector3;
  14814. /**
  14815. * Returns the current mesh absolute scaling.
  14816. * Returns a Vector3.
  14817. */
  14818. get absoluteScaling(): Vector3;
  14819. /**
  14820. * Returns the current mesh absolute rotation.
  14821. * Returns a Quaternion.
  14822. */
  14823. get absoluteRotationQuaternion(): Quaternion;
  14824. /**
  14825. * Sets a new matrix to apply before all other transformation
  14826. * @param matrix defines the transform matrix
  14827. * @returns the current TransformNode
  14828. */
  14829. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14830. /**
  14831. * Sets a new pivot matrix to the current node
  14832. * @param matrix defines the new pivot matrix to use
  14833. * @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
  14834. * @returns the current TransformNode
  14835. */
  14836. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14837. /**
  14838. * Returns the mesh pivot matrix.
  14839. * Default : Identity.
  14840. * @returns the matrix
  14841. */
  14842. getPivotMatrix(): Matrix;
  14843. /**
  14844. * Instantiate (when possible) or clone that node with its hierarchy
  14845. * @param newParent defines the new parent to use for the instance (or clone)
  14846. * @param options defines options to configure how copy is done
  14847. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14848. * @returns an instance (or a clone) of the current node with its hiearchy
  14849. */
  14850. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14851. doNotInstantiate: boolean;
  14852. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14853. /**
  14854. * Prevents the World matrix to be computed any longer
  14855. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14856. * @returns the TransformNode.
  14857. */
  14858. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14859. /**
  14860. * Allows back the World matrix computation.
  14861. * @returns the TransformNode.
  14862. */
  14863. unfreezeWorldMatrix(): this;
  14864. /**
  14865. * True if the World matrix has been frozen.
  14866. */
  14867. get isWorldMatrixFrozen(): boolean;
  14868. /**
  14869. * Retuns the mesh absolute position in the World.
  14870. * @returns a Vector3.
  14871. */
  14872. getAbsolutePosition(): Vector3;
  14873. /**
  14874. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14875. * @param absolutePosition the absolute position to set
  14876. * @returns the TransformNode.
  14877. */
  14878. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14879. /**
  14880. * Sets the mesh position in its local space.
  14881. * @param vector3 the position to set in localspace
  14882. * @returns the TransformNode.
  14883. */
  14884. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14885. /**
  14886. * Returns the mesh position in the local space from the current World matrix values.
  14887. * @returns a new Vector3.
  14888. */
  14889. getPositionExpressedInLocalSpace(): Vector3;
  14890. /**
  14891. * Translates the mesh along the passed Vector3 in its local space.
  14892. * @param vector3 the distance to translate in localspace
  14893. * @returns the TransformNode.
  14894. */
  14895. locallyTranslate(vector3: Vector3): TransformNode;
  14896. private static _lookAtVectorCache;
  14897. /**
  14898. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14899. * @param targetPoint the position (must be in same space as current mesh) to look at
  14900. * @param yawCor optional yaw (y-axis) correction in radians
  14901. * @param pitchCor optional pitch (x-axis) correction in radians
  14902. * @param rollCor optional roll (z-axis) correction in radians
  14903. * @param space the choosen space of the target
  14904. * @returns the TransformNode.
  14905. */
  14906. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14907. /**
  14908. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14909. * This Vector3 is expressed in the World space.
  14910. * @param localAxis axis to rotate
  14911. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14912. */
  14913. getDirection(localAxis: Vector3): Vector3;
  14914. /**
  14915. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14916. * localAxis is expressed in the mesh local space.
  14917. * result is computed in the Wordl space from the mesh World matrix.
  14918. * @param localAxis axis to rotate
  14919. * @param result the resulting transformnode
  14920. * @returns this TransformNode.
  14921. */
  14922. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14923. /**
  14924. * Sets this transform node rotation to the given local axis.
  14925. * @param localAxis the axis in local space
  14926. * @param yawCor optional yaw (y-axis) correction in radians
  14927. * @param pitchCor optional pitch (x-axis) correction in radians
  14928. * @param rollCor optional roll (z-axis) correction in radians
  14929. * @returns this TransformNode
  14930. */
  14931. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14932. /**
  14933. * Sets a new pivot point to the current node
  14934. * @param point defines the new pivot point to use
  14935. * @param space defines if the point is in world or local space (local by default)
  14936. * @returns the current TransformNode
  14937. */
  14938. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14939. /**
  14940. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14941. * @returns the pivot point
  14942. */
  14943. getPivotPoint(): Vector3;
  14944. /**
  14945. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14946. * @param result the vector3 to store the result
  14947. * @returns this TransformNode.
  14948. */
  14949. getPivotPointToRef(result: Vector3): TransformNode;
  14950. /**
  14951. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14952. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14953. */
  14954. getAbsolutePivotPoint(): Vector3;
  14955. /**
  14956. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14957. * @param result vector3 to store the result
  14958. * @returns this TransformNode.
  14959. */
  14960. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14961. /**
  14962. * Defines the passed node as the parent of the current node.
  14963. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14964. * @see https://doc.babylonjs.com/how_to/parenting
  14965. * @param node the node ot set as the parent
  14966. * @returns this TransformNode.
  14967. */
  14968. setParent(node: Nullable<Node>): TransformNode;
  14969. private _nonUniformScaling;
  14970. /**
  14971. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14972. */
  14973. get nonUniformScaling(): boolean;
  14974. /** @hidden */
  14975. _updateNonUniformScalingState(value: boolean): boolean;
  14976. /**
  14977. * Attach the current TransformNode to another TransformNode associated with a bone
  14978. * @param bone Bone affecting the TransformNode
  14979. * @param affectedTransformNode TransformNode associated with the bone
  14980. * @returns this object
  14981. */
  14982. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14983. /**
  14984. * Detach the transform node if its associated with a bone
  14985. * @returns this object
  14986. */
  14987. detachFromBone(): TransformNode;
  14988. private static _rotationAxisCache;
  14989. /**
  14990. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14991. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14992. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14993. * The passed axis is also normalized.
  14994. * @param axis the axis to rotate around
  14995. * @param amount the amount to rotate in radians
  14996. * @param space Space to rotate in (Default: local)
  14997. * @returns the TransformNode.
  14998. */
  14999. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15000. /**
  15001. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15002. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15003. * The passed axis is also normalized. .
  15004. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15005. * @param point the point to rotate around
  15006. * @param axis the axis to rotate around
  15007. * @param amount the amount to rotate in radians
  15008. * @returns the TransformNode
  15009. */
  15010. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15011. /**
  15012. * Translates the mesh along the axis vector for the passed distance in the given space.
  15013. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15014. * @param axis the axis to translate in
  15015. * @param distance the distance to translate
  15016. * @param space Space to rotate in (Default: local)
  15017. * @returns the TransformNode.
  15018. */
  15019. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15020. /**
  15021. * Adds a rotation step to the mesh current rotation.
  15022. * x, y, z are Euler angles expressed in radians.
  15023. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15024. * This means this rotation is made in the mesh local space only.
  15025. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15026. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15027. * ```javascript
  15028. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15029. * ```
  15030. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15031. * 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.
  15032. * @param x Rotation to add
  15033. * @param y Rotation to add
  15034. * @param z Rotation to add
  15035. * @returns the TransformNode.
  15036. */
  15037. addRotation(x: number, y: number, z: number): TransformNode;
  15038. /**
  15039. * @hidden
  15040. */
  15041. protected _getEffectiveParent(): Nullable<Node>;
  15042. /**
  15043. * Computes the world matrix of the node
  15044. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15045. * @returns the world matrix
  15046. */
  15047. computeWorldMatrix(force?: boolean): Matrix;
  15048. /**
  15049. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15050. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15051. */
  15052. resetLocalMatrix(independentOfChildren?: boolean): void;
  15053. protected _afterComputeWorldMatrix(): void;
  15054. /**
  15055. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15056. * @param func callback function to add
  15057. *
  15058. * @returns the TransformNode.
  15059. */
  15060. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15061. /**
  15062. * Removes a registered callback function.
  15063. * @param func callback function to remove
  15064. * @returns the TransformNode.
  15065. */
  15066. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15067. /**
  15068. * Gets the position of the current mesh in camera space
  15069. * @param camera defines the camera to use
  15070. * @returns a position
  15071. */
  15072. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15073. /**
  15074. * Returns the distance from the mesh to the active camera
  15075. * @param camera defines the camera to use
  15076. * @returns the distance
  15077. */
  15078. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15079. /**
  15080. * Clone the current transform node
  15081. * @param name Name of the new clone
  15082. * @param newParent New parent for the clone
  15083. * @param doNotCloneChildren Do not clone children hierarchy
  15084. * @returns the new transform node
  15085. */
  15086. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15087. /**
  15088. * Serializes the objects information.
  15089. * @param currentSerializationObject defines the object to serialize in
  15090. * @returns the serialized object
  15091. */
  15092. serialize(currentSerializationObject?: any): any;
  15093. /**
  15094. * Returns a new TransformNode object parsed from the source provided.
  15095. * @param parsedTransformNode is the source.
  15096. * @param scene the scne the object belongs to
  15097. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15098. * @returns a new TransformNode object parsed from the source provided.
  15099. */
  15100. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15101. /**
  15102. * Get all child-transformNodes of this node
  15103. * @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
  15104. * @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
  15105. * @returns an array of TransformNode
  15106. */
  15107. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15108. /**
  15109. * Releases resources associated with this transform node.
  15110. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15111. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15112. */
  15113. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15114. /**
  15115. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15116. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15117. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15118. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15119. * @returns the current mesh
  15120. */
  15121. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15122. private _syncAbsoluteScalingAndRotation;
  15123. }
  15124. }
  15125. declare module BABYLON {
  15126. /**
  15127. * Class used to override all child animations of a given target
  15128. */
  15129. export class AnimationPropertiesOverride {
  15130. /**
  15131. * Gets or sets a value indicating if animation blending must be used
  15132. */
  15133. enableBlending: boolean;
  15134. /**
  15135. * Gets or sets the blending speed to use when enableBlending is true
  15136. */
  15137. blendingSpeed: number;
  15138. /**
  15139. * Gets or sets the default loop mode to use
  15140. */
  15141. loopMode: number;
  15142. }
  15143. }
  15144. declare module BABYLON {
  15145. /**
  15146. * Class used to store bone information
  15147. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15148. */
  15149. export class Bone extends Node {
  15150. /**
  15151. * defines the bone name
  15152. */
  15153. name: string;
  15154. private static _tmpVecs;
  15155. private static _tmpQuat;
  15156. private static _tmpMats;
  15157. /**
  15158. * Gets the list of child bones
  15159. */
  15160. children: Bone[];
  15161. /** Gets the animations associated with this bone */
  15162. animations: Animation[];
  15163. /**
  15164. * Gets or sets bone length
  15165. */
  15166. length: number;
  15167. /**
  15168. * @hidden Internal only
  15169. * Set this value to map this bone to a different index in the transform matrices
  15170. * Set this value to -1 to exclude the bone from the transform matrices
  15171. */
  15172. _index: Nullable<number>;
  15173. private _skeleton;
  15174. private _localMatrix;
  15175. private _restPose;
  15176. private _bindPose;
  15177. private _baseMatrix;
  15178. private _absoluteTransform;
  15179. private _invertedAbsoluteTransform;
  15180. private _parent;
  15181. private _scalingDeterminant;
  15182. private _worldTransform;
  15183. private _localScaling;
  15184. private _localRotation;
  15185. private _localPosition;
  15186. private _needToDecompose;
  15187. private _needToCompose;
  15188. /** @hidden */
  15189. _linkedTransformNode: Nullable<TransformNode>;
  15190. /** @hidden */
  15191. _waitingTransformNodeId: Nullable<string>;
  15192. /** @hidden */
  15193. get _matrix(): Matrix;
  15194. /** @hidden */
  15195. set _matrix(value: Matrix);
  15196. /**
  15197. * Create a new bone
  15198. * @param name defines the bone name
  15199. * @param skeleton defines the parent skeleton
  15200. * @param parentBone defines the parent (can be null if the bone is the root)
  15201. * @param localMatrix defines the local matrix
  15202. * @param restPose defines the rest pose matrix
  15203. * @param baseMatrix defines the base matrix
  15204. * @param index defines index of the bone in the hiearchy
  15205. */
  15206. constructor(
  15207. /**
  15208. * defines the bone name
  15209. */
  15210. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15211. /**
  15212. * Gets the current object class name.
  15213. * @return the class name
  15214. */
  15215. getClassName(): string;
  15216. /**
  15217. * Gets the parent skeleton
  15218. * @returns a skeleton
  15219. */
  15220. getSkeleton(): Skeleton;
  15221. /**
  15222. * Gets parent bone
  15223. * @returns a bone or null if the bone is the root of the bone hierarchy
  15224. */
  15225. getParent(): Nullable<Bone>;
  15226. /**
  15227. * Returns an array containing the root bones
  15228. * @returns an array containing the root bones
  15229. */
  15230. getChildren(): Array<Bone>;
  15231. /**
  15232. * Gets the node index in matrix array generated for rendering
  15233. * @returns the node index
  15234. */
  15235. getIndex(): number;
  15236. /**
  15237. * Sets the parent bone
  15238. * @param parent defines the parent (can be null if the bone is the root)
  15239. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15240. */
  15241. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15242. /**
  15243. * Gets the local matrix
  15244. * @returns a matrix
  15245. */
  15246. getLocalMatrix(): Matrix;
  15247. /**
  15248. * Gets the base matrix (initial matrix which remains unchanged)
  15249. * @returns a matrix
  15250. */
  15251. getBaseMatrix(): Matrix;
  15252. /**
  15253. * Gets the rest pose matrix
  15254. * @returns a matrix
  15255. */
  15256. getRestPose(): Matrix;
  15257. /**
  15258. * Sets the rest pose matrix
  15259. * @param matrix the local-space rest pose to set for this bone
  15260. */
  15261. setRestPose(matrix: Matrix): void;
  15262. /**
  15263. * Gets the bind pose matrix
  15264. * @returns the bind pose matrix
  15265. */
  15266. getBindPose(): Matrix;
  15267. /**
  15268. * Sets the bind pose matrix
  15269. * @param matrix the local-space bind pose to set for this bone
  15270. */
  15271. setBindPose(matrix: Matrix): void;
  15272. /**
  15273. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15274. */
  15275. getWorldMatrix(): Matrix;
  15276. /**
  15277. * Sets the local matrix to rest pose matrix
  15278. */
  15279. returnToRest(): void;
  15280. /**
  15281. * Gets the inverse of the absolute transform matrix.
  15282. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15283. * @returns a matrix
  15284. */
  15285. getInvertedAbsoluteTransform(): Matrix;
  15286. /**
  15287. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15288. * @returns a matrix
  15289. */
  15290. getAbsoluteTransform(): Matrix;
  15291. /**
  15292. * Links with the given transform node.
  15293. * The local matrix of this bone is copied from the transform node every frame.
  15294. * @param transformNode defines the transform node to link to
  15295. */
  15296. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15297. /**
  15298. * Gets the node used to drive the bone's transformation
  15299. * @returns a transform node or null
  15300. */
  15301. getTransformNode(): Nullable<TransformNode>;
  15302. /** Gets or sets current position (in local space) */
  15303. get position(): Vector3;
  15304. set position(newPosition: Vector3);
  15305. /** Gets or sets current rotation (in local space) */
  15306. get rotation(): Vector3;
  15307. set rotation(newRotation: Vector3);
  15308. /** Gets or sets current rotation quaternion (in local space) */
  15309. get rotationQuaternion(): Quaternion;
  15310. set rotationQuaternion(newRotation: Quaternion);
  15311. /** Gets or sets current scaling (in local space) */
  15312. get scaling(): Vector3;
  15313. set scaling(newScaling: Vector3);
  15314. /**
  15315. * Gets the animation properties override
  15316. */
  15317. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15318. private _decompose;
  15319. private _compose;
  15320. /**
  15321. * Update the base and local matrices
  15322. * @param matrix defines the new base or local matrix
  15323. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15324. * @param updateLocalMatrix defines if the local matrix should be updated
  15325. */
  15326. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15327. /** @hidden */
  15328. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15329. /**
  15330. * Flag the bone as dirty (Forcing it to update everything)
  15331. */
  15332. markAsDirty(): void;
  15333. /** @hidden */
  15334. _markAsDirtyAndCompose(): void;
  15335. private _markAsDirtyAndDecompose;
  15336. /**
  15337. * Translate the bone in local or world space
  15338. * @param vec The amount to translate the bone
  15339. * @param space The space that the translation is in
  15340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15341. */
  15342. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15343. /**
  15344. * Set the postion of the bone in local or world space
  15345. * @param position The position to set the bone
  15346. * @param space The space that the position is in
  15347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15348. */
  15349. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15350. /**
  15351. * Set the absolute position of the bone (world space)
  15352. * @param position The position to set the bone
  15353. * @param mesh The mesh that this bone is attached to
  15354. */
  15355. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15356. /**
  15357. * Scale the bone on the x, y and z axes (in local space)
  15358. * @param x The amount to scale the bone on the x axis
  15359. * @param y The amount to scale the bone on the y axis
  15360. * @param z The amount to scale the bone on the z axis
  15361. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15362. */
  15363. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15364. /**
  15365. * Set the bone scaling in local space
  15366. * @param scale defines the scaling vector
  15367. */
  15368. setScale(scale: Vector3): void;
  15369. /**
  15370. * Gets the current scaling in local space
  15371. * @returns the current scaling vector
  15372. */
  15373. getScale(): Vector3;
  15374. /**
  15375. * Gets the current scaling in local space and stores it in a target vector
  15376. * @param result defines the target vector
  15377. */
  15378. getScaleToRef(result: Vector3): void;
  15379. /**
  15380. * Set the yaw, pitch, and roll of the bone in local or world space
  15381. * @param yaw The rotation of the bone on the y axis
  15382. * @param pitch The rotation of the bone on the x axis
  15383. * @param roll The rotation of the bone on the z axis
  15384. * @param space The space that the axes of rotation are in
  15385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15386. */
  15387. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15388. /**
  15389. * Add a rotation to the bone on an axis in local or world space
  15390. * @param axis The axis to rotate the bone on
  15391. * @param amount The amount to rotate the bone
  15392. * @param space The space that the axis is in
  15393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15394. */
  15395. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15396. /**
  15397. * Set the rotation of the bone to a particular axis angle in local or world space
  15398. * @param axis The axis to rotate the bone on
  15399. * @param angle The angle that the bone should be rotated to
  15400. * @param space The space that the axis is in
  15401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15402. */
  15403. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15404. /**
  15405. * Set the euler rotation of the bone in local of world space
  15406. * @param rotation The euler rotation that the bone should be set to
  15407. * @param space The space that the rotation is in
  15408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15409. */
  15410. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15411. /**
  15412. * Set the quaternion rotation of the bone in local of world space
  15413. * @param quat The quaternion rotation that the bone should be set to
  15414. * @param space The space that the rotation is in
  15415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15416. */
  15417. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15418. /**
  15419. * Set the rotation matrix of the bone in local of world space
  15420. * @param rotMat The rotation matrix that the bone should be set to
  15421. * @param space The space that the rotation is in
  15422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15423. */
  15424. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15425. private _rotateWithMatrix;
  15426. private _getNegativeRotationToRef;
  15427. /**
  15428. * Get the position of the bone in local or world space
  15429. * @param space The space that the returned position is in
  15430. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15431. * @returns The position of the bone
  15432. */
  15433. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15434. /**
  15435. * Copy the position of the bone to a vector3 in local or world space
  15436. * @param space The space that the returned position is in
  15437. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15438. * @param result The vector3 to copy the position to
  15439. */
  15440. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15441. /**
  15442. * Get the absolute position of the bone (world space)
  15443. * @param mesh The mesh that this bone is attached to
  15444. * @returns The absolute position of the bone
  15445. */
  15446. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15447. /**
  15448. * Copy the absolute position of the bone (world space) to the result param
  15449. * @param mesh The mesh that this bone is attached to
  15450. * @param result The vector3 to copy the absolute position to
  15451. */
  15452. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15453. /**
  15454. * Compute the absolute transforms of this bone and its children
  15455. */
  15456. computeAbsoluteTransforms(): void;
  15457. /**
  15458. * Get the world direction from an axis that is in the local space of the bone
  15459. * @param localAxis The local direction that is used to compute the world direction
  15460. * @param mesh The mesh that this bone is attached to
  15461. * @returns The world direction
  15462. */
  15463. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15464. /**
  15465. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15466. * @param localAxis The local direction that is used to compute the world direction
  15467. * @param mesh The mesh that this bone is attached to
  15468. * @param result The vector3 that the world direction will be copied to
  15469. */
  15470. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15471. /**
  15472. * Get the euler rotation of the bone in local or world space
  15473. * @param space The space that the rotation should be in
  15474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15475. * @returns The euler rotation
  15476. */
  15477. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15478. /**
  15479. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15480. * @param space The space that the rotation should be in
  15481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15482. * @param result The vector3 that the rotation should be copied to
  15483. */
  15484. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15485. /**
  15486. * Get the quaternion rotation of the bone in either local or world space
  15487. * @param space The space that the rotation should be in
  15488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15489. * @returns The quaternion rotation
  15490. */
  15491. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15492. /**
  15493. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15494. * @param space The space that the rotation should be in
  15495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15496. * @param result The quaternion that the rotation should be copied to
  15497. */
  15498. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15499. /**
  15500. * Get the rotation matrix of the bone in local or world space
  15501. * @param space The space that the rotation should be in
  15502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15503. * @returns The rotation matrix
  15504. */
  15505. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15506. /**
  15507. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15508. * @param space The space that the rotation should be in
  15509. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15510. * @param result The quaternion that the rotation should be copied to
  15511. */
  15512. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15513. /**
  15514. * Get the world position of a point that is in the local space of the bone
  15515. * @param position The local position
  15516. * @param mesh The mesh that this bone is attached to
  15517. * @returns The world position
  15518. */
  15519. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15520. /**
  15521. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15522. * @param position The local position
  15523. * @param mesh The mesh that this bone is attached to
  15524. * @param result The vector3 that the world position should be copied to
  15525. */
  15526. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15527. /**
  15528. * Get the local position of a point that is in world space
  15529. * @param position The world position
  15530. * @param mesh The mesh that this bone is attached to
  15531. * @returns The local position
  15532. */
  15533. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15534. /**
  15535. * Get the local position of a point that is in world space and copy it to the result param
  15536. * @param position The world position
  15537. * @param mesh The mesh that this bone is attached to
  15538. * @param result The vector3 that the local position should be copied to
  15539. */
  15540. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15541. }
  15542. }
  15543. declare module BABYLON {
  15544. /**
  15545. * Defines a runtime animation
  15546. */
  15547. export class RuntimeAnimation {
  15548. private _events;
  15549. /**
  15550. * The current frame of the runtime animation
  15551. */
  15552. private _currentFrame;
  15553. /**
  15554. * The animation used by the runtime animation
  15555. */
  15556. private _animation;
  15557. /**
  15558. * The target of the runtime animation
  15559. */
  15560. private _target;
  15561. /**
  15562. * The initiating animatable
  15563. */
  15564. private _host;
  15565. /**
  15566. * The original value of the runtime animation
  15567. */
  15568. private _originalValue;
  15569. /**
  15570. * The original blend value of the runtime animation
  15571. */
  15572. private _originalBlendValue;
  15573. /**
  15574. * The offsets cache of the runtime animation
  15575. */
  15576. private _offsetsCache;
  15577. /**
  15578. * The high limits cache of the runtime animation
  15579. */
  15580. private _highLimitsCache;
  15581. /**
  15582. * Specifies if the runtime animation has been stopped
  15583. */
  15584. private _stopped;
  15585. /**
  15586. * The blending factor of the runtime animation
  15587. */
  15588. private _blendingFactor;
  15589. /**
  15590. * The BabylonJS scene
  15591. */
  15592. private _scene;
  15593. /**
  15594. * The current value of the runtime animation
  15595. */
  15596. private _currentValue;
  15597. /** @hidden */
  15598. _animationState: _IAnimationState;
  15599. /**
  15600. * The active target of the runtime animation
  15601. */
  15602. private _activeTargets;
  15603. private _currentActiveTarget;
  15604. private _directTarget;
  15605. /**
  15606. * The target path of the runtime animation
  15607. */
  15608. private _targetPath;
  15609. /**
  15610. * The weight of the runtime animation
  15611. */
  15612. private _weight;
  15613. /**
  15614. * The ratio offset of the runtime animation
  15615. */
  15616. private _ratioOffset;
  15617. /**
  15618. * The previous delay of the runtime animation
  15619. */
  15620. private _previousDelay;
  15621. /**
  15622. * The previous ratio of the runtime animation
  15623. */
  15624. private _previousRatio;
  15625. private _enableBlending;
  15626. private _keys;
  15627. private _minFrame;
  15628. private _maxFrame;
  15629. private _minValue;
  15630. private _maxValue;
  15631. private _targetIsArray;
  15632. /**
  15633. * Gets the current frame of the runtime animation
  15634. */
  15635. get currentFrame(): number;
  15636. /**
  15637. * Gets the weight of the runtime animation
  15638. */
  15639. get weight(): number;
  15640. /**
  15641. * Gets the current value of the runtime animation
  15642. */
  15643. get currentValue(): any;
  15644. /**
  15645. * Gets the target path of the runtime animation
  15646. */
  15647. get targetPath(): string;
  15648. /**
  15649. * Gets the actual target of the runtime animation
  15650. */
  15651. get target(): any;
  15652. /**
  15653. * Gets the additive state of the runtime animation
  15654. */
  15655. get isAdditive(): boolean;
  15656. /** @hidden */
  15657. _onLoop: () => void;
  15658. /**
  15659. * Create a new RuntimeAnimation object
  15660. * @param target defines the target of the animation
  15661. * @param animation defines the source animation object
  15662. * @param scene defines the hosting scene
  15663. * @param host defines the initiating Animatable
  15664. */
  15665. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15666. private _preparePath;
  15667. /**
  15668. * Gets the animation from the runtime animation
  15669. */
  15670. get animation(): Animation;
  15671. /**
  15672. * Resets the runtime animation to the beginning
  15673. * @param restoreOriginal defines whether to restore the target property to the original value
  15674. */
  15675. reset(restoreOriginal?: boolean): void;
  15676. /**
  15677. * Specifies if the runtime animation is stopped
  15678. * @returns Boolean specifying if the runtime animation is stopped
  15679. */
  15680. isStopped(): boolean;
  15681. /**
  15682. * Disposes of the runtime animation
  15683. */
  15684. dispose(): void;
  15685. /**
  15686. * Apply the interpolated value to the target
  15687. * @param currentValue defines the value computed by the animation
  15688. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15689. */
  15690. setValue(currentValue: any, weight: number): void;
  15691. private _getOriginalValues;
  15692. private _setValue;
  15693. /**
  15694. * Gets the loop pmode of the runtime animation
  15695. * @returns Loop Mode
  15696. */
  15697. private _getCorrectLoopMode;
  15698. /**
  15699. * Move the current animation to a given frame
  15700. * @param frame defines the frame to move to
  15701. */
  15702. goToFrame(frame: number): void;
  15703. /**
  15704. * @hidden Internal use only
  15705. */
  15706. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15707. /**
  15708. * Execute the current animation
  15709. * @param delay defines the delay to add to the current frame
  15710. * @param from defines the lower bound of the animation range
  15711. * @param to defines the upper bound of the animation range
  15712. * @param loop defines if the current animation must loop
  15713. * @param speedRatio defines the current speed ratio
  15714. * @param weight defines the weight of the animation (default is -1 so no weight)
  15715. * @param onLoop optional callback called when animation loops
  15716. * @returns a boolean indicating if the animation is running
  15717. */
  15718. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15719. }
  15720. }
  15721. declare module BABYLON {
  15722. /**
  15723. * Class used to store an actual running animation
  15724. */
  15725. export class Animatable {
  15726. /** defines the target object */
  15727. target: any;
  15728. /** defines the starting frame number (default is 0) */
  15729. fromFrame: number;
  15730. /** defines the ending frame number (default is 100) */
  15731. toFrame: number;
  15732. /** defines if the animation must loop (default is false) */
  15733. loopAnimation: boolean;
  15734. /** defines a callback to call when animation ends if it is not looping */
  15735. onAnimationEnd?: (() => void) | null | undefined;
  15736. /** defines a callback to call when animation loops */
  15737. onAnimationLoop?: (() => void) | null | undefined;
  15738. /** defines whether the animation should be evaluated additively */
  15739. isAdditive: boolean;
  15740. private _localDelayOffset;
  15741. private _pausedDelay;
  15742. private _runtimeAnimations;
  15743. private _paused;
  15744. private _scene;
  15745. private _speedRatio;
  15746. private _weight;
  15747. private _syncRoot;
  15748. /**
  15749. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15750. * This will only apply for non looping animation (default is true)
  15751. */
  15752. disposeOnEnd: boolean;
  15753. /**
  15754. * Gets a boolean indicating if the animation has started
  15755. */
  15756. animationStarted: boolean;
  15757. /**
  15758. * Observer raised when the animation ends
  15759. */
  15760. onAnimationEndObservable: Observable<Animatable>;
  15761. /**
  15762. * Observer raised when the animation loops
  15763. */
  15764. onAnimationLoopObservable: Observable<Animatable>;
  15765. /**
  15766. * Gets the root Animatable used to synchronize and normalize animations
  15767. */
  15768. get syncRoot(): Nullable<Animatable>;
  15769. /**
  15770. * Gets the current frame of the first RuntimeAnimation
  15771. * Used to synchronize Animatables
  15772. */
  15773. get masterFrame(): number;
  15774. /**
  15775. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15776. */
  15777. get weight(): number;
  15778. set weight(value: number);
  15779. /**
  15780. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15781. */
  15782. get speedRatio(): number;
  15783. set speedRatio(value: number);
  15784. /**
  15785. * Creates a new Animatable
  15786. * @param scene defines the hosting scene
  15787. * @param target defines the target object
  15788. * @param fromFrame defines the starting frame number (default is 0)
  15789. * @param toFrame defines the ending frame number (default is 100)
  15790. * @param loopAnimation defines if the animation must loop (default is false)
  15791. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15792. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15793. * @param animations defines a group of animation to add to the new Animatable
  15794. * @param onAnimationLoop defines a callback to call when animation loops
  15795. * @param isAdditive defines whether the animation should be evaluated additively
  15796. */
  15797. constructor(scene: Scene,
  15798. /** defines the target object */
  15799. target: any,
  15800. /** defines the starting frame number (default is 0) */
  15801. fromFrame?: number,
  15802. /** defines the ending frame number (default is 100) */
  15803. toFrame?: number,
  15804. /** defines if the animation must loop (default is false) */
  15805. loopAnimation?: boolean, speedRatio?: number,
  15806. /** defines a callback to call when animation ends if it is not looping */
  15807. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15808. /** defines a callback to call when animation loops */
  15809. onAnimationLoop?: (() => void) | null | undefined,
  15810. /** defines whether the animation should be evaluated additively */
  15811. isAdditive?: boolean);
  15812. /**
  15813. * Synchronize and normalize current Animatable with a source Animatable
  15814. * This is useful when using animation weights and when animations are not of the same length
  15815. * @param root defines the root Animatable to synchronize with
  15816. * @returns the current Animatable
  15817. */
  15818. syncWith(root: Animatable): Animatable;
  15819. /**
  15820. * Gets the list of runtime animations
  15821. * @returns an array of RuntimeAnimation
  15822. */
  15823. getAnimations(): RuntimeAnimation[];
  15824. /**
  15825. * Adds more animations to the current animatable
  15826. * @param target defines the target of the animations
  15827. * @param animations defines the new animations to add
  15828. */
  15829. appendAnimations(target: any, animations: Animation[]): void;
  15830. /**
  15831. * Gets the source animation for a specific property
  15832. * @param property defines the propertyu to look for
  15833. * @returns null or the source animation for the given property
  15834. */
  15835. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15836. /**
  15837. * Gets the runtime animation for a specific property
  15838. * @param property defines the propertyu to look for
  15839. * @returns null or the runtime animation for the given property
  15840. */
  15841. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15842. /**
  15843. * Resets the animatable to its original state
  15844. */
  15845. reset(): void;
  15846. /**
  15847. * Allows the animatable to blend with current running animations
  15848. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15849. * @param blendingSpeed defines the blending speed to use
  15850. */
  15851. enableBlending(blendingSpeed: number): void;
  15852. /**
  15853. * Disable animation blending
  15854. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15855. */
  15856. disableBlending(): void;
  15857. /**
  15858. * Jump directly to a given frame
  15859. * @param frame defines the frame to jump to
  15860. */
  15861. goToFrame(frame: number): void;
  15862. /**
  15863. * Pause the animation
  15864. */
  15865. pause(): void;
  15866. /**
  15867. * Restart the animation
  15868. */
  15869. restart(): void;
  15870. private _raiseOnAnimationEnd;
  15871. /**
  15872. * Stop and delete the current animation
  15873. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15874. * @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)
  15875. */
  15876. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15877. /**
  15878. * Wait asynchronously for the animation to end
  15879. * @returns a promise which will be fullfilled when the animation ends
  15880. */
  15881. waitAsync(): Promise<Animatable>;
  15882. /** @hidden */
  15883. _animate(delay: number): boolean;
  15884. }
  15885. interface Scene {
  15886. /** @hidden */
  15887. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15888. /** @hidden */
  15889. _processLateAnimationBindingsForMatrices(holder: {
  15890. totalWeight: number;
  15891. totalAdditiveWeight: number;
  15892. animations: RuntimeAnimation[];
  15893. additiveAnimations: RuntimeAnimation[];
  15894. originalValue: Matrix;
  15895. }): any;
  15896. /** @hidden */
  15897. _processLateAnimationBindingsForQuaternions(holder: {
  15898. totalWeight: number;
  15899. totalAdditiveWeight: number;
  15900. animations: RuntimeAnimation[];
  15901. additiveAnimations: RuntimeAnimation[];
  15902. originalValue: Quaternion;
  15903. }, refQuaternion: Quaternion): Quaternion;
  15904. /** @hidden */
  15905. _processLateAnimationBindings(): void;
  15906. /**
  15907. * Will start the animation sequence of a given target
  15908. * @param target defines the target
  15909. * @param from defines from which frame should animation start
  15910. * @param to defines until which frame should animation run.
  15911. * @param weight defines the weight to apply to the animation (1.0 by default)
  15912. * @param loop defines if the animation loops
  15913. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15914. * @param onAnimationEnd defines the function to be executed when the animation ends
  15915. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15916. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15917. * @param onAnimationLoop defines the callback to call when an animation loops
  15918. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15919. * @returns the animatable object created for this animation
  15920. */
  15921. 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;
  15922. /**
  15923. * Will start the animation sequence of a given target
  15924. * @param target defines the target
  15925. * @param from defines from which frame should animation start
  15926. * @param to defines until which frame should animation run.
  15927. * @param loop defines if the animation loops
  15928. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15929. * @param onAnimationEnd defines the function to be executed when the animation ends
  15930. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15931. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15932. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15933. * @param onAnimationLoop defines the callback to call when an animation loops
  15934. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15935. * @returns the animatable object created for this animation
  15936. */
  15937. 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;
  15938. /**
  15939. * Will start the animation sequence of a given target and its hierarchy
  15940. * @param target defines the target
  15941. * @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.
  15942. * @param from defines from which frame should animation start
  15943. * @param to defines until which frame should animation run.
  15944. * @param loop defines if the animation loops
  15945. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15946. * @param onAnimationEnd defines the function to be executed when the animation ends
  15947. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15948. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15949. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15950. * @param onAnimationLoop defines the callback to call when an animation loops
  15951. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15952. * @returns the list of created animatables
  15953. */
  15954. 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[];
  15955. /**
  15956. * Begin a new animation on a given node
  15957. * @param target defines the target where the animation will take place
  15958. * @param animations defines the list of animations to start
  15959. * @param from defines the initial value
  15960. * @param to defines the final value
  15961. * @param loop defines if you want animation to loop (off by default)
  15962. * @param speedRatio defines the speed ratio to apply to all animations
  15963. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15964. * @param onAnimationLoop defines the callback to call when an animation loops
  15965. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15966. * @returns the list of created animatables
  15967. */
  15968. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15969. /**
  15970. * Begin a new animation on a given node and its hierarchy
  15971. * @param target defines the root node where the animation will take place
  15972. * @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.
  15973. * @param animations defines the list of animations to start
  15974. * @param from defines the initial value
  15975. * @param to defines the final value
  15976. * @param loop defines if you want animation to loop (off by default)
  15977. * @param speedRatio defines the speed ratio to apply to all animations
  15978. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15979. * @param onAnimationLoop defines the callback to call when an animation loops
  15980. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15981. * @returns the list of animatables created for all nodes
  15982. */
  15983. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15984. /**
  15985. * Gets the animatable associated with a specific target
  15986. * @param target defines the target of the animatable
  15987. * @returns the required animatable if found
  15988. */
  15989. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15990. /**
  15991. * Gets all animatables associated with a given target
  15992. * @param target defines the target to look animatables for
  15993. * @returns an array of Animatables
  15994. */
  15995. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15996. /**
  15997. * Stops and removes all animations that have been applied to the scene
  15998. */
  15999. stopAllAnimations(): void;
  16000. /**
  16001. * Gets the current delta time used by animation engine
  16002. */
  16003. deltaTime: number;
  16004. }
  16005. interface Bone {
  16006. /**
  16007. * Copy an animation range from another bone
  16008. * @param source defines the source bone
  16009. * @param rangeName defines the range name to copy
  16010. * @param frameOffset defines the frame offset
  16011. * @param rescaleAsRequired defines if rescaling must be applied if required
  16012. * @param skelDimensionsRatio defines the scaling ratio
  16013. * @returns true if operation was successful
  16014. */
  16015. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16016. }
  16017. }
  16018. declare module BABYLON {
  16019. /**
  16020. * Class used to handle skinning animations
  16021. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16022. */
  16023. export class Skeleton implements IAnimatable {
  16024. /** defines the skeleton name */
  16025. name: string;
  16026. /** defines the skeleton Id */
  16027. id: string;
  16028. /**
  16029. * Defines the list of child bones
  16030. */
  16031. bones: Bone[];
  16032. /**
  16033. * Defines an estimate of the dimension of the skeleton at rest
  16034. */
  16035. dimensionsAtRest: Vector3;
  16036. /**
  16037. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16038. */
  16039. needInitialSkinMatrix: boolean;
  16040. /**
  16041. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16042. */
  16043. overrideMesh: Nullable<AbstractMesh>;
  16044. /**
  16045. * Gets the list of animations attached to this skeleton
  16046. */
  16047. animations: Array<Animation>;
  16048. private _scene;
  16049. private _isDirty;
  16050. private _transformMatrices;
  16051. private _transformMatrixTexture;
  16052. private _meshesWithPoseMatrix;
  16053. private _animatables;
  16054. private _identity;
  16055. private _synchronizedWithMesh;
  16056. private _ranges;
  16057. private _lastAbsoluteTransformsUpdateId;
  16058. private _canUseTextureForBones;
  16059. private _uniqueId;
  16060. /** @hidden */
  16061. _numBonesWithLinkedTransformNode: number;
  16062. /** @hidden */
  16063. _hasWaitingData: Nullable<boolean>;
  16064. /** @hidden */
  16065. _waitingOverrideMeshId: Nullable<string>;
  16066. /**
  16067. * Specifies if the skeleton should be serialized
  16068. */
  16069. doNotSerialize: boolean;
  16070. private _useTextureToStoreBoneMatrices;
  16071. /**
  16072. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16073. * Please note that this option is not available if the hardware does not support it
  16074. */
  16075. get useTextureToStoreBoneMatrices(): boolean;
  16076. set useTextureToStoreBoneMatrices(value: boolean);
  16077. private _animationPropertiesOverride;
  16078. /**
  16079. * Gets or sets the animation properties override
  16080. */
  16081. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16082. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16083. /**
  16084. * List of inspectable custom properties (used by the Inspector)
  16085. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16086. */
  16087. inspectableCustomProperties: IInspectable[];
  16088. /**
  16089. * An observable triggered before computing the skeleton's matrices
  16090. */
  16091. onBeforeComputeObservable: Observable<Skeleton>;
  16092. /**
  16093. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16094. */
  16095. get isUsingTextureForMatrices(): boolean;
  16096. /**
  16097. * Gets the unique ID of this skeleton
  16098. */
  16099. get uniqueId(): number;
  16100. /**
  16101. * Creates a new skeleton
  16102. * @param name defines the skeleton name
  16103. * @param id defines the skeleton Id
  16104. * @param scene defines the hosting scene
  16105. */
  16106. constructor(
  16107. /** defines the skeleton name */
  16108. name: string,
  16109. /** defines the skeleton Id */
  16110. id: string, scene: Scene);
  16111. /**
  16112. * Gets the current object class name.
  16113. * @return the class name
  16114. */
  16115. getClassName(): string;
  16116. /**
  16117. * Returns an array containing the root bones
  16118. * @returns an array containing the root bones
  16119. */
  16120. getChildren(): Array<Bone>;
  16121. /**
  16122. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16123. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16124. * @returns a Float32Array containing matrices data
  16125. */
  16126. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16127. /**
  16128. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16129. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16130. * @returns a raw texture containing the data
  16131. */
  16132. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16133. /**
  16134. * Gets the current hosting scene
  16135. * @returns a scene object
  16136. */
  16137. getScene(): Scene;
  16138. /**
  16139. * Gets a string representing the current skeleton data
  16140. * @param fullDetails defines a boolean indicating if we want a verbose version
  16141. * @returns a string representing the current skeleton data
  16142. */
  16143. toString(fullDetails?: boolean): string;
  16144. /**
  16145. * Get bone's index searching by name
  16146. * @param name defines bone's name to search for
  16147. * @return the indice of the bone. Returns -1 if not found
  16148. */
  16149. getBoneIndexByName(name: string): number;
  16150. /**
  16151. * Creater a new animation range
  16152. * @param name defines the name of the range
  16153. * @param from defines the start key
  16154. * @param to defines the end key
  16155. */
  16156. createAnimationRange(name: string, from: number, to: number): void;
  16157. /**
  16158. * Delete a specific animation range
  16159. * @param name defines the name of the range
  16160. * @param deleteFrames defines if frames must be removed as well
  16161. */
  16162. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16163. /**
  16164. * Gets a specific animation range
  16165. * @param name defines the name of the range to look for
  16166. * @returns the requested animation range or null if not found
  16167. */
  16168. getAnimationRange(name: string): Nullable<AnimationRange>;
  16169. /**
  16170. * Gets the list of all animation ranges defined on this skeleton
  16171. * @returns an array
  16172. */
  16173. getAnimationRanges(): Nullable<AnimationRange>[];
  16174. /**
  16175. * Copy animation range from a source skeleton.
  16176. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16177. * @param source defines the source skeleton
  16178. * @param name defines the name of the range to copy
  16179. * @param rescaleAsRequired defines if rescaling must be applied if required
  16180. * @returns true if operation was successful
  16181. */
  16182. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16183. /**
  16184. * Forces the skeleton to go to rest pose
  16185. */
  16186. returnToRest(): void;
  16187. private _getHighestAnimationFrame;
  16188. /**
  16189. * Begin a specific animation range
  16190. * @param name defines the name of the range to start
  16191. * @param loop defines if looping must be turned on (false by default)
  16192. * @param speedRatio defines the speed ratio to apply (1 by default)
  16193. * @param onAnimationEnd defines a callback which will be called when animation will end
  16194. * @returns a new animatable
  16195. */
  16196. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16197. /**
  16198. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16199. * @param skeleton defines the Skeleton containing the animation range to convert
  16200. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16201. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16202. * @returns the original skeleton
  16203. */
  16204. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16205. /** @hidden */
  16206. _markAsDirty(): void;
  16207. /** @hidden */
  16208. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16209. /** @hidden */
  16210. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16211. private _computeTransformMatrices;
  16212. /**
  16213. * Build all resources required to render a skeleton
  16214. */
  16215. prepare(): void;
  16216. /**
  16217. * Gets the list of animatables currently running for this skeleton
  16218. * @returns an array of animatables
  16219. */
  16220. getAnimatables(): IAnimatable[];
  16221. /**
  16222. * Clone the current skeleton
  16223. * @param name defines the name of the new skeleton
  16224. * @param id defines the id of the new skeleton
  16225. * @returns the new skeleton
  16226. */
  16227. clone(name: string, id?: string): Skeleton;
  16228. /**
  16229. * Enable animation blending for this skeleton
  16230. * @param blendingSpeed defines the blending speed to apply
  16231. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16232. */
  16233. enableBlending(blendingSpeed?: number): void;
  16234. /**
  16235. * Releases all resources associated with the current skeleton
  16236. */
  16237. dispose(): void;
  16238. /**
  16239. * Serialize the skeleton in a JSON object
  16240. * @returns a JSON object
  16241. */
  16242. serialize(): any;
  16243. /**
  16244. * Creates a new skeleton from serialized data
  16245. * @param parsedSkeleton defines the serialized data
  16246. * @param scene defines the hosting scene
  16247. * @returns a new skeleton
  16248. */
  16249. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16250. /**
  16251. * Compute all node absolute transforms
  16252. * @param forceUpdate defines if computation must be done even if cache is up to date
  16253. */
  16254. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16255. /**
  16256. * Gets the root pose matrix
  16257. * @returns a matrix
  16258. */
  16259. getPoseMatrix(): Nullable<Matrix>;
  16260. /**
  16261. * Sorts bones per internal index
  16262. */
  16263. sortBones(): void;
  16264. private _sortBones;
  16265. }
  16266. }
  16267. declare module BABYLON {
  16268. /**
  16269. * Creates an instance based on a source mesh.
  16270. */
  16271. export class InstancedMesh extends AbstractMesh {
  16272. private _sourceMesh;
  16273. private _currentLOD;
  16274. /** @hidden */
  16275. _indexInSourceMeshInstanceArray: number;
  16276. constructor(name: string, source: Mesh);
  16277. /**
  16278. * Returns the string "InstancedMesh".
  16279. */
  16280. getClassName(): string;
  16281. /** Gets the list of lights affecting that mesh */
  16282. get lightSources(): Light[];
  16283. _resyncLightSources(): void;
  16284. _resyncLightSource(light: Light): void;
  16285. _removeLightSource(light: Light, dispose: boolean): void;
  16286. /**
  16287. * If the source mesh receives shadows
  16288. */
  16289. get receiveShadows(): boolean;
  16290. /**
  16291. * The material of the source mesh
  16292. */
  16293. get material(): Nullable<Material>;
  16294. /**
  16295. * Visibility of the source mesh
  16296. */
  16297. get visibility(): number;
  16298. /**
  16299. * Skeleton of the source mesh
  16300. */
  16301. get skeleton(): Nullable<Skeleton>;
  16302. /**
  16303. * Rendering ground id of the source mesh
  16304. */
  16305. get renderingGroupId(): number;
  16306. set renderingGroupId(value: number);
  16307. /**
  16308. * Returns the total number of vertices (integer).
  16309. */
  16310. getTotalVertices(): number;
  16311. /**
  16312. * Returns a positive integer : the total number of indices in this mesh geometry.
  16313. * @returns the numner of indices or zero if the mesh has no geometry.
  16314. */
  16315. getTotalIndices(): number;
  16316. /**
  16317. * The source mesh of the instance
  16318. */
  16319. get sourceMesh(): Mesh;
  16320. /**
  16321. * Creates a new InstancedMesh object from the mesh model.
  16322. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16323. * @param name defines the name of the new instance
  16324. * @returns a new InstancedMesh
  16325. */
  16326. createInstance(name: string): InstancedMesh;
  16327. /**
  16328. * Is this node ready to be used/rendered
  16329. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16330. * @return {boolean} is it ready
  16331. */
  16332. isReady(completeCheck?: boolean): boolean;
  16333. /**
  16334. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16335. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16336. * @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.
  16337. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16338. */
  16339. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16340. /**
  16341. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16342. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16343. * The `data` are either a numeric array either a Float32Array.
  16344. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16345. * 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).
  16346. * Note that a new underlying VertexBuffer object is created each call.
  16347. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16348. *
  16349. * Possible `kind` values :
  16350. * - VertexBuffer.PositionKind
  16351. * - VertexBuffer.UVKind
  16352. * - VertexBuffer.UV2Kind
  16353. * - VertexBuffer.UV3Kind
  16354. * - VertexBuffer.UV4Kind
  16355. * - VertexBuffer.UV5Kind
  16356. * - VertexBuffer.UV6Kind
  16357. * - VertexBuffer.ColorKind
  16358. * - VertexBuffer.MatricesIndicesKind
  16359. * - VertexBuffer.MatricesIndicesExtraKind
  16360. * - VertexBuffer.MatricesWeightsKind
  16361. * - VertexBuffer.MatricesWeightsExtraKind
  16362. *
  16363. * Returns the Mesh.
  16364. */
  16365. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16366. /**
  16367. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16368. * If the mesh has no geometry, it is simply returned as it is.
  16369. * The `data` are either a numeric array either a Float32Array.
  16370. * No new underlying VertexBuffer object is created.
  16371. * 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.
  16372. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16373. *
  16374. * Possible `kind` values :
  16375. * - VertexBuffer.PositionKind
  16376. * - VertexBuffer.UVKind
  16377. * - VertexBuffer.UV2Kind
  16378. * - VertexBuffer.UV3Kind
  16379. * - VertexBuffer.UV4Kind
  16380. * - VertexBuffer.UV5Kind
  16381. * - VertexBuffer.UV6Kind
  16382. * - VertexBuffer.ColorKind
  16383. * - VertexBuffer.MatricesIndicesKind
  16384. * - VertexBuffer.MatricesIndicesExtraKind
  16385. * - VertexBuffer.MatricesWeightsKind
  16386. * - VertexBuffer.MatricesWeightsExtraKind
  16387. *
  16388. * Returns the Mesh.
  16389. */
  16390. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16391. /**
  16392. * Sets the mesh indices.
  16393. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16394. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16395. * This method creates a new index buffer each call.
  16396. * Returns the Mesh.
  16397. */
  16398. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16399. /**
  16400. * Boolean : True if the mesh owns the requested kind of data.
  16401. */
  16402. isVerticesDataPresent(kind: string): boolean;
  16403. /**
  16404. * Returns an array of indices (IndicesArray).
  16405. */
  16406. getIndices(): Nullable<IndicesArray>;
  16407. get _positions(): Nullable<Vector3[]>;
  16408. /**
  16409. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16410. * This means the mesh underlying bounding box and sphere are recomputed.
  16411. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16412. * @returns the current mesh
  16413. */
  16414. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16415. /** @hidden */
  16416. _preActivate(): InstancedMesh;
  16417. /** @hidden */
  16418. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16419. /** @hidden */
  16420. _postActivate(): void;
  16421. getWorldMatrix(): Matrix;
  16422. get isAnInstance(): boolean;
  16423. /**
  16424. * Returns the current associated LOD AbstractMesh.
  16425. */
  16426. getLOD(camera: Camera): AbstractMesh;
  16427. /** @hidden */
  16428. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16429. /** @hidden */
  16430. _syncSubMeshes(): InstancedMesh;
  16431. /** @hidden */
  16432. _generatePointsArray(): boolean;
  16433. /** @hidden */
  16434. _updateBoundingInfo(): AbstractMesh;
  16435. /**
  16436. * Creates a new InstancedMesh from the current mesh.
  16437. * - name (string) : the cloned mesh name
  16438. * - newParent (optional Node) : the optional Node to parent the clone to.
  16439. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16440. *
  16441. * Returns the clone.
  16442. */
  16443. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16444. /**
  16445. * Disposes the InstancedMesh.
  16446. * Returns nothing.
  16447. */
  16448. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16449. }
  16450. interface Mesh {
  16451. /**
  16452. * Register a custom buffer that will be instanced
  16453. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16454. * @param kind defines the buffer kind
  16455. * @param stride defines the stride in floats
  16456. */
  16457. registerInstancedBuffer(kind: string, stride: number): void;
  16458. /**
  16459. * true to use the edge renderer for all instances of this mesh
  16460. */
  16461. edgesShareWithInstances: boolean;
  16462. /** @hidden */
  16463. _userInstancedBuffersStorage: {
  16464. data: {
  16465. [key: string]: Float32Array;
  16466. };
  16467. sizes: {
  16468. [key: string]: number;
  16469. };
  16470. vertexBuffers: {
  16471. [key: string]: Nullable<VertexBuffer>;
  16472. };
  16473. strides: {
  16474. [key: string]: number;
  16475. };
  16476. };
  16477. }
  16478. interface AbstractMesh {
  16479. /**
  16480. * Object used to store instanced buffers defined by user
  16481. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16482. */
  16483. instancedBuffers: {
  16484. [key: string]: any;
  16485. };
  16486. }
  16487. }
  16488. declare module BABYLON {
  16489. /**
  16490. * Defines the options associated with the creation of a shader material.
  16491. */
  16492. export interface IShaderMaterialOptions {
  16493. /**
  16494. * Does the material work in alpha blend mode
  16495. */
  16496. needAlphaBlending: boolean;
  16497. /**
  16498. * Does the material work in alpha test mode
  16499. */
  16500. needAlphaTesting: boolean;
  16501. /**
  16502. * The list of attribute names used in the shader
  16503. */
  16504. attributes: string[];
  16505. /**
  16506. * The list of unifrom names used in the shader
  16507. */
  16508. uniforms: string[];
  16509. /**
  16510. * The list of UBO names used in the shader
  16511. */
  16512. uniformBuffers: string[];
  16513. /**
  16514. * The list of sampler names used in the shader
  16515. */
  16516. samplers: string[];
  16517. /**
  16518. * The list of defines used in the shader
  16519. */
  16520. defines: string[];
  16521. }
  16522. /**
  16523. * 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.
  16524. *
  16525. * This returned material effects how the mesh will look based on the code in the shaders.
  16526. *
  16527. * @see https://doc.babylonjs.com/how_to/shader_material
  16528. */
  16529. export class ShaderMaterial extends Material {
  16530. private _shaderPath;
  16531. private _options;
  16532. private _textures;
  16533. private _textureArrays;
  16534. private _floats;
  16535. private _ints;
  16536. private _floatsArrays;
  16537. private _colors3;
  16538. private _colors3Arrays;
  16539. private _colors4;
  16540. private _colors4Arrays;
  16541. private _vectors2;
  16542. private _vectors3;
  16543. private _vectors4;
  16544. private _matrices;
  16545. private _matrixArrays;
  16546. private _matrices3x3;
  16547. private _matrices2x2;
  16548. private _vectors2Arrays;
  16549. private _vectors3Arrays;
  16550. private _vectors4Arrays;
  16551. private _cachedWorldViewMatrix;
  16552. private _cachedWorldViewProjectionMatrix;
  16553. private _renderId;
  16554. private _multiview;
  16555. private _cachedDefines;
  16556. /** Define the Url to load snippets */
  16557. static SnippetUrl: string;
  16558. /** Snippet ID if the material was created from the snippet server */
  16559. snippetId: string;
  16560. /**
  16561. * Instantiate a new shader material.
  16562. * 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.
  16563. * This returned material effects how the mesh will look based on the code in the shaders.
  16564. * @see https://doc.babylonjs.com/how_to/shader_material
  16565. * @param name Define the name of the material in the scene
  16566. * @param scene Define the scene the material belongs to
  16567. * @param shaderPath Defines the route to the shader code in one of three ways:
  16568. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16569. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16570. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16571. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16572. * @param options Define the options used to create the shader
  16573. */
  16574. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16575. /**
  16576. * Gets the shader path used to define the shader code
  16577. * It can be modified to trigger a new compilation
  16578. */
  16579. get shaderPath(): any;
  16580. /**
  16581. * Sets the shader path used to define the shader code
  16582. * It can be modified to trigger a new compilation
  16583. */
  16584. set shaderPath(shaderPath: any);
  16585. /**
  16586. * Gets the options used to compile the shader.
  16587. * They can be modified to trigger a new compilation
  16588. */
  16589. get options(): IShaderMaterialOptions;
  16590. /**
  16591. * Gets the current class name of the material e.g. "ShaderMaterial"
  16592. * Mainly use in serialization.
  16593. * @returns the class name
  16594. */
  16595. getClassName(): string;
  16596. /**
  16597. * Specifies if the material will require alpha blending
  16598. * @returns a boolean specifying if alpha blending is needed
  16599. */
  16600. needAlphaBlending(): boolean;
  16601. /**
  16602. * Specifies if this material should be rendered in alpha test mode
  16603. * @returns a boolean specifying if an alpha test is needed.
  16604. */
  16605. needAlphaTesting(): boolean;
  16606. private _checkUniform;
  16607. /**
  16608. * Set a texture in the shader.
  16609. * @param name Define the name of the uniform samplers as defined in the shader
  16610. * @param texture Define the texture to bind to this sampler
  16611. * @return the material itself allowing "fluent" like uniform updates
  16612. */
  16613. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16614. /**
  16615. * Set a texture array in the shader.
  16616. * @param name Define the name of the uniform sampler array as defined in the shader
  16617. * @param textures Define the list of textures to bind to this sampler
  16618. * @return the material itself allowing "fluent" like uniform updates
  16619. */
  16620. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16621. /**
  16622. * Set a float in the shader.
  16623. * @param name Define the name of the uniform as defined in the shader
  16624. * @param value Define the value to give to the uniform
  16625. * @return the material itself allowing "fluent" like uniform updates
  16626. */
  16627. setFloat(name: string, value: number): ShaderMaterial;
  16628. /**
  16629. * Set a int in the shader.
  16630. * @param name Define the name of the uniform as defined in the shader
  16631. * @param value Define the value to give to the uniform
  16632. * @return the material itself allowing "fluent" like uniform updates
  16633. */
  16634. setInt(name: string, value: number): ShaderMaterial;
  16635. /**
  16636. * Set an array of floats in the shader.
  16637. * @param name Define the name of the uniform as defined in the shader
  16638. * @param value Define the value to give to the uniform
  16639. * @return the material itself allowing "fluent" like uniform updates
  16640. */
  16641. setFloats(name: string, value: number[]): ShaderMaterial;
  16642. /**
  16643. * Set a vec3 in the shader from a Color3.
  16644. * @param name Define the name of the uniform as defined in the shader
  16645. * @param value Define the value to give to the uniform
  16646. * @return the material itself allowing "fluent" like uniform updates
  16647. */
  16648. setColor3(name: string, value: Color3): ShaderMaterial;
  16649. /**
  16650. * Set a vec3 array in the shader from a Color3 array.
  16651. * @param name Define the name of the uniform as defined in the shader
  16652. * @param value Define the value to give to the uniform
  16653. * @return the material itself allowing "fluent" like uniform updates
  16654. */
  16655. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16656. /**
  16657. * Set a vec4 in the shader from a Color4.
  16658. * @param name Define the name of the uniform as defined in the shader
  16659. * @param value Define the value to give to the uniform
  16660. * @return the material itself allowing "fluent" like uniform updates
  16661. */
  16662. setColor4(name: string, value: Color4): ShaderMaterial;
  16663. /**
  16664. * Set a vec4 array in the shader from a Color4 array.
  16665. * @param name Define the name of the uniform as defined in the shader
  16666. * @param value Define the value to give to the uniform
  16667. * @return the material itself allowing "fluent" like uniform updates
  16668. */
  16669. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16670. /**
  16671. * Set a vec2 in the shader from a Vector2.
  16672. * @param name Define the name of the uniform as defined in the shader
  16673. * @param value Define the value to give to the uniform
  16674. * @return the material itself allowing "fluent" like uniform updates
  16675. */
  16676. setVector2(name: string, value: Vector2): ShaderMaterial;
  16677. /**
  16678. * Set a vec3 in the shader from a Vector3.
  16679. * @param name Define the name of the uniform as defined in the shader
  16680. * @param value Define the value to give to the uniform
  16681. * @return the material itself allowing "fluent" like uniform updates
  16682. */
  16683. setVector3(name: string, value: Vector3): ShaderMaterial;
  16684. /**
  16685. * Set a vec4 in the shader from a Vector4.
  16686. * @param name Define the name of the uniform as defined in the shader
  16687. * @param value Define the value to give to the uniform
  16688. * @return the material itself allowing "fluent" like uniform updates
  16689. */
  16690. setVector4(name: string, value: Vector4): ShaderMaterial;
  16691. /**
  16692. * Set a mat4 in the shader from a Matrix.
  16693. * @param name Define the name of the uniform as defined in the shader
  16694. * @param value Define the value to give to the uniform
  16695. * @return the material itself allowing "fluent" like uniform updates
  16696. */
  16697. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16698. /**
  16699. * Set a float32Array in the shader from a matrix array.
  16700. * @param name Define the name of the uniform as defined in the shader
  16701. * @param value Define the value to give to the uniform
  16702. * @return the material itself allowing "fluent" like uniform updates
  16703. */
  16704. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16705. /**
  16706. * Set a mat3 in the shader from a Float32Array.
  16707. * @param name Define the name of the uniform as defined in the shader
  16708. * @param value Define the value to give to the uniform
  16709. * @return the material itself allowing "fluent" like uniform updates
  16710. */
  16711. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16712. /**
  16713. * Set a mat2 in the shader from a Float32Array.
  16714. * @param name Define the name of the uniform as defined in the shader
  16715. * @param value Define the value to give to the uniform
  16716. * @return the material itself allowing "fluent" like uniform updates
  16717. */
  16718. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16719. /**
  16720. * Set a vec2 array in the shader from a number array.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the material itself allowing "fluent" like uniform updates
  16724. */
  16725. setArray2(name: string, value: number[]): ShaderMaterial;
  16726. /**
  16727. * Set a vec3 array in the shader from a number array.
  16728. * @param name Define the name of the uniform as defined in the shader
  16729. * @param value Define the value to give to the uniform
  16730. * @return the material itself allowing "fluent" like uniform updates
  16731. */
  16732. setArray3(name: string, value: number[]): ShaderMaterial;
  16733. /**
  16734. * Set a vec4 array in the shader from a number array.
  16735. * @param name Define the name of the uniform as defined in the shader
  16736. * @param value Define the value to give to the uniform
  16737. * @return the material itself allowing "fluent" like uniform updates
  16738. */
  16739. setArray4(name: string, value: number[]): ShaderMaterial;
  16740. private _checkCache;
  16741. /**
  16742. * Specifies that the submesh is ready to be used
  16743. * @param mesh defines the mesh to check
  16744. * @param subMesh defines which submesh to check
  16745. * @param useInstances specifies that instances should be used
  16746. * @returns a boolean indicating that the submesh is ready or not
  16747. */
  16748. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16749. /**
  16750. * Checks if the material is ready to render the requested mesh
  16751. * @param mesh Define the mesh to render
  16752. * @param useInstances Define whether or not the material is used with instances
  16753. * @returns true if ready, otherwise false
  16754. */
  16755. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16756. /**
  16757. * Binds the world matrix to the material
  16758. * @param world defines the world transformation matrix
  16759. * @param effectOverride - If provided, use this effect instead of internal effect
  16760. */
  16761. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16762. /**
  16763. * Binds the submesh to this material by preparing the effect and shader to draw
  16764. * @param world defines the world transformation matrix
  16765. * @param mesh defines the mesh containing the submesh
  16766. * @param subMesh defines the submesh to bind the material to
  16767. */
  16768. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16769. /**
  16770. * Binds the material to the mesh
  16771. * @param world defines the world transformation matrix
  16772. * @param mesh defines the mesh to bind the material to
  16773. * @param effectOverride - If provided, use this effect instead of internal effect
  16774. */
  16775. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16776. protected _afterBind(mesh?: Mesh): void;
  16777. /**
  16778. * Gets the active textures from the material
  16779. * @returns an array of textures
  16780. */
  16781. getActiveTextures(): BaseTexture[];
  16782. /**
  16783. * Specifies if the material uses a texture
  16784. * @param texture defines the texture to check against the material
  16785. * @returns a boolean specifying if the material uses the texture
  16786. */
  16787. hasTexture(texture: BaseTexture): boolean;
  16788. /**
  16789. * Makes a duplicate of the material, and gives it a new name
  16790. * @param name defines the new name for the duplicated material
  16791. * @returns the cloned material
  16792. */
  16793. clone(name: string): ShaderMaterial;
  16794. /**
  16795. * Disposes the material
  16796. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16797. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16798. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16799. */
  16800. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16801. /**
  16802. * Serializes this material in a JSON representation
  16803. * @returns the serialized material object
  16804. */
  16805. serialize(): any;
  16806. /**
  16807. * Creates a shader material from parsed shader material data
  16808. * @param source defines the JSON represnetation of the material
  16809. * @param scene defines the hosting scene
  16810. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16811. * @returns a new material
  16812. */
  16813. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16814. /**
  16815. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16816. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16817. * @param url defines the url to load from
  16818. * @param scene defines the hosting scene
  16819. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16820. * @returns a promise that will resolve to the new ShaderMaterial
  16821. */
  16822. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16823. /**
  16824. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16825. * @param snippetId defines the snippet to load
  16826. * @param scene defines the hosting scene
  16827. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16828. * @returns a promise that will resolve to the new ShaderMaterial
  16829. */
  16830. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16831. }
  16832. }
  16833. declare module BABYLON {
  16834. /** @hidden */
  16835. export var colorPixelShader: {
  16836. name: string;
  16837. shader: string;
  16838. };
  16839. }
  16840. declare module BABYLON {
  16841. /** @hidden */
  16842. export var colorVertexShader: {
  16843. name: string;
  16844. shader: string;
  16845. };
  16846. }
  16847. declare module BABYLON {
  16848. /**
  16849. * Line mesh
  16850. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16851. */
  16852. export class LinesMesh extends Mesh {
  16853. /**
  16854. * If vertex color should be applied to the mesh
  16855. */
  16856. readonly useVertexColor?: boolean | undefined;
  16857. /**
  16858. * If vertex alpha should be applied to the mesh
  16859. */
  16860. readonly useVertexAlpha?: boolean | undefined;
  16861. /**
  16862. * Color of the line (Default: White)
  16863. */
  16864. color: Color3;
  16865. /**
  16866. * Alpha of the line (Default: 1)
  16867. */
  16868. alpha: number;
  16869. /**
  16870. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16871. * This margin is expressed in world space coordinates, so its value may vary.
  16872. * Default value is 0.1
  16873. */
  16874. intersectionThreshold: number;
  16875. private _colorShader;
  16876. private color4;
  16877. /**
  16878. * Creates a new LinesMesh
  16879. * @param name defines the name
  16880. * @param scene defines the hosting scene
  16881. * @param parent defines the parent mesh if any
  16882. * @param source defines the optional source LinesMesh used to clone data from
  16883. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16884. * When false, achieved by calling a clone(), also passing False.
  16885. * This will make creation of children, recursive.
  16886. * @param useVertexColor defines if this LinesMesh supports vertex color
  16887. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16888. */
  16889. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16890. /**
  16891. * If vertex color should be applied to the mesh
  16892. */
  16893. useVertexColor?: boolean | undefined,
  16894. /**
  16895. * If vertex alpha should be applied to the mesh
  16896. */
  16897. useVertexAlpha?: boolean | undefined);
  16898. private _addClipPlaneDefine;
  16899. private _removeClipPlaneDefine;
  16900. isReady(): boolean;
  16901. /**
  16902. * Returns the string "LineMesh"
  16903. */
  16904. getClassName(): string;
  16905. /**
  16906. * @hidden
  16907. */
  16908. get material(): Material;
  16909. /**
  16910. * @hidden
  16911. */
  16912. set material(value: Material);
  16913. /**
  16914. * @hidden
  16915. */
  16916. get checkCollisions(): boolean;
  16917. /** @hidden */
  16918. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16919. /** @hidden */
  16920. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16921. /**
  16922. * Disposes of the line mesh
  16923. * @param doNotRecurse If children should be disposed
  16924. */
  16925. dispose(doNotRecurse?: boolean): void;
  16926. /**
  16927. * Returns a new LineMesh object cloned from the current one.
  16928. */
  16929. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16930. /**
  16931. * Creates a new InstancedLinesMesh object from the mesh model.
  16932. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16933. * @param name defines the name of the new instance
  16934. * @returns a new InstancedLinesMesh
  16935. */
  16936. createInstance(name: string): InstancedLinesMesh;
  16937. }
  16938. /**
  16939. * Creates an instance based on a source LinesMesh
  16940. */
  16941. export class InstancedLinesMesh extends InstancedMesh {
  16942. /**
  16943. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16944. * This margin is expressed in world space coordinates, so its value may vary.
  16945. * Initilized with the intersectionThreshold value of the source LinesMesh
  16946. */
  16947. intersectionThreshold: number;
  16948. constructor(name: string, source: LinesMesh);
  16949. /**
  16950. * Returns the string "InstancedLinesMesh".
  16951. */
  16952. getClassName(): string;
  16953. }
  16954. }
  16955. declare module BABYLON {
  16956. /** @hidden */
  16957. export var linePixelShader: {
  16958. name: string;
  16959. shader: string;
  16960. };
  16961. }
  16962. declare module BABYLON {
  16963. /** @hidden */
  16964. export var lineVertexShader: {
  16965. name: string;
  16966. shader: string;
  16967. };
  16968. }
  16969. declare module BABYLON {
  16970. interface Scene {
  16971. /** @hidden */
  16972. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16973. }
  16974. interface AbstractMesh {
  16975. /**
  16976. * Gets the edgesRenderer associated with the mesh
  16977. */
  16978. edgesRenderer: Nullable<EdgesRenderer>;
  16979. }
  16980. interface LinesMesh {
  16981. /**
  16982. * Enables the edge rendering mode on the mesh.
  16983. * This mode makes the mesh edges visible
  16984. * @param epsilon defines the maximal distance between two angles to detect a face
  16985. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16986. * @returns the currentAbstractMesh
  16987. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16988. */
  16989. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16990. }
  16991. interface InstancedLinesMesh {
  16992. /**
  16993. * Enables the edge rendering mode on the mesh.
  16994. * This mode makes the mesh edges visible
  16995. * @param epsilon defines the maximal distance between two angles to detect a face
  16996. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16997. * @returns the current InstancedLinesMesh
  16998. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16999. */
  17000. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17001. }
  17002. /**
  17003. * Defines the minimum contract an Edges renderer should follow.
  17004. */
  17005. export interface IEdgesRenderer extends IDisposable {
  17006. /**
  17007. * Gets or sets a boolean indicating if the edgesRenderer is active
  17008. */
  17009. isEnabled: boolean;
  17010. /**
  17011. * Renders the edges of the attached mesh,
  17012. */
  17013. render(): void;
  17014. /**
  17015. * Checks wether or not the edges renderer is ready to render.
  17016. * @return true if ready, otherwise false.
  17017. */
  17018. isReady(): boolean;
  17019. /**
  17020. * List of instances to render in case the source mesh has instances
  17021. */
  17022. customInstances: SmartArray<Matrix>;
  17023. }
  17024. /**
  17025. * Defines the additional options of the edges renderer
  17026. */
  17027. export interface IEdgesRendererOptions {
  17028. /**
  17029. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17030. * If not defined, the default value is true
  17031. */
  17032. useAlternateEdgeFinder?: boolean;
  17033. /**
  17034. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17035. * If not defined, the default value is true.
  17036. * 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)
  17037. * This option is used only if useAlternateEdgeFinder = true
  17038. */
  17039. useFastVertexMerger?: boolean;
  17040. /**
  17041. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17042. * The default value is 1e-6
  17043. * This option is used only if useAlternateEdgeFinder = true
  17044. */
  17045. epsilonVertexMerge?: number;
  17046. /**
  17047. * 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
  17048. * 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.
  17049. * This option is used only if useAlternateEdgeFinder = true
  17050. */
  17051. applyTessellation?: boolean;
  17052. /**
  17053. * 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
  17054. * The default value is 1e-6
  17055. * This option is used only if useAlternateEdgeFinder = true
  17056. */
  17057. epsilonVertexAligned?: number;
  17058. }
  17059. /**
  17060. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17061. */
  17062. export class EdgesRenderer implements IEdgesRenderer {
  17063. /**
  17064. * Define the size of the edges with an orthographic camera
  17065. */
  17066. edgesWidthScalerForOrthographic: number;
  17067. /**
  17068. * Define the size of the edges with a perspective camera
  17069. */
  17070. edgesWidthScalerForPerspective: number;
  17071. protected _source: AbstractMesh;
  17072. protected _linesPositions: number[];
  17073. protected _linesNormals: number[];
  17074. protected _linesIndices: number[];
  17075. protected _epsilon: number;
  17076. protected _indicesCount: number;
  17077. protected _lineShader: ShaderMaterial;
  17078. protected _ib: DataBuffer;
  17079. protected _buffers: {
  17080. [key: string]: Nullable<VertexBuffer>;
  17081. };
  17082. protected _buffersForInstances: {
  17083. [key: string]: Nullable<VertexBuffer>;
  17084. };
  17085. protected _checkVerticesInsteadOfIndices: boolean;
  17086. protected _options: Nullable<IEdgesRendererOptions>;
  17087. private _meshRebuildObserver;
  17088. private _meshDisposeObserver;
  17089. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17090. isEnabled: boolean;
  17091. /**
  17092. * List of instances to render in case the source mesh has instances
  17093. */
  17094. customInstances: SmartArray<Matrix>;
  17095. private static GetShader;
  17096. /**
  17097. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17098. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17099. * @param source Mesh used to create edges
  17100. * @param epsilon sum of angles in adjacency to check for edge
  17101. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17102. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17103. * @param options The options to apply when generating the edges
  17104. */
  17105. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17106. protected _prepareRessources(): void;
  17107. /** @hidden */
  17108. _rebuild(): void;
  17109. /**
  17110. * Releases the required resources for the edges renderer
  17111. */
  17112. dispose(): void;
  17113. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17114. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17115. /**
  17116. * Checks if the pair of p0 and p1 is en edge
  17117. * @param faceIndex
  17118. * @param edge
  17119. * @param faceNormals
  17120. * @param p0
  17121. * @param p1
  17122. * @private
  17123. */
  17124. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17125. /**
  17126. * push line into the position, normal and index buffer
  17127. * @protected
  17128. */
  17129. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17130. /**
  17131. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17132. */
  17133. private _tessellateTriangle;
  17134. private _generateEdgesLinesAlternate;
  17135. /**
  17136. * Generates lines edges from adjacencjes
  17137. * @private
  17138. */
  17139. _generateEdgesLines(): void;
  17140. /**
  17141. * Checks wether or not the edges renderer is ready to render.
  17142. * @return true if ready, otherwise false.
  17143. */
  17144. isReady(): boolean;
  17145. /**
  17146. * Renders the edges of the attached mesh,
  17147. */
  17148. render(): void;
  17149. }
  17150. /**
  17151. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17152. */
  17153. export class LineEdgesRenderer extends EdgesRenderer {
  17154. /**
  17155. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17156. * @param source LineMesh used to generate edges
  17157. * @param epsilon not important (specified angle for edge detection)
  17158. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17159. */
  17160. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17161. /**
  17162. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17163. */
  17164. _generateEdgesLines(): void;
  17165. }
  17166. }
  17167. declare module BABYLON {
  17168. /**
  17169. * This represents the object necessary to create a rendering group.
  17170. * This is exclusively used and created by the rendering manager.
  17171. * To modify the behavior, you use the available helpers in your scene or meshes.
  17172. * @hidden
  17173. */
  17174. export class RenderingGroup {
  17175. index: number;
  17176. private static _zeroVector;
  17177. private _scene;
  17178. private _opaqueSubMeshes;
  17179. private _transparentSubMeshes;
  17180. private _alphaTestSubMeshes;
  17181. private _depthOnlySubMeshes;
  17182. private _particleSystems;
  17183. private _spriteManagers;
  17184. private _opaqueSortCompareFn;
  17185. private _alphaTestSortCompareFn;
  17186. private _transparentSortCompareFn;
  17187. private _renderOpaque;
  17188. private _renderAlphaTest;
  17189. private _renderTransparent;
  17190. /** @hidden */
  17191. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17192. onBeforeTransparentRendering: () => void;
  17193. /**
  17194. * Set the opaque sort comparison function.
  17195. * If null the sub meshes will be render in the order they were created
  17196. */
  17197. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17198. /**
  17199. * Set the alpha test sort comparison function.
  17200. * If null the sub meshes will be render in the order they were created
  17201. */
  17202. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17203. /**
  17204. * Set the transparent sort comparison function.
  17205. * If null the sub meshes will be render in the order they were created
  17206. */
  17207. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17208. /**
  17209. * Creates a new rendering group.
  17210. * @param index The rendering group index
  17211. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17212. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17213. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17214. */
  17215. 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>);
  17216. /**
  17217. * Render all the sub meshes contained in the group.
  17218. * @param customRenderFunction Used to override the default render behaviour of the group.
  17219. * @returns true if rendered some submeshes.
  17220. */
  17221. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17222. /**
  17223. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17224. * @param subMeshes The submeshes to render
  17225. */
  17226. private renderOpaqueSorted;
  17227. /**
  17228. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17229. * @param subMeshes The submeshes to render
  17230. */
  17231. private renderAlphaTestSorted;
  17232. /**
  17233. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17234. * @param subMeshes The submeshes to render
  17235. */
  17236. private renderTransparentSorted;
  17237. /**
  17238. * Renders the submeshes in a specified order.
  17239. * @param subMeshes The submeshes to sort before render
  17240. * @param sortCompareFn The comparison function use to sort
  17241. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17242. * @param transparent Specifies to activate blending if true
  17243. */
  17244. private static renderSorted;
  17245. /**
  17246. * Renders the submeshes in the order they were dispatched (no sort applied).
  17247. * @param subMeshes The submeshes to render
  17248. */
  17249. private static renderUnsorted;
  17250. /**
  17251. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17252. * are rendered back to front if in the same alpha index.
  17253. *
  17254. * @param a The first submesh
  17255. * @param b The second submesh
  17256. * @returns The result of the comparison
  17257. */
  17258. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17259. /**
  17260. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17261. * are rendered back to front.
  17262. *
  17263. * @param a The first submesh
  17264. * @param b The second submesh
  17265. * @returns The result of the comparison
  17266. */
  17267. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17268. /**
  17269. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17270. * are rendered front to back (prevent overdraw).
  17271. *
  17272. * @param a The first submesh
  17273. * @param b The second submesh
  17274. * @returns The result of the comparison
  17275. */
  17276. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17277. /**
  17278. * Resets the different lists of submeshes to prepare a new frame.
  17279. */
  17280. prepare(): void;
  17281. dispose(): void;
  17282. /**
  17283. * Inserts the submesh in its correct queue depending on its material.
  17284. * @param subMesh The submesh to dispatch
  17285. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17286. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17287. */
  17288. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17289. dispatchSprites(spriteManager: ISpriteManager): void;
  17290. dispatchParticles(particleSystem: IParticleSystem): void;
  17291. private _renderParticles;
  17292. private _renderSprites;
  17293. }
  17294. }
  17295. declare module BABYLON {
  17296. /**
  17297. * Interface describing the different options available in the rendering manager
  17298. * regarding Auto Clear between groups.
  17299. */
  17300. export interface IRenderingManagerAutoClearSetup {
  17301. /**
  17302. * Defines whether or not autoclear is enable.
  17303. */
  17304. autoClear: boolean;
  17305. /**
  17306. * Defines whether or not to autoclear the depth buffer.
  17307. */
  17308. depth: boolean;
  17309. /**
  17310. * Defines whether or not to autoclear the stencil buffer.
  17311. */
  17312. stencil: boolean;
  17313. }
  17314. /**
  17315. * This class is used by the onRenderingGroupObservable
  17316. */
  17317. export class RenderingGroupInfo {
  17318. /**
  17319. * The Scene that being rendered
  17320. */
  17321. scene: Scene;
  17322. /**
  17323. * The camera currently used for the rendering pass
  17324. */
  17325. camera: Nullable<Camera>;
  17326. /**
  17327. * The ID of the renderingGroup being processed
  17328. */
  17329. renderingGroupId: number;
  17330. }
  17331. /**
  17332. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17333. * It is enable to manage the different groups as well as the different necessary sort functions.
  17334. * This should not be used directly aside of the few static configurations
  17335. */
  17336. export class RenderingManager {
  17337. /**
  17338. * The max id used for rendering groups (not included)
  17339. */
  17340. static MAX_RENDERINGGROUPS: number;
  17341. /**
  17342. * The min id used for rendering groups (included)
  17343. */
  17344. static MIN_RENDERINGGROUPS: number;
  17345. /**
  17346. * Used to globally prevent autoclearing scenes.
  17347. */
  17348. static AUTOCLEAR: boolean;
  17349. /**
  17350. * @hidden
  17351. */
  17352. _useSceneAutoClearSetup: boolean;
  17353. private _scene;
  17354. private _renderingGroups;
  17355. private _depthStencilBufferAlreadyCleaned;
  17356. private _autoClearDepthStencil;
  17357. private _customOpaqueSortCompareFn;
  17358. private _customAlphaTestSortCompareFn;
  17359. private _customTransparentSortCompareFn;
  17360. private _renderingGroupInfo;
  17361. /**
  17362. * Instantiates a new rendering group for a particular scene
  17363. * @param scene Defines the scene the groups belongs to
  17364. */
  17365. constructor(scene: Scene);
  17366. private _clearDepthStencilBuffer;
  17367. /**
  17368. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17369. * @hidden
  17370. */
  17371. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17372. /**
  17373. * Resets the different information of the group to prepare a new frame
  17374. * @hidden
  17375. */
  17376. reset(): void;
  17377. /**
  17378. * Dispose and release the group and its associated resources.
  17379. * @hidden
  17380. */
  17381. dispose(): void;
  17382. /**
  17383. * Clear the info related to rendering groups preventing retention points during dispose.
  17384. */
  17385. freeRenderingGroups(): void;
  17386. private _prepareRenderingGroup;
  17387. /**
  17388. * Add a sprite manager to the rendering manager in order to render it this frame.
  17389. * @param spriteManager Define the sprite manager to render
  17390. */
  17391. dispatchSprites(spriteManager: ISpriteManager): void;
  17392. /**
  17393. * Add a particle system to the rendering manager in order to render it this frame.
  17394. * @param particleSystem Define the particle system to render
  17395. */
  17396. dispatchParticles(particleSystem: IParticleSystem): void;
  17397. /**
  17398. * Add a submesh to the manager in order to render it this frame
  17399. * @param subMesh The submesh to dispatch
  17400. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17401. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17402. */
  17403. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17404. /**
  17405. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17406. * This allowed control for front to back rendering or reversly depending of the special needs.
  17407. *
  17408. * @param renderingGroupId The rendering group id corresponding to its index
  17409. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17410. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17411. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17412. */
  17413. 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;
  17414. /**
  17415. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17416. *
  17417. * @param renderingGroupId The rendering group id corresponding to its index
  17418. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17419. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17420. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17421. */
  17422. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17423. /**
  17424. * Gets the current auto clear configuration for one rendering group of the rendering
  17425. * manager.
  17426. * @param index the rendering group index to get the information for
  17427. * @returns The auto clear setup for the requested rendering group
  17428. */
  17429. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17430. }
  17431. }
  17432. declare module BABYLON {
  17433. /**
  17434. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17435. */
  17436. export interface ICustomShaderOptions {
  17437. /**
  17438. * Gets or sets the custom shader name to use
  17439. */
  17440. shaderName: string;
  17441. /**
  17442. * The list of attribute names used in the shader
  17443. */
  17444. attributes?: string[];
  17445. /**
  17446. * The list of unifrom names used in the shader
  17447. */
  17448. uniforms?: string[];
  17449. /**
  17450. * The list of sampler names used in the shader
  17451. */
  17452. samplers?: string[];
  17453. /**
  17454. * The list of defines used in the shader
  17455. */
  17456. defines?: string[];
  17457. }
  17458. /**
  17459. * Interface to implement to create a shadow generator compatible with BJS.
  17460. */
  17461. export interface IShadowGenerator {
  17462. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17463. id: string;
  17464. /**
  17465. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17466. * @returns The render target texture if present otherwise, null
  17467. */
  17468. getShadowMap(): Nullable<RenderTargetTexture>;
  17469. /**
  17470. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17471. * @param subMesh The submesh we want to render in the shadow map
  17472. * @param useInstances Defines wether will draw in the map using instances
  17473. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17474. * @returns true if ready otherwise, false
  17475. */
  17476. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17477. /**
  17478. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17479. * @param defines Defines of the material we want to update
  17480. * @param lightIndex Index of the light in the enabled light list of the material
  17481. */
  17482. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17483. /**
  17484. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17485. * defined in the generator but impacting the effect).
  17486. * It implies the unifroms available on the materials are the standard BJS ones.
  17487. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17488. * @param effect The effect we are binfing the information for
  17489. */
  17490. bindShadowLight(lightIndex: string, effect: Effect): void;
  17491. /**
  17492. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17493. * (eq to shadow prjection matrix * light transform matrix)
  17494. * @returns The transform matrix used to create the shadow map
  17495. */
  17496. getTransformMatrix(): Matrix;
  17497. /**
  17498. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17499. * Cube and 2D textures for instance.
  17500. */
  17501. recreateShadowMap(): void;
  17502. /**
  17503. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17504. * @param onCompiled Callback triggered at the and of the effects compilation
  17505. * @param options Sets of optional options forcing the compilation with different modes
  17506. */
  17507. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17508. useInstances: boolean;
  17509. }>): void;
  17510. /**
  17511. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17512. * @param options Sets of optional options forcing the compilation with different modes
  17513. * @returns A promise that resolves when the compilation completes
  17514. */
  17515. forceCompilationAsync(options?: Partial<{
  17516. useInstances: boolean;
  17517. }>): Promise<void>;
  17518. /**
  17519. * Serializes the shadow generator setup to a json object.
  17520. * @returns The serialized JSON object
  17521. */
  17522. serialize(): any;
  17523. /**
  17524. * Disposes the Shadow map and related Textures and effects.
  17525. */
  17526. dispose(): void;
  17527. }
  17528. /**
  17529. * Default implementation IShadowGenerator.
  17530. * This is the main object responsible of generating shadows in the framework.
  17531. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17532. */
  17533. export class ShadowGenerator implements IShadowGenerator {
  17534. /**
  17535. * Name of the shadow generator class
  17536. */
  17537. static CLASSNAME: string;
  17538. /**
  17539. * Shadow generator mode None: no filtering applied.
  17540. */
  17541. static readonly FILTER_NONE: number;
  17542. /**
  17543. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17544. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17545. */
  17546. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17547. /**
  17548. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17549. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17550. */
  17551. static readonly FILTER_POISSONSAMPLING: number;
  17552. /**
  17553. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17554. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17555. */
  17556. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17557. /**
  17558. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17559. * edge artifacts on steep falloff.
  17560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17561. */
  17562. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17563. /**
  17564. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17565. * edge artifacts on steep falloff.
  17566. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17567. */
  17568. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17569. /**
  17570. * Shadow generator mode PCF: Percentage Closer Filtering
  17571. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17572. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17573. */
  17574. static readonly FILTER_PCF: number;
  17575. /**
  17576. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17577. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17578. * Contact Hardening
  17579. */
  17580. static readonly FILTER_PCSS: number;
  17581. /**
  17582. * Reserved for PCF and PCSS
  17583. * Highest Quality.
  17584. *
  17585. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17586. *
  17587. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17588. */
  17589. static readonly QUALITY_HIGH: number;
  17590. /**
  17591. * Reserved for PCF and PCSS
  17592. * Good tradeoff for quality/perf cross devices
  17593. *
  17594. * Execute PCF on a 3*3 kernel.
  17595. *
  17596. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17597. */
  17598. static readonly QUALITY_MEDIUM: number;
  17599. /**
  17600. * Reserved for PCF and PCSS
  17601. * The lowest quality but the fastest.
  17602. *
  17603. * Execute PCF on a 1*1 kernel.
  17604. *
  17605. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17606. */
  17607. static readonly QUALITY_LOW: number;
  17608. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17609. id: string;
  17610. /** Gets or sets the custom shader name to use */
  17611. customShaderOptions: ICustomShaderOptions;
  17612. /**
  17613. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17614. */
  17615. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17616. /**
  17617. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17618. */
  17619. onAfterShadowMapRenderObservable: Observable<Effect>;
  17620. /**
  17621. * Observable triggered before a mesh is rendered in the shadow map.
  17622. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17623. */
  17624. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17625. /**
  17626. * Observable triggered after a mesh is rendered in the shadow map.
  17627. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17628. */
  17629. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17630. protected _bias: number;
  17631. /**
  17632. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17633. */
  17634. get bias(): number;
  17635. /**
  17636. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17637. */
  17638. set bias(bias: number);
  17639. protected _normalBias: number;
  17640. /**
  17641. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17642. */
  17643. get normalBias(): number;
  17644. /**
  17645. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17646. */
  17647. set normalBias(normalBias: number);
  17648. protected _blurBoxOffset: number;
  17649. /**
  17650. * Gets the blur box offset: offset applied during the blur pass.
  17651. * Only useful if useKernelBlur = false
  17652. */
  17653. get blurBoxOffset(): number;
  17654. /**
  17655. * Sets the blur box offset: offset applied during the blur pass.
  17656. * Only useful if useKernelBlur = false
  17657. */
  17658. set blurBoxOffset(value: number);
  17659. protected _blurScale: number;
  17660. /**
  17661. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17662. * 2 means half of the size.
  17663. */
  17664. get blurScale(): number;
  17665. /**
  17666. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17667. * 2 means half of the size.
  17668. */
  17669. set blurScale(value: number);
  17670. protected _blurKernel: number;
  17671. /**
  17672. * Gets the blur kernel: kernel size of the blur pass.
  17673. * Only useful if useKernelBlur = true
  17674. */
  17675. get blurKernel(): number;
  17676. /**
  17677. * Sets the blur kernel: kernel size of the blur pass.
  17678. * Only useful if useKernelBlur = true
  17679. */
  17680. set blurKernel(value: number);
  17681. protected _useKernelBlur: boolean;
  17682. /**
  17683. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17684. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17685. */
  17686. get useKernelBlur(): boolean;
  17687. /**
  17688. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17689. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17690. */
  17691. set useKernelBlur(value: boolean);
  17692. protected _depthScale: number;
  17693. /**
  17694. * Gets the depth scale used in ESM mode.
  17695. */
  17696. get depthScale(): number;
  17697. /**
  17698. * Sets the depth scale used in ESM mode.
  17699. * This can override the scale stored on the light.
  17700. */
  17701. set depthScale(value: number);
  17702. protected _validateFilter(filter: number): number;
  17703. protected _filter: number;
  17704. /**
  17705. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17706. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17707. */
  17708. get filter(): number;
  17709. /**
  17710. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17711. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17712. */
  17713. set filter(value: number);
  17714. /**
  17715. * Gets if the current filter is set to Poisson Sampling.
  17716. */
  17717. get usePoissonSampling(): boolean;
  17718. /**
  17719. * Sets the current filter to Poisson Sampling.
  17720. */
  17721. set usePoissonSampling(value: boolean);
  17722. /**
  17723. * Gets if the current filter is set to ESM.
  17724. */
  17725. get useExponentialShadowMap(): boolean;
  17726. /**
  17727. * Sets the current filter is to ESM.
  17728. */
  17729. set useExponentialShadowMap(value: boolean);
  17730. /**
  17731. * Gets if the current filter is set to filtered ESM.
  17732. */
  17733. get useBlurExponentialShadowMap(): boolean;
  17734. /**
  17735. * Gets if the current filter is set to filtered ESM.
  17736. */
  17737. set useBlurExponentialShadowMap(value: boolean);
  17738. /**
  17739. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17740. * exponential to prevent steep falloff artifacts).
  17741. */
  17742. get useCloseExponentialShadowMap(): boolean;
  17743. /**
  17744. * Sets the current filter to "close ESM" (using the inverse of the
  17745. * exponential to prevent steep falloff artifacts).
  17746. */
  17747. set useCloseExponentialShadowMap(value: boolean);
  17748. /**
  17749. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17750. * exponential to prevent steep falloff artifacts).
  17751. */
  17752. get useBlurCloseExponentialShadowMap(): boolean;
  17753. /**
  17754. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17755. * exponential to prevent steep falloff artifacts).
  17756. */
  17757. set useBlurCloseExponentialShadowMap(value: boolean);
  17758. /**
  17759. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17760. */
  17761. get usePercentageCloserFiltering(): boolean;
  17762. /**
  17763. * Sets the current filter to "PCF" (percentage closer filtering).
  17764. */
  17765. set usePercentageCloserFiltering(value: boolean);
  17766. protected _filteringQuality: number;
  17767. /**
  17768. * Gets the PCF or PCSS Quality.
  17769. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17770. */
  17771. get filteringQuality(): number;
  17772. /**
  17773. * Sets the PCF or PCSS Quality.
  17774. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17775. */
  17776. set filteringQuality(filteringQuality: number);
  17777. /**
  17778. * Gets if the current filter is set to "PCSS" (contact hardening).
  17779. */
  17780. get useContactHardeningShadow(): boolean;
  17781. /**
  17782. * Sets the current filter to "PCSS" (contact hardening).
  17783. */
  17784. set useContactHardeningShadow(value: boolean);
  17785. protected _contactHardeningLightSizeUVRatio: number;
  17786. /**
  17787. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17788. * Using a ratio helps keeping shape stability independently of the map size.
  17789. *
  17790. * It does not account for the light projection as it was having too much
  17791. * instability during the light setup or during light position changes.
  17792. *
  17793. * Only valid if useContactHardeningShadow is true.
  17794. */
  17795. get contactHardeningLightSizeUVRatio(): number;
  17796. /**
  17797. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17798. * Using a ratio helps keeping shape stability independently of the map size.
  17799. *
  17800. * It does not account for the light projection as it was having too much
  17801. * instability during the light setup or during light position changes.
  17802. *
  17803. * Only valid if useContactHardeningShadow is true.
  17804. */
  17805. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17806. protected _darkness: number;
  17807. /** Gets or sets the actual darkness of a shadow */
  17808. get darkness(): number;
  17809. set darkness(value: number);
  17810. /**
  17811. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17812. * 0 means strongest and 1 would means no shadow.
  17813. * @returns the darkness.
  17814. */
  17815. getDarkness(): number;
  17816. /**
  17817. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17818. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17819. * @returns the shadow generator allowing fluent coding.
  17820. */
  17821. setDarkness(darkness: number): ShadowGenerator;
  17822. protected _transparencyShadow: boolean;
  17823. /** Gets or sets the ability to have transparent shadow */
  17824. get transparencyShadow(): boolean;
  17825. set transparencyShadow(value: boolean);
  17826. /**
  17827. * Sets the ability to have transparent shadow (boolean).
  17828. * @param transparent True if transparent else False
  17829. * @returns the shadow generator allowing fluent coding
  17830. */
  17831. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17832. /**
  17833. * Enables or disables shadows with varying strength based on the transparency
  17834. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17835. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17836. * mesh.visibility * alphaTexture.a
  17837. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17838. */
  17839. enableSoftTransparentShadow: boolean;
  17840. protected _shadowMap: Nullable<RenderTargetTexture>;
  17841. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17842. /**
  17843. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17844. * @returns The render target texture if present otherwise, null
  17845. */
  17846. getShadowMap(): Nullable<RenderTargetTexture>;
  17847. /**
  17848. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17849. * @returns The render target texture if the shadow map is present otherwise, null
  17850. */
  17851. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17852. /**
  17853. * Gets the class name of that object
  17854. * @returns "ShadowGenerator"
  17855. */
  17856. getClassName(): string;
  17857. /**
  17858. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17859. * @param mesh Mesh to add
  17860. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17861. * @returns the Shadow Generator itself
  17862. */
  17863. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17864. /**
  17865. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17866. * @param mesh Mesh to remove
  17867. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17868. * @returns the Shadow Generator itself
  17869. */
  17870. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17871. /**
  17872. * Controls the extent to which the shadows fade out at the edge of the frustum
  17873. */
  17874. frustumEdgeFalloff: number;
  17875. protected _light: IShadowLight;
  17876. /**
  17877. * Returns the associated light object.
  17878. * @returns the light generating the shadow
  17879. */
  17880. getLight(): IShadowLight;
  17881. /**
  17882. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17883. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17884. * It might on the other hand introduce peter panning.
  17885. */
  17886. forceBackFacesOnly: boolean;
  17887. protected _scene: Scene;
  17888. protected _lightDirection: Vector3;
  17889. protected _effect: Effect;
  17890. protected _viewMatrix: Matrix;
  17891. protected _projectionMatrix: Matrix;
  17892. protected _transformMatrix: Matrix;
  17893. protected _cachedPosition: Vector3;
  17894. protected _cachedDirection: Vector3;
  17895. protected _cachedDefines: string;
  17896. protected _currentRenderID: number;
  17897. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17898. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17899. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17900. protected _blurPostProcesses: PostProcess[];
  17901. protected _mapSize: number;
  17902. protected _currentFaceIndex: number;
  17903. protected _currentFaceIndexCache: number;
  17904. protected _textureType: number;
  17905. protected _defaultTextureMatrix: Matrix;
  17906. protected _storedUniqueId: Nullable<number>;
  17907. /** @hidden */
  17908. static _SceneComponentInitialization: (scene: Scene) => void;
  17909. /**
  17910. * Creates a ShadowGenerator object.
  17911. * A ShadowGenerator is the required tool to use the shadows.
  17912. * Each light casting shadows needs to use its own ShadowGenerator.
  17913. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17914. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17915. * @param light The light object generating the shadows.
  17916. * @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.
  17917. */
  17918. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17919. protected _initializeGenerator(): void;
  17920. protected _createTargetRenderTexture(): void;
  17921. protected _initializeShadowMap(): void;
  17922. protected _initializeBlurRTTAndPostProcesses(): void;
  17923. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17924. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17925. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17926. protected _applyFilterValues(): void;
  17927. /**
  17928. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17929. * @param onCompiled Callback triggered at the and of the effects compilation
  17930. * @param options Sets of optional options forcing the compilation with different modes
  17931. */
  17932. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17933. useInstances: boolean;
  17934. }>): void;
  17935. /**
  17936. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17937. * @param options Sets of optional options forcing the compilation with different modes
  17938. * @returns A promise that resolves when the compilation completes
  17939. */
  17940. forceCompilationAsync(options?: Partial<{
  17941. useInstances: boolean;
  17942. }>): Promise<void>;
  17943. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17944. private _prepareShadowDefines;
  17945. /**
  17946. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17947. * @param subMesh The submesh we want to render in the shadow map
  17948. * @param useInstances Defines wether will draw in the map using instances
  17949. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17950. * @returns true if ready otherwise, false
  17951. */
  17952. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17953. /**
  17954. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17955. * @param defines Defines of the material we want to update
  17956. * @param lightIndex Index of the light in the enabled light list of the material
  17957. */
  17958. prepareDefines(defines: any, lightIndex: number): void;
  17959. /**
  17960. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17961. * defined in the generator but impacting the effect).
  17962. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17963. * @param effect The effect we are binfing the information for
  17964. */
  17965. bindShadowLight(lightIndex: string, effect: Effect): void;
  17966. /**
  17967. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17968. * (eq to shadow prjection matrix * light transform matrix)
  17969. * @returns The transform matrix used to create the shadow map
  17970. */
  17971. getTransformMatrix(): Matrix;
  17972. /**
  17973. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17974. * Cube and 2D textures for instance.
  17975. */
  17976. recreateShadowMap(): void;
  17977. protected _disposeBlurPostProcesses(): void;
  17978. protected _disposeRTTandPostProcesses(): void;
  17979. /**
  17980. * Disposes the ShadowGenerator.
  17981. * Returns nothing.
  17982. */
  17983. dispose(): void;
  17984. /**
  17985. * Serializes the shadow generator setup to a json object.
  17986. * @returns The serialized JSON object
  17987. */
  17988. serialize(): any;
  17989. /**
  17990. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17991. * @param parsedShadowGenerator The JSON object to parse
  17992. * @param scene The scene to create the shadow map for
  17993. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17994. * @returns The parsed shadow generator
  17995. */
  17996. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17997. }
  17998. }
  17999. declare module BABYLON {
  18000. /**
  18001. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18002. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18003. * 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.
  18004. */
  18005. export abstract class Light extends Node {
  18006. /**
  18007. * Falloff Default: light is falling off following the material specification:
  18008. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18009. */
  18010. static readonly FALLOFF_DEFAULT: number;
  18011. /**
  18012. * Falloff Physical: light is falling off following the inverse squared distance law.
  18013. */
  18014. static readonly FALLOFF_PHYSICAL: number;
  18015. /**
  18016. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18017. * to enhance interoperability with other engines.
  18018. */
  18019. static readonly FALLOFF_GLTF: number;
  18020. /**
  18021. * Falloff Standard: light is falling off like in the standard material
  18022. * to enhance interoperability with other materials.
  18023. */
  18024. static readonly FALLOFF_STANDARD: number;
  18025. /**
  18026. * If every light affecting the material is in this lightmapMode,
  18027. * material.lightmapTexture adds or multiplies
  18028. * (depends on material.useLightmapAsShadowmap)
  18029. * after every other light calculations.
  18030. */
  18031. static readonly LIGHTMAP_DEFAULT: number;
  18032. /**
  18033. * material.lightmapTexture as only diffuse lighting from this light
  18034. * adds only specular lighting from this light
  18035. * adds dynamic shadows
  18036. */
  18037. static readonly LIGHTMAP_SPECULAR: number;
  18038. /**
  18039. * material.lightmapTexture as only lighting
  18040. * no light calculation from this light
  18041. * only adds dynamic shadows from this light
  18042. */
  18043. static readonly LIGHTMAP_SHADOWSONLY: number;
  18044. /**
  18045. * Each light type uses the default quantity according to its type:
  18046. * point/spot lights use luminous intensity
  18047. * directional lights use illuminance
  18048. */
  18049. static readonly INTENSITYMODE_AUTOMATIC: number;
  18050. /**
  18051. * lumen (lm)
  18052. */
  18053. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18054. /**
  18055. * candela (lm/sr)
  18056. */
  18057. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18058. /**
  18059. * lux (lm/m^2)
  18060. */
  18061. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18062. /**
  18063. * nit (cd/m^2)
  18064. */
  18065. static readonly INTENSITYMODE_LUMINANCE: number;
  18066. /**
  18067. * Light type const id of the point light.
  18068. */
  18069. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18070. /**
  18071. * Light type const id of the directional light.
  18072. */
  18073. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18074. /**
  18075. * Light type const id of the spot light.
  18076. */
  18077. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18078. /**
  18079. * Light type const id of the hemispheric light.
  18080. */
  18081. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18082. /**
  18083. * Diffuse gives the basic color to an object.
  18084. */
  18085. diffuse: Color3;
  18086. /**
  18087. * Specular produces a highlight color on an object.
  18088. * Note: This is note affecting PBR materials.
  18089. */
  18090. specular: Color3;
  18091. /**
  18092. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18093. * falling off base on range or angle.
  18094. * This can be set to any values in Light.FALLOFF_x.
  18095. *
  18096. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18097. * other types of materials.
  18098. */
  18099. falloffType: number;
  18100. /**
  18101. * Strength of the light.
  18102. * Note: By default it is define in the framework own unit.
  18103. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18104. */
  18105. intensity: number;
  18106. private _range;
  18107. protected _inverseSquaredRange: number;
  18108. /**
  18109. * Defines how far from the source the light is impacting in scene units.
  18110. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18111. */
  18112. get range(): number;
  18113. /**
  18114. * Defines how far from the source the light is impacting in scene units.
  18115. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18116. */
  18117. set range(value: number);
  18118. /**
  18119. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18120. * of light.
  18121. */
  18122. private _photometricScale;
  18123. private _intensityMode;
  18124. /**
  18125. * Gets the photometric scale used to interpret the intensity.
  18126. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18127. */
  18128. get intensityMode(): number;
  18129. /**
  18130. * Sets the photometric scale used to interpret the intensity.
  18131. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18132. */
  18133. set intensityMode(value: number);
  18134. private _radius;
  18135. /**
  18136. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18137. */
  18138. get radius(): number;
  18139. /**
  18140. * sets the light radius used by PBR Materials to simulate soft area lights.
  18141. */
  18142. set radius(value: number);
  18143. private _renderPriority;
  18144. /**
  18145. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18146. * exceeding the number allowed of the materials.
  18147. */
  18148. renderPriority: number;
  18149. private _shadowEnabled;
  18150. /**
  18151. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18152. * the current shadow generator.
  18153. */
  18154. get shadowEnabled(): boolean;
  18155. /**
  18156. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18157. * the current shadow generator.
  18158. */
  18159. set shadowEnabled(value: boolean);
  18160. private _includedOnlyMeshes;
  18161. /**
  18162. * Gets the only meshes impacted by this light.
  18163. */
  18164. get includedOnlyMeshes(): AbstractMesh[];
  18165. /**
  18166. * Sets the only meshes impacted by this light.
  18167. */
  18168. set includedOnlyMeshes(value: AbstractMesh[]);
  18169. private _excludedMeshes;
  18170. /**
  18171. * Gets the meshes not impacted by this light.
  18172. */
  18173. get excludedMeshes(): AbstractMesh[];
  18174. /**
  18175. * Sets the meshes not impacted by this light.
  18176. */
  18177. set excludedMeshes(value: AbstractMesh[]);
  18178. private _excludeWithLayerMask;
  18179. /**
  18180. * Gets the layer id use to find what meshes are not impacted by the light.
  18181. * Inactive if 0
  18182. */
  18183. get excludeWithLayerMask(): number;
  18184. /**
  18185. * Sets the layer id use to find what meshes are not impacted by the light.
  18186. * Inactive if 0
  18187. */
  18188. set excludeWithLayerMask(value: number);
  18189. private _includeOnlyWithLayerMask;
  18190. /**
  18191. * Gets the layer id use to find what meshes are impacted by the light.
  18192. * Inactive if 0
  18193. */
  18194. get includeOnlyWithLayerMask(): number;
  18195. /**
  18196. * Sets the layer id use to find what meshes are impacted by the light.
  18197. * Inactive if 0
  18198. */
  18199. set includeOnlyWithLayerMask(value: number);
  18200. private _lightmapMode;
  18201. /**
  18202. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18203. */
  18204. get lightmapMode(): number;
  18205. /**
  18206. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18207. */
  18208. set lightmapMode(value: number);
  18209. /**
  18210. * Shadow generator associted to the light.
  18211. * @hidden Internal use only.
  18212. */
  18213. _shadowGenerator: Nullable<IShadowGenerator>;
  18214. /**
  18215. * @hidden Internal use only.
  18216. */
  18217. _excludedMeshesIds: string[];
  18218. /**
  18219. * @hidden Internal use only.
  18220. */
  18221. _includedOnlyMeshesIds: string[];
  18222. /**
  18223. * The current light unifom buffer.
  18224. * @hidden Internal use only.
  18225. */
  18226. _uniformBuffer: UniformBuffer;
  18227. /** @hidden */
  18228. _renderId: number;
  18229. /**
  18230. * Creates a Light object in the scene.
  18231. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18232. * @param name The firendly name of the light
  18233. * @param scene The scene the light belongs too
  18234. */
  18235. constructor(name: string, scene: Scene);
  18236. protected abstract _buildUniformLayout(): void;
  18237. /**
  18238. * Sets the passed Effect "effect" with the Light information.
  18239. * @param effect The effect to update
  18240. * @param lightIndex The index of the light in the effect to update
  18241. * @returns The light
  18242. */
  18243. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18244. /**
  18245. * Sets the passed Effect "effect" with the Light textures.
  18246. * @param effect The effect to update
  18247. * @param lightIndex The index of the light in the effect to update
  18248. * @returns The light
  18249. */
  18250. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18251. /**
  18252. * Binds the lights information from the scene to the effect for the given mesh.
  18253. * @param lightIndex Light index
  18254. * @param scene The scene where the light belongs to
  18255. * @param effect The effect we are binding the data to
  18256. * @param useSpecular Defines if specular is supported
  18257. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18258. */
  18259. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18260. /**
  18261. * Sets the passed Effect "effect" with the Light information.
  18262. * @param effect The effect to update
  18263. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18264. * @returns The light
  18265. */
  18266. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18267. /**
  18268. * Returns the string "Light".
  18269. * @returns the class name
  18270. */
  18271. getClassName(): string;
  18272. /** @hidden */
  18273. readonly _isLight: boolean;
  18274. /**
  18275. * Converts the light information to a readable string for debug purpose.
  18276. * @param fullDetails Supports for multiple levels of logging within scene loading
  18277. * @returns the human readable light info
  18278. */
  18279. toString(fullDetails?: boolean): string;
  18280. /** @hidden */
  18281. protected _syncParentEnabledState(): void;
  18282. /**
  18283. * Set the enabled state of this node.
  18284. * @param value - the new enabled state
  18285. */
  18286. setEnabled(value: boolean): void;
  18287. /**
  18288. * Returns the Light associated shadow generator if any.
  18289. * @return the associated shadow generator.
  18290. */
  18291. getShadowGenerator(): Nullable<IShadowGenerator>;
  18292. /**
  18293. * Returns a Vector3, the absolute light position in the World.
  18294. * @returns the world space position of the light
  18295. */
  18296. getAbsolutePosition(): Vector3;
  18297. /**
  18298. * Specifies if the light will affect the passed mesh.
  18299. * @param mesh The mesh to test against the light
  18300. * @return true the mesh is affected otherwise, false.
  18301. */
  18302. canAffectMesh(mesh: AbstractMesh): boolean;
  18303. /**
  18304. * Sort function to order lights for rendering.
  18305. * @param a First Light object to compare to second.
  18306. * @param b Second Light object to compare first.
  18307. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18308. */
  18309. static CompareLightsPriority(a: Light, b: Light): number;
  18310. /**
  18311. * Releases resources associated with this node.
  18312. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18313. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18314. */
  18315. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18316. /**
  18317. * Returns the light type ID (integer).
  18318. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18319. */
  18320. getTypeID(): number;
  18321. /**
  18322. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18323. * @returns the scaled intensity in intensity mode unit
  18324. */
  18325. getScaledIntensity(): number;
  18326. /**
  18327. * Returns a new Light object, named "name", from the current one.
  18328. * @param name The name of the cloned light
  18329. * @param newParent The parent of this light, if it has one
  18330. * @returns the new created light
  18331. */
  18332. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18333. /**
  18334. * Serializes the current light into a Serialization object.
  18335. * @returns the serialized object.
  18336. */
  18337. serialize(): any;
  18338. /**
  18339. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18340. * This new light is named "name" and added to the passed scene.
  18341. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18342. * @param name The friendly name of the light
  18343. * @param scene The scene the new light will belong to
  18344. * @returns the constructor function
  18345. */
  18346. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18347. /**
  18348. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18349. * @param parsedLight The JSON representation of the light
  18350. * @param scene The scene to create the parsed light in
  18351. * @returns the created light after parsing
  18352. */
  18353. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18354. private _hookArrayForExcluded;
  18355. private _hookArrayForIncludedOnly;
  18356. private _resyncMeshes;
  18357. /**
  18358. * Forces the meshes to update their light related information in their rendering used effects
  18359. * @hidden Internal Use Only
  18360. */
  18361. _markMeshesAsLightDirty(): void;
  18362. /**
  18363. * Recomputes the cached photometric scale if needed.
  18364. */
  18365. private _computePhotometricScale;
  18366. /**
  18367. * Returns the Photometric Scale according to the light type and intensity mode.
  18368. */
  18369. private _getPhotometricScale;
  18370. /**
  18371. * Reorder the light in the scene according to their defined priority.
  18372. * @hidden Internal Use Only
  18373. */
  18374. _reorderLightsInScene(): void;
  18375. /**
  18376. * Prepares the list of defines specific to the light type.
  18377. * @param defines the list of defines
  18378. * @param lightIndex defines the index of the light for the effect
  18379. */
  18380. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18381. }
  18382. }
  18383. declare module BABYLON {
  18384. /**
  18385. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18386. * This is the base of the follow, arc rotate cameras and Free camera
  18387. * @see https://doc.babylonjs.com/features/cameras
  18388. */
  18389. export class TargetCamera extends Camera {
  18390. private static _RigCamTransformMatrix;
  18391. private static _TargetTransformMatrix;
  18392. private static _TargetFocalPoint;
  18393. private _tmpUpVector;
  18394. private _tmpTargetVector;
  18395. /**
  18396. * Define the current direction the camera is moving to
  18397. */
  18398. cameraDirection: Vector3;
  18399. /**
  18400. * Define the current rotation the camera is rotating to
  18401. */
  18402. cameraRotation: Vector2;
  18403. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18404. ignoreParentScaling: boolean;
  18405. /**
  18406. * When set, the up vector of the camera will be updated by the rotation of the camera
  18407. */
  18408. updateUpVectorFromRotation: boolean;
  18409. private _tmpQuaternion;
  18410. /**
  18411. * Define the current rotation of the camera
  18412. */
  18413. rotation: Vector3;
  18414. /**
  18415. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18416. */
  18417. rotationQuaternion: Quaternion;
  18418. /**
  18419. * Define the current speed of the camera
  18420. */
  18421. speed: number;
  18422. /**
  18423. * Add constraint to the camera to prevent it to move freely in all directions and
  18424. * around all axis.
  18425. */
  18426. noRotationConstraint: boolean;
  18427. /**
  18428. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18429. * panning
  18430. */
  18431. invertRotation: boolean;
  18432. /**
  18433. * Speed multiplier for inverse camera panning
  18434. */
  18435. inverseRotationSpeed: number;
  18436. /**
  18437. * Define the current target of the camera as an object or a position.
  18438. */
  18439. lockedTarget: any;
  18440. /** @hidden */
  18441. _currentTarget: Vector3;
  18442. /** @hidden */
  18443. _initialFocalDistance: number;
  18444. /** @hidden */
  18445. _viewMatrix: Matrix;
  18446. /** @hidden */
  18447. _camMatrix: Matrix;
  18448. /** @hidden */
  18449. _cameraTransformMatrix: Matrix;
  18450. /** @hidden */
  18451. _cameraRotationMatrix: Matrix;
  18452. /** @hidden */
  18453. _referencePoint: Vector3;
  18454. /** @hidden */
  18455. _transformedReferencePoint: Vector3;
  18456. /** @hidden */
  18457. _reset: () => void;
  18458. private _defaultUp;
  18459. /**
  18460. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18461. * This is the base of the follow, arc rotate cameras and Free camera
  18462. * @see https://doc.babylonjs.com/features/cameras
  18463. * @param name Defines the name of the camera in the scene
  18464. * @param position Defines the start position of the camera in the scene
  18465. * @param scene Defines the scene the camera belongs to
  18466. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18467. */
  18468. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18469. /**
  18470. * Gets the position in front of the camera at a given distance.
  18471. * @param distance The distance from the camera we want the position to be
  18472. * @returns the position
  18473. */
  18474. getFrontPosition(distance: number): Vector3;
  18475. /** @hidden */
  18476. _getLockedTargetPosition(): Nullable<Vector3>;
  18477. private _storedPosition;
  18478. private _storedRotation;
  18479. private _storedRotationQuaternion;
  18480. /**
  18481. * Store current camera state of the camera (fov, position, rotation, etc..)
  18482. * @returns the camera
  18483. */
  18484. storeState(): Camera;
  18485. /**
  18486. * Restored camera state. You must call storeState() first
  18487. * @returns whether it was successful or not
  18488. * @hidden
  18489. */
  18490. _restoreStateValues(): boolean;
  18491. /** @hidden */
  18492. _initCache(): void;
  18493. /** @hidden */
  18494. _updateCache(ignoreParentClass?: boolean): void;
  18495. /** @hidden */
  18496. _isSynchronizedViewMatrix(): boolean;
  18497. /** @hidden */
  18498. _computeLocalCameraSpeed(): number;
  18499. /**
  18500. * Defines the target the camera should look at.
  18501. * @param target Defines the new target as a Vector or a mesh
  18502. */
  18503. setTarget(target: Vector3): void;
  18504. /**
  18505. * Defines the target point of the camera.
  18506. * The camera looks towards it form the radius distance.
  18507. */
  18508. get target(): Vector3;
  18509. set target(value: Vector3);
  18510. /**
  18511. * Return the current target position of the camera. This value is expressed in local space.
  18512. * @returns the target position
  18513. */
  18514. getTarget(): Vector3;
  18515. /** @hidden */
  18516. _decideIfNeedsToMove(): boolean;
  18517. /** @hidden */
  18518. _updatePosition(): void;
  18519. /** @hidden */
  18520. _checkInputs(): void;
  18521. protected _updateCameraRotationMatrix(): void;
  18522. /**
  18523. * 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)
  18524. * @returns the current camera
  18525. */
  18526. private _rotateUpVectorWithCameraRotationMatrix;
  18527. private _cachedRotationZ;
  18528. private _cachedQuaternionRotationZ;
  18529. /** @hidden */
  18530. _getViewMatrix(): Matrix;
  18531. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18532. /**
  18533. * @hidden
  18534. */
  18535. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18536. /**
  18537. * @hidden
  18538. */
  18539. _updateRigCameras(): void;
  18540. private _getRigCamPositionAndTarget;
  18541. /**
  18542. * Gets the current object class name.
  18543. * @return the class name
  18544. */
  18545. getClassName(): string;
  18546. }
  18547. }
  18548. declare module BABYLON {
  18549. /**
  18550. * Gather the list of keyboard event types as constants.
  18551. */
  18552. export class KeyboardEventTypes {
  18553. /**
  18554. * The keydown event is fired when a key becomes active (pressed).
  18555. */
  18556. static readonly KEYDOWN: number;
  18557. /**
  18558. * The keyup event is fired when a key has been released.
  18559. */
  18560. static readonly KEYUP: number;
  18561. }
  18562. /**
  18563. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18564. */
  18565. export class KeyboardInfo {
  18566. /**
  18567. * Defines the type of event (KeyboardEventTypes)
  18568. */
  18569. type: number;
  18570. /**
  18571. * Defines the related dom event
  18572. */
  18573. event: KeyboardEvent;
  18574. /**
  18575. * Instantiates a new keyboard info.
  18576. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18577. * @param type Defines the type of event (KeyboardEventTypes)
  18578. * @param event Defines the related dom event
  18579. */
  18580. constructor(
  18581. /**
  18582. * Defines the type of event (KeyboardEventTypes)
  18583. */
  18584. type: number,
  18585. /**
  18586. * Defines the related dom event
  18587. */
  18588. event: KeyboardEvent);
  18589. }
  18590. /**
  18591. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18592. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18593. */
  18594. export class KeyboardInfoPre extends KeyboardInfo {
  18595. /**
  18596. * Defines the type of event (KeyboardEventTypes)
  18597. */
  18598. type: number;
  18599. /**
  18600. * Defines the related dom event
  18601. */
  18602. event: KeyboardEvent;
  18603. /**
  18604. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18605. */
  18606. skipOnPointerObservable: boolean;
  18607. /**
  18608. * Instantiates a new keyboard pre info.
  18609. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18610. * @param type Defines the type of event (KeyboardEventTypes)
  18611. * @param event Defines the related dom event
  18612. */
  18613. constructor(
  18614. /**
  18615. * Defines the type of event (KeyboardEventTypes)
  18616. */
  18617. type: number,
  18618. /**
  18619. * Defines the related dom event
  18620. */
  18621. event: KeyboardEvent);
  18622. }
  18623. }
  18624. declare module BABYLON {
  18625. /**
  18626. * Manage the keyboard inputs to control the movement of a free camera.
  18627. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18628. */
  18629. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18630. /**
  18631. * Defines the camera the input is attached to.
  18632. */
  18633. camera: FreeCamera;
  18634. /**
  18635. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18636. */
  18637. keysUp: number[];
  18638. /**
  18639. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18640. */
  18641. keysUpward: number[];
  18642. /**
  18643. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18644. */
  18645. keysDown: number[];
  18646. /**
  18647. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18648. */
  18649. keysDownward: number[];
  18650. /**
  18651. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18652. */
  18653. keysLeft: number[];
  18654. /**
  18655. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18656. */
  18657. keysRight: number[];
  18658. private _keys;
  18659. private _onCanvasBlurObserver;
  18660. private _onKeyboardObserver;
  18661. private _engine;
  18662. private _scene;
  18663. /**
  18664. * Attach the input controls to a specific dom element to get the input from.
  18665. * @param element Defines the element the controls should be listened from
  18666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18667. */
  18668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18669. /**
  18670. * Detach the current controls from the specified dom element.
  18671. * @param element Defines the element to stop listening the inputs from
  18672. */
  18673. detachControl(element: Nullable<HTMLElement>): void;
  18674. /**
  18675. * Update the current camera state depending on the inputs that have been used this frame.
  18676. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18677. */
  18678. checkInputs(): void;
  18679. /**
  18680. * Gets the class name of the current intput.
  18681. * @returns the class name
  18682. */
  18683. getClassName(): string;
  18684. /** @hidden */
  18685. _onLostFocus(): void;
  18686. /**
  18687. * Get the friendly name associated with the input class.
  18688. * @returns the input friendly name
  18689. */
  18690. getSimpleName(): string;
  18691. }
  18692. }
  18693. declare module BABYLON {
  18694. /**
  18695. * Gather the list of pointer event types as constants.
  18696. */
  18697. export class PointerEventTypes {
  18698. /**
  18699. * 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.
  18700. */
  18701. static readonly POINTERDOWN: number;
  18702. /**
  18703. * The pointerup event is fired when a pointer is no longer active.
  18704. */
  18705. static readonly POINTERUP: number;
  18706. /**
  18707. * The pointermove event is fired when a pointer changes coordinates.
  18708. */
  18709. static readonly POINTERMOVE: number;
  18710. /**
  18711. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18712. */
  18713. static readonly POINTERWHEEL: number;
  18714. /**
  18715. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18716. */
  18717. static readonly POINTERPICK: number;
  18718. /**
  18719. * The pointertap event is fired when a the object has been touched and released without drag.
  18720. */
  18721. static readonly POINTERTAP: number;
  18722. /**
  18723. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18724. */
  18725. static readonly POINTERDOUBLETAP: number;
  18726. }
  18727. /**
  18728. * Base class of pointer info types.
  18729. */
  18730. export class PointerInfoBase {
  18731. /**
  18732. * Defines the type of event (PointerEventTypes)
  18733. */
  18734. type: number;
  18735. /**
  18736. * Defines the related dom event
  18737. */
  18738. event: PointerEvent | MouseWheelEvent;
  18739. /**
  18740. * Instantiates the base class of pointers info.
  18741. * @param type Defines the type of event (PointerEventTypes)
  18742. * @param event Defines the related dom event
  18743. */
  18744. constructor(
  18745. /**
  18746. * Defines the type of event (PointerEventTypes)
  18747. */
  18748. type: number,
  18749. /**
  18750. * Defines the related dom event
  18751. */
  18752. event: PointerEvent | MouseWheelEvent);
  18753. }
  18754. /**
  18755. * This class is used to store pointer related info for the onPrePointerObservable event.
  18756. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18757. */
  18758. export class PointerInfoPre extends PointerInfoBase {
  18759. /**
  18760. * Ray from a pointer if availible (eg. 6dof controller)
  18761. */
  18762. ray: Nullable<Ray>;
  18763. /**
  18764. * Defines the local position of the pointer on the canvas.
  18765. */
  18766. localPosition: Vector2;
  18767. /**
  18768. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18769. */
  18770. skipOnPointerObservable: boolean;
  18771. /**
  18772. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18773. * @param type Defines the type of event (PointerEventTypes)
  18774. * @param event Defines the related dom event
  18775. * @param localX Defines the local x coordinates of the pointer when the event occured
  18776. * @param localY Defines the local y coordinates of the pointer when the event occured
  18777. */
  18778. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18779. }
  18780. /**
  18781. * This type contains all the data related to a pointer event in Babylon.js.
  18782. * 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.
  18783. */
  18784. export class PointerInfo extends PointerInfoBase {
  18785. /**
  18786. * Defines the picking info associated to the info (if any)\
  18787. */
  18788. pickInfo: Nullable<PickingInfo>;
  18789. /**
  18790. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18791. * @param type Defines the type of event (PointerEventTypes)
  18792. * @param event Defines the related dom event
  18793. * @param pickInfo Defines the picking info associated to the info (if any)\
  18794. */
  18795. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18796. /**
  18797. * Defines the picking info associated to the info (if any)\
  18798. */
  18799. pickInfo: Nullable<PickingInfo>);
  18800. }
  18801. /**
  18802. * Data relating to a touch event on the screen.
  18803. */
  18804. export interface PointerTouch {
  18805. /**
  18806. * X coordinate of touch.
  18807. */
  18808. x: number;
  18809. /**
  18810. * Y coordinate of touch.
  18811. */
  18812. y: number;
  18813. /**
  18814. * Id of touch. Unique for each finger.
  18815. */
  18816. pointerId: number;
  18817. /**
  18818. * Event type passed from DOM.
  18819. */
  18820. type: any;
  18821. }
  18822. }
  18823. declare module BABYLON {
  18824. /**
  18825. * Manage the mouse inputs to control the movement of a free camera.
  18826. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18827. */
  18828. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18829. /**
  18830. * Define if touch is enabled in the mouse input
  18831. */
  18832. touchEnabled: boolean;
  18833. /**
  18834. * Defines the camera the input is attached to.
  18835. */
  18836. camera: FreeCamera;
  18837. /**
  18838. * Defines the buttons associated with the input to handle camera move.
  18839. */
  18840. buttons: number[];
  18841. /**
  18842. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18843. */
  18844. angularSensibility: number;
  18845. private _pointerInput;
  18846. private _onMouseMove;
  18847. private _observer;
  18848. private previousPosition;
  18849. /**
  18850. * Observable for when a pointer move event occurs containing the move offset
  18851. */
  18852. onPointerMovedObservable: Observable<{
  18853. offsetX: number;
  18854. offsetY: number;
  18855. }>;
  18856. /**
  18857. * @hidden
  18858. * If the camera should be rotated automatically based on pointer movement
  18859. */
  18860. _allowCameraRotation: boolean;
  18861. /**
  18862. * Manage the mouse inputs to control the movement of a free camera.
  18863. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18864. * @param touchEnabled Defines if touch is enabled or not
  18865. */
  18866. constructor(
  18867. /**
  18868. * Define if touch is enabled in the mouse input
  18869. */
  18870. touchEnabled?: boolean);
  18871. /**
  18872. * Attach the input controls to a specific dom element to get the input from.
  18873. * @param element Defines the element the controls should be listened from
  18874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18875. */
  18876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18877. /**
  18878. * Called on JS contextmenu event.
  18879. * Override this method to provide functionality.
  18880. */
  18881. protected onContextMenu(evt: PointerEvent): void;
  18882. /**
  18883. * Detach the current controls from the specified dom element.
  18884. * @param element Defines the element to stop listening the inputs from
  18885. */
  18886. detachControl(element: Nullable<HTMLElement>): void;
  18887. /**
  18888. * Gets the class name of the current intput.
  18889. * @returns the class name
  18890. */
  18891. getClassName(): string;
  18892. /**
  18893. * Get the friendly name associated with the input class.
  18894. * @returns the input friendly name
  18895. */
  18896. getSimpleName(): string;
  18897. }
  18898. }
  18899. declare module BABYLON {
  18900. /**
  18901. * Manage the touch inputs to control the movement of a free camera.
  18902. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18903. */
  18904. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18905. /**
  18906. * Define if mouse events can be treated as touch events
  18907. */
  18908. allowMouse: boolean;
  18909. /**
  18910. * Defines the camera the input is attached to.
  18911. */
  18912. camera: FreeCamera;
  18913. /**
  18914. * Defines the touch sensibility for rotation.
  18915. * The higher the faster.
  18916. */
  18917. touchAngularSensibility: number;
  18918. /**
  18919. * Defines the touch sensibility for move.
  18920. * The higher the faster.
  18921. */
  18922. touchMoveSensibility: number;
  18923. private _offsetX;
  18924. private _offsetY;
  18925. private _pointerPressed;
  18926. private _pointerInput;
  18927. private _observer;
  18928. private _onLostFocus;
  18929. /**
  18930. * Manage the touch inputs to control the movement of a free camera.
  18931. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18932. * @param allowMouse Defines if mouse events can be treated as touch events
  18933. */
  18934. constructor(
  18935. /**
  18936. * Define if mouse events can be treated as touch events
  18937. */
  18938. allowMouse?: boolean);
  18939. /**
  18940. * Attach the input controls to a specific dom element to get the input from.
  18941. * @param element Defines the element the controls should be listened from
  18942. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18943. */
  18944. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18945. /**
  18946. * Detach the current controls from the specified dom element.
  18947. * @param element Defines the element to stop listening the inputs from
  18948. */
  18949. detachControl(element: Nullable<HTMLElement>): void;
  18950. /**
  18951. * Update the current camera state depending on the inputs that have been used this frame.
  18952. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18953. */
  18954. checkInputs(): void;
  18955. /**
  18956. * Gets the class name of the current intput.
  18957. * @returns the class name
  18958. */
  18959. getClassName(): string;
  18960. /**
  18961. * Get the friendly name associated with the input class.
  18962. * @returns the input friendly name
  18963. */
  18964. getSimpleName(): string;
  18965. }
  18966. }
  18967. declare module BABYLON {
  18968. /**
  18969. * Default Inputs manager for the FreeCamera.
  18970. * It groups all the default supported inputs for ease of use.
  18971. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18972. */
  18973. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18974. /**
  18975. * @hidden
  18976. */
  18977. _mouseInput: Nullable<FreeCameraMouseInput>;
  18978. /**
  18979. * Instantiates a new FreeCameraInputsManager.
  18980. * @param camera Defines the camera the inputs belong to
  18981. */
  18982. constructor(camera: FreeCamera);
  18983. /**
  18984. * Add keyboard input support to the input manager.
  18985. * @returns the current input manager
  18986. */
  18987. addKeyboard(): FreeCameraInputsManager;
  18988. /**
  18989. * Add mouse input support to the input manager.
  18990. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18991. * @returns the current input manager
  18992. */
  18993. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18994. /**
  18995. * Removes the mouse input support from the manager
  18996. * @returns the current input manager
  18997. */
  18998. removeMouse(): FreeCameraInputsManager;
  18999. /**
  19000. * Add touch input support to the input manager.
  19001. * @returns the current input manager
  19002. */
  19003. addTouch(): FreeCameraInputsManager;
  19004. /**
  19005. * Remove all attached input methods from a camera
  19006. */
  19007. clear(): void;
  19008. }
  19009. }
  19010. declare module BABYLON {
  19011. /**
  19012. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19013. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19014. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19015. */
  19016. export class FreeCamera extends TargetCamera {
  19017. /**
  19018. * Define the collision ellipsoid of the camera.
  19019. * This is helpful to simulate a camera body like the player body around the camera
  19020. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19021. */
  19022. ellipsoid: Vector3;
  19023. /**
  19024. * Define an offset for the position of the ellipsoid around the camera.
  19025. * This can be helpful to determine the center of the body near the gravity center of the body
  19026. * instead of its head.
  19027. */
  19028. ellipsoidOffset: Vector3;
  19029. /**
  19030. * Enable or disable collisions of the camera with the rest of the scene objects.
  19031. */
  19032. checkCollisions: boolean;
  19033. /**
  19034. * Enable or disable gravity on the camera.
  19035. */
  19036. applyGravity: boolean;
  19037. /**
  19038. * Define the input manager associated to the camera.
  19039. */
  19040. inputs: FreeCameraInputsManager;
  19041. /**
  19042. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19043. * Higher values reduce sensitivity.
  19044. */
  19045. get angularSensibility(): number;
  19046. /**
  19047. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19048. * Higher values reduce sensitivity.
  19049. */
  19050. set angularSensibility(value: number);
  19051. /**
  19052. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19053. */
  19054. get keysUp(): number[];
  19055. set keysUp(value: number[]);
  19056. /**
  19057. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19058. */
  19059. get keysUpward(): number[];
  19060. set keysUpward(value: number[]);
  19061. /**
  19062. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19063. */
  19064. get keysDown(): number[];
  19065. set keysDown(value: number[]);
  19066. /**
  19067. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19068. */
  19069. get keysDownward(): number[];
  19070. set keysDownward(value: number[]);
  19071. /**
  19072. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19073. */
  19074. get keysLeft(): number[];
  19075. set keysLeft(value: number[]);
  19076. /**
  19077. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19078. */
  19079. get keysRight(): number[];
  19080. set keysRight(value: number[]);
  19081. /**
  19082. * Event raised when the camera collide with a mesh in the scene.
  19083. */
  19084. onCollide: (collidedMesh: AbstractMesh) => void;
  19085. private _collider;
  19086. private _needMoveForGravity;
  19087. private _oldPosition;
  19088. private _diffPosition;
  19089. private _newPosition;
  19090. /** @hidden */
  19091. _localDirection: Vector3;
  19092. /** @hidden */
  19093. _transformedDirection: Vector3;
  19094. /**
  19095. * Instantiates a Free Camera.
  19096. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19097. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19098. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19099. * @param name Define the name of the camera in the scene
  19100. * @param position Define the start position of the camera in the scene
  19101. * @param scene Define the scene the camera belongs to
  19102. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19103. */
  19104. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19105. /**
  19106. * Attached controls to the current camera.
  19107. * @param element Defines the element the controls should be listened from
  19108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19109. */
  19110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19111. /**
  19112. * Detach the current controls from the camera.
  19113. * The camera will stop reacting to inputs.
  19114. * @param element Defines the element to stop listening the inputs from
  19115. */
  19116. detachControl(element: HTMLElement): void;
  19117. private _collisionMask;
  19118. /**
  19119. * Define a collision mask to limit the list of object the camera can collide with
  19120. */
  19121. get collisionMask(): number;
  19122. set collisionMask(mask: number);
  19123. /** @hidden */
  19124. _collideWithWorld(displacement: Vector3): void;
  19125. private _onCollisionPositionChange;
  19126. /** @hidden */
  19127. _checkInputs(): void;
  19128. /** @hidden */
  19129. _decideIfNeedsToMove(): boolean;
  19130. /** @hidden */
  19131. _updatePosition(): void;
  19132. /**
  19133. * Destroy the camera and release the current resources hold by it.
  19134. */
  19135. dispose(): void;
  19136. /**
  19137. * Gets the current object class name.
  19138. * @return the class name
  19139. */
  19140. getClassName(): string;
  19141. }
  19142. }
  19143. declare module BABYLON {
  19144. /**
  19145. * Represents a gamepad control stick position
  19146. */
  19147. export class StickValues {
  19148. /**
  19149. * The x component of the control stick
  19150. */
  19151. x: number;
  19152. /**
  19153. * The y component of the control stick
  19154. */
  19155. y: number;
  19156. /**
  19157. * Initializes the gamepad x and y control stick values
  19158. * @param x The x component of the gamepad control stick value
  19159. * @param y The y component of the gamepad control stick value
  19160. */
  19161. constructor(
  19162. /**
  19163. * The x component of the control stick
  19164. */
  19165. x: number,
  19166. /**
  19167. * The y component of the control stick
  19168. */
  19169. y: number);
  19170. }
  19171. /**
  19172. * An interface which manages callbacks for gamepad button changes
  19173. */
  19174. export interface GamepadButtonChanges {
  19175. /**
  19176. * Called when a gamepad has been changed
  19177. */
  19178. changed: boolean;
  19179. /**
  19180. * Called when a gamepad press event has been triggered
  19181. */
  19182. pressChanged: boolean;
  19183. /**
  19184. * Called when a touch event has been triggered
  19185. */
  19186. touchChanged: boolean;
  19187. /**
  19188. * Called when a value has changed
  19189. */
  19190. valueChanged: boolean;
  19191. }
  19192. /**
  19193. * Represents a gamepad
  19194. */
  19195. export class Gamepad {
  19196. /**
  19197. * The id of the gamepad
  19198. */
  19199. id: string;
  19200. /**
  19201. * The index of the gamepad
  19202. */
  19203. index: number;
  19204. /**
  19205. * The browser gamepad
  19206. */
  19207. browserGamepad: any;
  19208. /**
  19209. * Specifies what type of gamepad this represents
  19210. */
  19211. type: number;
  19212. private _leftStick;
  19213. private _rightStick;
  19214. /** @hidden */
  19215. _isConnected: boolean;
  19216. private _leftStickAxisX;
  19217. private _leftStickAxisY;
  19218. private _rightStickAxisX;
  19219. private _rightStickAxisY;
  19220. /**
  19221. * Triggered when the left control stick has been changed
  19222. */
  19223. private _onleftstickchanged;
  19224. /**
  19225. * Triggered when the right control stick has been changed
  19226. */
  19227. private _onrightstickchanged;
  19228. /**
  19229. * Represents a gamepad controller
  19230. */
  19231. static GAMEPAD: number;
  19232. /**
  19233. * Represents a generic controller
  19234. */
  19235. static GENERIC: number;
  19236. /**
  19237. * Represents an XBox controller
  19238. */
  19239. static XBOX: number;
  19240. /**
  19241. * Represents a pose-enabled controller
  19242. */
  19243. static POSE_ENABLED: number;
  19244. /**
  19245. * Represents an Dual Shock controller
  19246. */
  19247. static DUALSHOCK: number;
  19248. /**
  19249. * Specifies whether the left control stick should be Y-inverted
  19250. */
  19251. protected _invertLeftStickY: boolean;
  19252. /**
  19253. * Specifies if the gamepad has been connected
  19254. */
  19255. get isConnected(): boolean;
  19256. /**
  19257. * Initializes the gamepad
  19258. * @param id The id of the gamepad
  19259. * @param index The index of the gamepad
  19260. * @param browserGamepad The browser gamepad
  19261. * @param leftStickX The x component of the left joystick
  19262. * @param leftStickY The y component of the left joystick
  19263. * @param rightStickX The x component of the right joystick
  19264. * @param rightStickY The y component of the right joystick
  19265. */
  19266. constructor(
  19267. /**
  19268. * The id of the gamepad
  19269. */
  19270. id: string,
  19271. /**
  19272. * The index of the gamepad
  19273. */
  19274. index: number,
  19275. /**
  19276. * The browser gamepad
  19277. */
  19278. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19279. /**
  19280. * Callback triggered when the left joystick has changed
  19281. * @param callback
  19282. */
  19283. onleftstickchanged(callback: (values: StickValues) => void): void;
  19284. /**
  19285. * Callback triggered when the right joystick has changed
  19286. * @param callback
  19287. */
  19288. onrightstickchanged(callback: (values: StickValues) => void): void;
  19289. /**
  19290. * Gets the left joystick
  19291. */
  19292. get leftStick(): StickValues;
  19293. /**
  19294. * Sets the left joystick values
  19295. */
  19296. set leftStick(newValues: StickValues);
  19297. /**
  19298. * Gets the right joystick
  19299. */
  19300. get rightStick(): StickValues;
  19301. /**
  19302. * Sets the right joystick value
  19303. */
  19304. set rightStick(newValues: StickValues);
  19305. /**
  19306. * Updates the gamepad joystick positions
  19307. */
  19308. update(): void;
  19309. /**
  19310. * Disposes the gamepad
  19311. */
  19312. dispose(): void;
  19313. }
  19314. /**
  19315. * Represents a generic gamepad
  19316. */
  19317. export class GenericPad extends Gamepad {
  19318. private _buttons;
  19319. private _onbuttondown;
  19320. private _onbuttonup;
  19321. /**
  19322. * Observable triggered when a button has been pressed
  19323. */
  19324. onButtonDownObservable: Observable<number>;
  19325. /**
  19326. * Observable triggered when a button has been released
  19327. */
  19328. onButtonUpObservable: Observable<number>;
  19329. /**
  19330. * Callback triggered when a button has been pressed
  19331. * @param callback Called when a button has been pressed
  19332. */
  19333. onbuttondown(callback: (buttonPressed: number) => void): void;
  19334. /**
  19335. * Callback triggered when a button has been released
  19336. * @param callback Called when a button has been released
  19337. */
  19338. onbuttonup(callback: (buttonReleased: number) => void): void;
  19339. /**
  19340. * Initializes the generic gamepad
  19341. * @param id The id of the generic gamepad
  19342. * @param index The index of the generic gamepad
  19343. * @param browserGamepad The browser gamepad
  19344. */
  19345. constructor(id: string, index: number, browserGamepad: any);
  19346. private _setButtonValue;
  19347. /**
  19348. * Updates the generic gamepad
  19349. */
  19350. update(): void;
  19351. /**
  19352. * Disposes the generic gamepad
  19353. */
  19354. dispose(): void;
  19355. }
  19356. }
  19357. declare module BABYLON {
  19358. /**
  19359. * Defines the types of pose enabled controllers that are supported
  19360. */
  19361. export enum PoseEnabledControllerType {
  19362. /**
  19363. * HTC Vive
  19364. */
  19365. VIVE = 0,
  19366. /**
  19367. * Oculus Rift
  19368. */
  19369. OCULUS = 1,
  19370. /**
  19371. * Windows mixed reality
  19372. */
  19373. WINDOWS = 2,
  19374. /**
  19375. * Samsung gear VR
  19376. */
  19377. GEAR_VR = 3,
  19378. /**
  19379. * Google Daydream
  19380. */
  19381. DAYDREAM = 4,
  19382. /**
  19383. * Generic
  19384. */
  19385. GENERIC = 5
  19386. }
  19387. /**
  19388. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19389. */
  19390. export interface MutableGamepadButton {
  19391. /**
  19392. * Value of the button/trigger
  19393. */
  19394. value: number;
  19395. /**
  19396. * If the button/trigger is currently touched
  19397. */
  19398. touched: boolean;
  19399. /**
  19400. * If the button/trigger is currently pressed
  19401. */
  19402. pressed: boolean;
  19403. }
  19404. /**
  19405. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19406. * @hidden
  19407. */
  19408. export interface ExtendedGamepadButton extends GamepadButton {
  19409. /**
  19410. * If the button/trigger is currently pressed
  19411. */
  19412. readonly pressed: boolean;
  19413. /**
  19414. * If the button/trigger is currently touched
  19415. */
  19416. readonly touched: boolean;
  19417. /**
  19418. * Value of the button/trigger
  19419. */
  19420. readonly value: number;
  19421. }
  19422. /** @hidden */
  19423. export interface _GamePadFactory {
  19424. /**
  19425. * Returns whether or not the current gamepad can be created for this type of controller.
  19426. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19427. * @returns true if it can be created, otherwise false
  19428. */
  19429. canCreate(gamepadInfo: any): boolean;
  19430. /**
  19431. * Creates a new instance of the Gamepad.
  19432. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19433. * @returns the new gamepad instance
  19434. */
  19435. create(gamepadInfo: any): Gamepad;
  19436. }
  19437. /**
  19438. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19439. */
  19440. export class PoseEnabledControllerHelper {
  19441. /** @hidden */
  19442. static _ControllerFactories: _GamePadFactory[];
  19443. /** @hidden */
  19444. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19445. /**
  19446. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19447. * @param vrGamepad the gamepad to initialized
  19448. * @returns a vr controller of the type the gamepad identified as
  19449. */
  19450. static InitiateController(vrGamepad: any): Gamepad;
  19451. }
  19452. /**
  19453. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19454. */
  19455. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19456. /**
  19457. * If the controller is used in a webXR session
  19458. */
  19459. isXR: boolean;
  19460. private _deviceRoomPosition;
  19461. private _deviceRoomRotationQuaternion;
  19462. /**
  19463. * The device position in babylon space
  19464. */
  19465. devicePosition: Vector3;
  19466. /**
  19467. * The device rotation in babylon space
  19468. */
  19469. deviceRotationQuaternion: Quaternion;
  19470. /**
  19471. * The scale factor of the device in babylon space
  19472. */
  19473. deviceScaleFactor: number;
  19474. /**
  19475. * (Likely devicePosition should be used instead) The device position in its room space
  19476. */
  19477. position: Vector3;
  19478. /**
  19479. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19480. */
  19481. rotationQuaternion: Quaternion;
  19482. /**
  19483. * The type of controller (Eg. Windows mixed reality)
  19484. */
  19485. controllerType: PoseEnabledControllerType;
  19486. protected _calculatedPosition: Vector3;
  19487. private _calculatedRotation;
  19488. /**
  19489. * The raw pose from the device
  19490. */
  19491. rawPose: DevicePose;
  19492. private _trackPosition;
  19493. private _maxRotationDistFromHeadset;
  19494. private _draggedRoomRotation;
  19495. /**
  19496. * @hidden
  19497. */
  19498. _disableTrackPosition(fixedPosition: Vector3): void;
  19499. /**
  19500. * Internal, the mesh attached to the controller
  19501. * @hidden
  19502. */
  19503. _mesh: Nullable<AbstractMesh>;
  19504. private _poseControlledCamera;
  19505. private _leftHandSystemQuaternion;
  19506. /**
  19507. * Internal, matrix used to convert room space to babylon space
  19508. * @hidden
  19509. */
  19510. _deviceToWorld: Matrix;
  19511. /**
  19512. * Node to be used when casting a ray from the controller
  19513. * @hidden
  19514. */
  19515. _pointingPoseNode: Nullable<TransformNode>;
  19516. /**
  19517. * Name of the child mesh that can be used to cast a ray from the controller
  19518. */
  19519. static readonly POINTING_POSE: string;
  19520. /**
  19521. * Creates a new PoseEnabledController from a gamepad
  19522. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19523. */
  19524. constructor(browserGamepad: any);
  19525. private _workingMatrix;
  19526. /**
  19527. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19528. */
  19529. update(): void;
  19530. /**
  19531. * Updates only the pose device and mesh without doing any button event checking
  19532. */
  19533. protected _updatePoseAndMesh(): void;
  19534. /**
  19535. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19536. * @param poseData raw pose fromthe device
  19537. */
  19538. updateFromDevice(poseData: DevicePose): void;
  19539. /**
  19540. * @hidden
  19541. */
  19542. _meshAttachedObservable: Observable<AbstractMesh>;
  19543. /**
  19544. * Attaches a mesh to the controller
  19545. * @param mesh the mesh to be attached
  19546. */
  19547. attachToMesh(mesh: AbstractMesh): void;
  19548. /**
  19549. * Attaches the controllers mesh to a camera
  19550. * @param camera the camera the mesh should be attached to
  19551. */
  19552. attachToPoseControlledCamera(camera: TargetCamera): void;
  19553. /**
  19554. * Disposes of the controller
  19555. */
  19556. dispose(): void;
  19557. /**
  19558. * The mesh that is attached to the controller
  19559. */
  19560. get mesh(): Nullable<AbstractMesh>;
  19561. /**
  19562. * Gets the ray of the controller in the direction the controller is pointing
  19563. * @param length the length the resulting ray should be
  19564. * @returns a ray in the direction the controller is pointing
  19565. */
  19566. getForwardRay(length?: number): Ray;
  19567. }
  19568. }
  19569. declare module BABYLON {
  19570. /**
  19571. * Defines the WebVRController object that represents controllers tracked in 3D space
  19572. */
  19573. export abstract class WebVRController extends PoseEnabledController {
  19574. /**
  19575. * Internal, the default controller model for the controller
  19576. */
  19577. protected _defaultModel: Nullable<AbstractMesh>;
  19578. /**
  19579. * Fired when the trigger state has changed
  19580. */
  19581. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19582. /**
  19583. * Fired when the main button state has changed
  19584. */
  19585. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19586. /**
  19587. * Fired when the secondary button state has changed
  19588. */
  19589. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19590. /**
  19591. * Fired when the pad state has changed
  19592. */
  19593. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19594. /**
  19595. * Fired when controllers stick values have changed
  19596. */
  19597. onPadValuesChangedObservable: Observable<StickValues>;
  19598. /**
  19599. * Array of button availible on the controller
  19600. */
  19601. protected _buttons: Array<MutableGamepadButton>;
  19602. private _onButtonStateChange;
  19603. /**
  19604. * Fired when a controller button's state has changed
  19605. * @param callback the callback containing the button that was modified
  19606. */
  19607. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19608. /**
  19609. * X and Y axis corresponding to the controllers joystick
  19610. */
  19611. pad: StickValues;
  19612. /**
  19613. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19614. */
  19615. hand: string;
  19616. /**
  19617. * The default controller model for the controller
  19618. */
  19619. get defaultModel(): Nullable<AbstractMesh>;
  19620. /**
  19621. * Creates a new WebVRController from a gamepad
  19622. * @param vrGamepad the gamepad that the WebVRController should be created from
  19623. */
  19624. constructor(vrGamepad: any);
  19625. /**
  19626. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19627. */
  19628. update(): void;
  19629. /**
  19630. * Function to be called when a button is modified
  19631. */
  19632. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19633. /**
  19634. * Loads a mesh and attaches it to the controller
  19635. * @param scene the scene the mesh should be added to
  19636. * @param meshLoaded callback for when the mesh has been loaded
  19637. */
  19638. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19639. private _setButtonValue;
  19640. private _changes;
  19641. private _checkChanges;
  19642. /**
  19643. * Disposes of th webVRCOntroller
  19644. */
  19645. dispose(): void;
  19646. }
  19647. }
  19648. declare module BABYLON {
  19649. /**
  19650. * The HemisphericLight simulates the ambient environment light,
  19651. * so the passed direction is the light reflection direction, not the incoming direction.
  19652. */
  19653. export class HemisphericLight extends Light {
  19654. /**
  19655. * The groundColor is the light in the opposite direction to the one specified during creation.
  19656. * 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.
  19657. */
  19658. groundColor: Color3;
  19659. /**
  19660. * The light reflection direction, not the incoming direction.
  19661. */
  19662. direction: Vector3;
  19663. /**
  19664. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19665. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19666. * The HemisphericLight can't cast shadows.
  19667. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19668. * @param name The friendly name of the light
  19669. * @param direction The direction of the light reflection
  19670. * @param scene The scene the light belongs to
  19671. */
  19672. constructor(name: string, direction: Vector3, scene: Scene);
  19673. protected _buildUniformLayout(): void;
  19674. /**
  19675. * Returns the string "HemisphericLight".
  19676. * @return The class name
  19677. */
  19678. getClassName(): string;
  19679. /**
  19680. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19681. * Returns the updated direction.
  19682. * @param target The target the direction should point to
  19683. * @return The computed direction
  19684. */
  19685. setDirectionToTarget(target: Vector3): Vector3;
  19686. /**
  19687. * Returns the shadow generator associated to the light.
  19688. * @returns Always null for hemispheric lights because it does not support shadows.
  19689. */
  19690. getShadowGenerator(): Nullable<IShadowGenerator>;
  19691. /**
  19692. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19693. * @param effect The effect to update
  19694. * @param lightIndex The index of the light in the effect to update
  19695. * @returns The hemispheric light
  19696. */
  19697. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19698. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19699. /**
  19700. * Computes the world matrix of the node
  19701. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19702. * @param useWasUpdatedFlag defines a reserved property
  19703. * @returns the world matrix
  19704. */
  19705. computeWorldMatrix(): Matrix;
  19706. /**
  19707. * Returns the integer 3.
  19708. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19709. */
  19710. getTypeID(): number;
  19711. /**
  19712. * Prepares the list of defines specific to the light type.
  19713. * @param defines the list of defines
  19714. * @param lightIndex defines the index of the light for the effect
  19715. */
  19716. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19717. }
  19718. }
  19719. declare module BABYLON {
  19720. /** @hidden */
  19721. export var vrMultiviewToSingleviewPixelShader: {
  19722. name: string;
  19723. shader: string;
  19724. };
  19725. }
  19726. declare module BABYLON {
  19727. /**
  19728. * Renders to multiple views with a single draw call
  19729. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19730. */
  19731. export class MultiviewRenderTarget extends RenderTargetTexture {
  19732. /**
  19733. * Creates a multiview render target
  19734. * @param scene scene used with the render target
  19735. * @param size the size of the render target (used for each view)
  19736. */
  19737. constructor(scene: Scene, size?: number | {
  19738. width: number;
  19739. height: number;
  19740. } | {
  19741. ratio: number;
  19742. });
  19743. /**
  19744. * @hidden
  19745. * @param faceIndex the face index, if its a cube texture
  19746. */
  19747. _bindFrameBuffer(faceIndex?: number): void;
  19748. /**
  19749. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19750. * @returns the view count
  19751. */
  19752. getViewCount(): number;
  19753. }
  19754. }
  19755. declare module BABYLON {
  19756. interface Engine {
  19757. /**
  19758. * Creates a new multiview render target
  19759. * @param width defines the width of the texture
  19760. * @param height defines the height of the texture
  19761. * @returns the created multiview texture
  19762. */
  19763. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19764. /**
  19765. * Binds a multiview framebuffer to be drawn to
  19766. * @param multiviewTexture texture to bind
  19767. */
  19768. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19769. }
  19770. interface Camera {
  19771. /**
  19772. * @hidden
  19773. * 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)
  19774. */
  19775. _useMultiviewToSingleView: boolean;
  19776. /**
  19777. * @hidden
  19778. * 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)
  19779. */
  19780. _multiviewTexture: Nullable<RenderTargetTexture>;
  19781. /**
  19782. * @hidden
  19783. * ensures the multiview texture of the camera exists and has the specified width/height
  19784. * @param width height to set on the multiview texture
  19785. * @param height width to set on the multiview texture
  19786. */
  19787. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19788. }
  19789. interface Scene {
  19790. /** @hidden */
  19791. _transformMatrixR: Matrix;
  19792. /** @hidden */
  19793. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19794. /** @hidden */
  19795. _createMultiviewUbo(): void;
  19796. /** @hidden */
  19797. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19798. /** @hidden */
  19799. _renderMultiviewToSingleView(camera: Camera): void;
  19800. }
  19801. }
  19802. declare module BABYLON {
  19803. /**
  19804. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19805. * This will not be used for webXR as it supports displaying texture arrays directly
  19806. */
  19807. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19808. /**
  19809. * Gets a string identifying the name of the class
  19810. * @returns "VRMultiviewToSingleviewPostProcess" string
  19811. */
  19812. getClassName(): string;
  19813. /**
  19814. * Initializes a VRMultiviewToSingleview
  19815. * @param name name of the post process
  19816. * @param camera camera to be applied to
  19817. * @param scaleFactor scaling factor to the size of the output texture
  19818. */
  19819. constructor(name: string, camera: Camera, scaleFactor: number);
  19820. }
  19821. }
  19822. declare module BABYLON {
  19823. /**
  19824. * Interface used to define additional presentation attributes
  19825. */
  19826. export interface IVRPresentationAttributes {
  19827. /**
  19828. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19829. */
  19830. highRefreshRate: boolean;
  19831. /**
  19832. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19833. */
  19834. foveationLevel: number;
  19835. }
  19836. interface Engine {
  19837. /** @hidden */
  19838. _vrDisplay: any;
  19839. /** @hidden */
  19840. _vrSupported: boolean;
  19841. /** @hidden */
  19842. _oldSize: Size;
  19843. /** @hidden */
  19844. _oldHardwareScaleFactor: number;
  19845. /** @hidden */
  19846. _vrExclusivePointerMode: boolean;
  19847. /** @hidden */
  19848. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19849. /** @hidden */
  19850. _onVRDisplayPointerRestricted: () => void;
  19851. /** @hidden */
  19852. _onVRDisplayPointerUnrestricted: () => void;
  19853. /** @hidden */
  19854. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19855. /** @hidden */
  19856. _onVrDisplayDisconnect: Nullable<() => void>;
  19857. /** @hidden */
  19858. _onVrDisplayPresentChange: Nullable<() => void>;
  19859. /**
  19860. * Observable signaled when VR display mode changes
  19861. */
  19862. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19863. /**
  19864. * Observable signaled when VR request present is complete
  19865. */
  19866. onVRRequestPresentComplete: Observable<boolean>;
  19867. /**
  19868. * Observable signaled when VR request present starts
  19869. */
  19870. onVRRequestPresentStart: Observable<Engine>;
  19871. /**
  19872. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19873. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19874. */
  19875. isInVRExclusivePointerMode: boolean;
  19876. /**
  19877. * Gets a boolean indicating if a webVR device was detected
  19878. * @returns true if a webVR device was detected
  19879. */
  19880. isVRDevicePresent(): boolean;
  19881. /**
  19882. * Gets the current webVR device
  19883. * @returns the current webVR device (or null)
  19884. */
  19885. getVRDevice(): any;
  19886. /**
  19887. * Initializes a webVR display and starts listening to display change events
  19888. * The onVRDisplayChangedObservable will be notified upon these changes
  19889. * @returns A promise containing a VRDisplay and if vr is supported
  19890. */
  19891. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19892. /** @hidden */
  19893. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19894. /**
  19895. * Gets or sets the presentation attributes used to configure VR rendering
  19896. */
  19897. vrPresentationAttributes?: IVRPresentationAttributes;
  19898. /**
  19899. * Call this function to switch to webVR mode
  19900. * Will do nothing if webVR is not supported or if there is no webVR device
  19901. * @param options the webvr options provided to the camera. mainly used for multiview
  19902. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19903. */
  19904. enableVR(options: WebVROptions): void;
  19905. /** @hidden */
  19906. _onVRFullScreenTriggered(): void;
  19907. }
  19908. }
  19909. declare module BABYLON {
  19910. /**
  19911. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19912. * IMPORTANT!! The data is right-hand data.
  19913. * @export
  19914. * @interface DevicePose
  19915. */
  19916. export interface DevicePose {
  19917. /**
  19918. * The position of the device, values in array are [x,y,z].
  19919. */
  19920. readonly position: Nullable<Float32Array>;
  19921. /**
  19922. * The linearVelocity of the device, values in array are [x,y,z].
  19923. */
  19924. readonly linearVelocity: Nullable<Float32Array>;
  19925. /**
  19926. * The linearAcceleration of the device, values in array are [x,y,z].
  19927. */
  19928. readonly linearAcceleration: Nullable<Float32Array>;
  19929. /**
  19930. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19931. */
  19932. readonly orientation: Nullable<Float32Array>;
  19933. /**
  19934. * The angularVelocity of the device, values in array are [x,y,z].
  19935. */
  19936. readonly angularVelocity: Nullable<Float32Array>;
  19937. /**
  19938. * The angularAcceleration of the device, values in array are [x,y,z].
  19939. */
  19940. readonly angularAcceleration: Nullable<Float32Array>;
  19941. }
  19942. /**
  19943. * Interface representing a pose controlled object in Babylon.
  19944. * A pose controlled object has both regular pose values as well as pose values
  19945. * from an external device such as a VR head mounted display
  19946. */
  19947. export interface PoseControlled {
  19948. /**
  19949. * The position of the object in babylon space.
  19950. */
  19951. position: Vector3;
  19952. /**
  19953. * The rotation quaternion of the object in babylon space.
  19954. */
  19955. rotationQuaternion: Quaternion;
  19956. /**
  19957. * The position of the device in babylon space.
  19958. */
  19959. devicePosition?: Vector3;
  19960. /**
  19961. * The rotation quaternion of the device in babylon space.
  19962. */
  19963. deviceRotationQuaternion: Quaternion;
  19964. /**
  19965. * The raw pose coming from the device.
  19966. */
  19967. rawPose: Nullable<DevicePose>;
  19968. /**
  19969. * The scale of the device to be used when translating from device space to babylon space.
  19970. */
  19971. deviceScaleFactor: number;
  19972. /**
  19973. * Updates the poseControlled values based on the input device pose.
  19974. * @param poseData the pose data to update the object with
  19975. */
  19976. updateFromDevice(poseData: DevicePose): void;
  19977. }
  19978. /**
  19979. * Set of options to customize the webVRCamera
  19980. */
  19981. export interface WebVROptions {
  19982. /**
  19983. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19984. */
  19985. trackPosition?: boolean;
  19986. /**
  19987. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19988. */
  19989. positionScale?: number;
  19990. /**
  19991. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19992. */
  19993. displayName?: string;
  19994. /**
  19995. * Should the native controller meshes be initialized. (default: true)
  19996. */
  19997. controllerMeshes?: boolean;
  19998. /**
  19999. * Creating a default HemiLight only on controllers. (default: true)
  20000. */
  20001. defaultLightingOnControllers?: boolean;
  20002. /**
  20003. * If you don't want to use the default VR button of the helper. (default: false)
  20004. */
  20005. useCustomVRButton?: boolean;
  20006. /**
  20007. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20008. */
  20009. customVRButton?: HTMLButtonElement;
  20010. /**
  20011. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20012. */
  20013. rayLength?: number;
  20014. /**
  20015. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20016. */
  20017. defaultHeight?: number;
  20018. /**
  20019. * If multiview should be used if availible (default: false)
  20020. */
  20021. useMultiview?: boolean;
  20022. }
  20023. /**
  20024. * This represents a WebVR camera.
  20025. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20026. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20027. */
  20028. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20029. private webVROptions;
  20030. /**
  20031. * @hidden
  20032. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20033. */
  20034. _vrDevice: any;
  20035. /**
  20036. * The rawPose of the vrDevice.
  20037. */
  20038. rawPose: Nullable<DevicePose>;
  20039. private _onVREnabled;
  20040. private _specsVersion;
  20041. private _attached;
  20042. private _frameData;
  20043. protected _descendants: Array<Node>;
  20044. private _deviceRoomPosition;
  20045. /** @hidden */
  20046. _deviceRoomRotationQuaternion: Quaternion;
  20047. private _standingMatrix;
  20048. /**
  20049. * Represents device position in babylon space.
  20050. */
  20051. devicePosition: Vector3;
  20052. /**
  20053. * Represents device rotation in babylon space.
  20054. */
  20055. deviceRotationQuaternion: Quaternion;
  20056. /**
  20057. * The scale of the device to be used when translating from device space to babylon space.
  20058. */
  20059. deviceScaleFactor: number;
  20060. private _deviceToWorld;
  20061. private _worldToDevice;
  20062. /**
  20063. * References to the webVR controllers for the vrDevice.
  20064. */
  20065. controllers: Array<WebVRController>;
  20066. /**
  20067. * Emits an event when a controller is attached.
  20068. */
  20069. onControllersAttachedObservable: Observable<WebVRController[]>;
  20070. /**
  20071. * Emits an event when a controller's mesh has been loaded;
  20072. */
  20073. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20074. /**
  20075. * Emits an event when the HMD's pose has been updated.
  20076. */
  20077. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20078. private _poseSet;
  20079. /**
  20080. * If the rig cameras be used as parent instead of this camera.
  20081. */
  20082. rigParenting: boolean;
  20083. private _lightOnControllers;
  20084. private _defaultHeight?;
  20085. /**
  20086. * Instantiates a WebVRFreeCamera.
  20087. * @param name The name of the WebVRFreeCamera
  20088. * @param position The starting anchor position for the camera
  20089. * @param scene The scene the camera belongs to
  20090. * @param webVROptions a set of customizable options for the webVRCamera
  20091. */
  20092. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20093. /**
  20094. * Gets the device distance from the ground in meters.
  20095. * @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.
  20096. */
  20097. deviceDistanceToRoomGround(): number;
  20098. /**
  20099. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20100. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20101. */
  20102. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20103. /**
  20104. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20105. * @returns A promise with a boolean set to if the standing matrix is supported.
  20106. */
  20107. useStandingMatrixAsync(): Promise<boolean>;
  20108. /**
  20109. * Disposes the camera
  20110. */
  20111. dispose(): void;
  20112. /**
  20113. * Gets a vrController by name.
  20114. * @param name The name of the controller to retreive
  20115. * @returns the controller matching the name specified or null if not found
  20116. */
  20117. getControllerByName(name: string): Nullable<WebVRController>;
  20118. private _leftController;
  20119. /**
  20120. * The controller corresponding to the users left hand.
  20121. */
  20122. get leftController(): Nullable<WebVRController>;
  20123. private _rightController;
  20124. /**
  20125. * The controller corresponding to the users right hand.
  20126. */
  20127. get rightController(): Nullable<WebVRController>;
  20128. /**
  20129. * Casts a ray forward from the vrCamera's gaze.
  20130. * @param length Length of the ray (default: 100)
  20131. * @returns the ray corresponding to the gaze
  20132. */
  20133. getForwardRay(length?: number): Ray;
  20134. /**
  20135. * @hidden
  20136. * Updates the camera based on device's frame data
  20137. */
  20138. _checkInputs(): void;
  20139. /**
  20140. * Updates the poseControlled values based on the input device pose.
  20141. * @param poseData Pose coming from the device
  20142. */
  20143. updateFromDevice(poseData: DevicePose): void;
  20144. private _htmlElementAttached;
  20145. private _detachIfAttached;
  20146. /**
  20147. * WebVR's attach control will start broadcasting frames to the device.
  20148. * Note that in certain browsers (chrome for example) this function must be called
  20149. * within a user-interaction callback. Example:
  20150. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20151. *
  20152. * @param element html element to attach the vrDevice to
  20153. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20154. */
  20155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20156. /**
  20157. * Detaches the camera from the html element and disables VR
  20158. *
  20159. * @param element html element to detach from
  20160. */
  20161. detachControl(element: HTMLElement): void;
  20162. /**
  20163. * @returns the name of this class
  20164. */
  20165. getClassName(): string;
  20166. /**
  20167. * Calls resetPose on the vrDisplay
  20168. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20169. */
  20170. resetToCurrentRotation(): void;
  20171. /**
  20172. * @hidden
  20173. * Updates the rig cameras (left and right eye)
  20174. */
  20175. _updateRigCameras(): void;
  20176. private _workingVector;
  20177. private _oneVector;
  20178. private _workingMatrix;
  20179. private updateCacheCalled;
  20180. private _correctPositionIfNotTrackPosition;
  20181. /**
  20182. * @hidden
  20183. * Updates the cached values of the camera
  20184. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20185. */
  20186. _updateCache(ignoreParentClass?: boolean): void;
  20187. /**
  20188. * @hidden
  20189. * Get current device position in babylon world
  20190. */
  20191. _computeDevicePosition(): void;
  20192. /**
  20193. * Updates the current device position and rotation in the babylon world
  20194. */
  20195. update(): void;
  20196. /**
  20197. * @hidden
  20198. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20199. * @returns an identity matrix
  20200. */
  20201. _getViewMatrix(): Matrix;
  20202. private _tmpMatrix;
  20203. /**
  20204. * This function is called by the two RIG cameras.
  20205. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20206. * @hidden
  20207. */
  20208. _getWebVRViewMatrix(): Matrix;
  20209. /** @hidden */
  20210. _getWebVRProjectionMatrix(): Matrix;
  20211. private _onGamepadConnectedObserver;
  20212. private _onGamepadDisconnectedObserver;
  20213. private _updateCacheWhenTrackingDisabledObserver;
  20214. /**
  20215. * Initializes the controllers and their meshes
  20216. */
  20217. initControllers(): void;
  20218. }
  20219. }
  20220. declare module BABYLON {
  20221. /**
  20222. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20223. *
  20224. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20225. *
  20226. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20227. */
  20228. export class MaterialHelper {
  20229. /**
  20230. * Bind the current view position to an effect.
  20231. * @param effect The effect to be bound
  20232. * @param scene The scene the eyes position is used from
  20233. * @param variableName name of the shader variable that will hold the eye position
  20234. */
  20235. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20236. /**
  20237. * Helps preparing the defines values about the UVs in used in the effect.
  20238. * UVs are shared as much as we can accross channels in the shaders.
  20239. * @param texture The texture we are preparing the UVs for
  20240. * @param defines The defines to update
  20241. * @param key The channel key "diffuse", "specular"... used in the shader
  20242. */
  20243. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20244. /**
  20245. * Binds a texture matrix value to its corrsponding uniform
  20246. * @param texture The texture to bind the matrix for
  20247. * @param uniformBuffer The uniform buffer receivin the data
  20248. * @param key The channel key "diffuse", "specular"... used in the shader
  20249. */
  20250. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20251. /**
  20252. * Gets the current status of the fog (should it be enabled?)
  20253. * @param mesh defines the mesh to evaluate for fog support
  20254. * @param scene defines the hosting scene
  20255. * @returns true if fog must be enabled
  20256. */
  20257. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20258. /**
  20259. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20260. * @param mesh defines the current mesh
  20261. * @param scene defines the current scene
  20262. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20263. * @param pointsCloud defines if point cloud rendering has to be turned on
  20264. * @param fogEnabled defines if fog has to be turned on
  20265. * @param alphaTest defines if alpha testing has to be turned on
  20266. * @param defines defines the current list of defines
  20267. */
  20268. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20269. /**
  20270. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20271. * @param scene defines the current scene
  20272. * @param engine defines the current engine
  20273. * @param defines specifies the list of active defines
  20274. * @param useInstances defines if instances have to be turned on
  20275. * @param useClipPlane defines if clip plane have to be turned on
  20276. * @param useInstances defines if instances have to be turned on
  20277. * @param useThinInstances defines if thin instances have to be turned on
  20278. */
  20279. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20280. /**
  20281. * Prepares the defines for bones
  20282. * @param mesh The mesh containing the geometry data we will draw
  20283. * @param defines The defines to update
  20284. */
  20285. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20286. /**
  20287. * Prepares the defines for morph targets
  20288. * @param mesh The mesh containing the geometry data we will draw
  20289. * @param defines The defines to update
  20290. */
  20291. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20292. /**
  20293. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20294. * @param mesh The mesh containing the geometry data we will draw
  20295. * @param defines The defines to update
  20296. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20297. * @param useBones Precise whether bones should be used or not (override mesh info)
  20298. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20299. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20300. * @returns false if defines are considered not dirty and have not been checked
  20301. */
  20302. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20303. /**
  20304. * Prepares the defines related to multiview
  20305. * @param scene The scene we are intending to draw
  20306. * @param defines The defines to update
  20307. */
  20308. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20309. /**
  20310. * Prepares the defines related to the prepass
  20311. * @param scene The scene we are intending to draw
  20312. * @param defines The defines to update
  20313. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20314. */
  20315. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20316. /**
  20317. * Prepares the defines related to the light information passed in parameter
  20318. * @param scene The scene we are intending to draw
  20319. * @param mesh The mesh the effect is compiling for
  20320. * @param light The light the effect is compiling for
  20321. * @param lightIndex The index of the light
  20322. * @param defines The defines to update
  20323. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20324. * @param state Defines the current state regarding what is needed (normals, etc...)
  20325. */
  20326. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20327. needNormals: boolean;
  20328. needRebuild: boolean;
  20329. shadowEnabled: boolean;
  20330. specularEnabled: boolean;
  20331. lightmapMode: boolean;
  20332. }): void;
  20333. /**
  20334. * Prepares the defines related to the light information passed in parameter
  20335. * @param scene The scene we are intending to draw
  20336. * @param mesh The mesh the effect is compiling for
  20337. * @param defines The defines to update
  20338. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20339. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20340. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20341. * @returns true if normals will be required for the rest of the effect
  20342. */
  20343. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20344. /**
  20345. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20346. * @param lightIndex defines the light index
  20347. * @param uniformsList The uniform list
  20348. * @param samplersList The sampler list
  20349. * @param projectedLightTexture defines if projected texture must be used
  20350. * @param uniformBuffersList defines an optional list of uniform buffers
  20351. */
  20352. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20353. /**
  20354. * Prepares the uniforms and samplers list to be used in the effect
  20355. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20356. * @param samplersList The sampler list
  20357. * @param defines The defines helping in the list generation
  20358. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20359. */
  20360. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20361. /**
  20362. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20363. * @param defines The defines to update while falling back
  20364. * @param fallbacks The authorized effect fallbacks
  20365. * @param maxSimultaneousLights The maximum number of lights allowed
  20366. * @param rank the current rank of the Effect
  20367. * @returns The newly affected rank
  20368. */
  20369. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20370. private static _TmpMorphInfluencers;
  20371. /**
  20372. * Prepares the list of attributes required for morph targets according to the effect defines.
  20373. * @param attribs The current list of supported attribs
  20374. * @param mesh The mesh to prepare the morph targets attributes for
  20375. * @param influencers The number of influencers
  20376. */
  20377. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20378. /**
  20379. * Prepares the list of attributes required for morph targets according to the effect defines.
  20380. * @param attribs The current list of supported attribs
  20381. * @param mesh The mesh to prepare the morph targets attributes for
  20382. * @param defines The current Defines of the effect
  20383. */
  20384. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20385. /**
  20386. * Prepares the list of attributes required for bones according to the effect defines.
  20387. * @param attribs The current list of supported attribs
  20388. * @param mesh The mesh to prepare the bones attributes for
  20389. * @param defines The current Defines of the effect
  20390. * @param fallbacks The current efffect fallback strategy
  20391. */
  20392. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20393. /**
  20394. * Check and prepare the list of attributes required for instances according to the effect defines.
  20395. * @param attribs The current list of supported attribs
  20396. * @param defines The current MaterialDefines of the effect
  20397. */
  20398. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20399. /**
  20400. * Add the list of attributes required for instances to the attribs array.
  20401. * @param attribs The current list of supported attribs
  20402. */
  20403. static PushAttributesForInstances(attribs: string[]): void;
  20404. /**
  20405. * Binds the light information to the effect.
  20406. * @param light The light containing the generator
  20407. * @param effect The effect we are binding the data to
  20408. * @param lightIndex The light index in the effect used to render
  20409. */
  20410. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20411. /**
  20412. * Binds the lights information from the scene to the effect for the given mesh.
  20413. * @param light Light to bind
  20414. * @param lightIndex Light index
  20415. * @param scene The scene where the light belongs to
  20416. * @param effect The effect we are binding the data to
  20417. * @param useSpecular Defines if specular is supported
  20418. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20419. */
  20420. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20421. /**
  20422. * Binds the lights information from the scene to the effect for the given mesh.
  20423. * @param scene The scene the lights belongs to
  20424. * @param mesh The mesh we are binding the information to render
  20425. * @param effect The effect we are binding the data to
  20426. * @param defines The generated defines for the effect
  20427. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20428. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20429. */
  20430. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20431. private static _tempFogColor;
  20432. /**
  20433. * Binds the fog information from the scene to the effect for the given mesh.
  20434. * @param scene The scene the lights belongs to
  20435. * @param mesh The mesh we are binding the information to render
  20436. * @param effect The effect we are binding the data to
  20437. * @param linearSpace Defines if the fog effect is applied in linear space
  20438. */
  20439. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20440. /**
  20441. * Binds the bones information from the mesh to the effect.
  20442. * @param mesh The mesh we are binding the information to render
  20443. * @param effect The effect we are binding the data to
  20444. */
  20445. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20446. /**
  20447. * Binds the morph targets information from the mesh to the effect.
  20448. * @param abstractMesh The mesh we are binding the information to render
  20449. * @param effect The effect we are binding the data to
  20450. */
  20451. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20452. /**
  20453. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20454. * @param defines The generated defines used in the effect
  20455. * @param effect The effect we are binding the data to
  20456. * @param scene The scene we are willing to render with logarithmic scale for
  20457. */
  20458. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20459. /**
  20460. * Binds the clip plane information from the scene to the effect.
  20461. * @param scene The scene the clip plane information are extracted from
  20462. * @param effect The effect we are binding the data to
  20463. */
  20464. static BindClipPlane(effect: Effect, scene: Scene): void;
  20465. }
  20466. }
  20467. declare module BABYLON {
  20468. /**
  20469. * Block used to expose an input value
  20470. */
  20471. export class InputBlock extends NodeMaterialBlock {
  20472. private _mode;
  20473. private _associatedVariableName;
  20474. private _storedValue;
  20475. private _valueCallback;
  20476. private _type;
  20477. private _animationType;
  20478. /** Gets or set a value used to limit the range of float values */
  20479. min: number;
  20480. /** Gets or set a value used to limit the range of float values */
  20481. max: number;
  20482. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20483. isBoolean: boolean;
  20484. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20485. matrixMode: number;
  20486. /** @hidden */
  20487. _systemValue: Nullable<NodeMaterialSystemValues>;
  20488. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20489. isConstant: boolean;
  20490. /** Gets or sets the group to use to display this block in the Inspector */
  20491. groupInInspector: string;
  20492. /** Gets an observable raised when the value is changed */
  20493. onValueChangedObservable: Observable<InputBlock>;
  20494. /**
  20495. * Gets or sets the connection point type (default is float)
  20496. */
  20497. get type(): NodeMaterialBlockConnectionPointTypes;
  20498. /**
  20499. * Creates a new InputBlock
  20500. * @param name defines the block name
  20501. * @param target defines the target of that block (Vertex by default)
  20502. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20503. */
  20504. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20505. /**
  20506. * Validates if a name is a reserve word.
  20507. * @param newName the new name to be given to the node.
  20508. * @returns false if the name is a reserve word, else true.
  20509. */
  20510. validateBlockName(newName: string): boolean;
  20511. /**
  20512. * Gets the output component
  20513. */
  20514. get output(): NodeMaterialConnectionPoint;
  20515. /**
  20516. * Set the source of this connection point to a vertex attribute
  20517. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20518. * @returns the current connection point
  20519. */
  20520. setAsAttribute(attributeName?: string): InputBlock;
  20521. /**
  20522. * Set the source of this connection point to a system value
  20523. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20524. * @returns the current connection point
  20525. */
  20526. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20527. /**
  20528. * Gets or sets the value of that point.
  20529. * Please note that this value will be ignored if valueCallback is defined
  20530. */
  20531. get value(): any;
  20532. set value(value: any);
  20533. /**
  20534. * Gets or sets a callback used to get the value of that point.
  20535. * Please note that setting this value will force the connection point to ignore the value property
  20536. */
  20537. get valueCallback(): () => any;
  20538. set valueCallback(value: () => any);
  20539. /**
  20540. * Gets or sets the associated variable name in the shader
  20541. */
  20542. get associatedVariableName(): string;
  20543. set associatedVariableName(value: string);
  20544. /** Gets or sets the type of animation applied to the input */
  20545. get animationType(): AnimatedInputBlockTypes;
  20546. set animationType(value: AnimatedInputBlockTypes);
  20547. /**
  20548. * Gets a boolean indicating that this connection point not defined yet
  20549. */
  20550. get isUndefined(): boolean;
  20551. /**
  20552. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20553. * In this case the connection point name must be the name of the uniform to use.
  20554. * Can only be set on inputs
  20555. */
  20556. get isUniform(): boolean;
  20557. set isUniform(value: boolean);
  20558. /**
  20559. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20560. * In this case the connection point name must be the name of the attribute to use
  20561. * Can only be set on inputs
  20562. */
  20563. get isAttribute(): boolean;
  20564. set isAttribute(value: boolean);
  20565. /**
  20566. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20567. * Can only be set on exit points
  20568. */
  20569. get isVarying(): boolean;
  20570. set isVarying(value: boolean);
  20571. /**
  20572. * Gets a boolean indicating that the current connection point is a system value
  20573. */
  20574. get isSystemValue(): boolean;
  20575. /**
  20576. * Gets or sets the current well known value or null if not defined as a system value
  20577. */
  20578. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20579. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20580. /**
  20581. * Gets the current class name
  20582. * @returns the class name
  20583. */
  20584. getClassName(): string;
  20585. /**
  20586. * Animate the input if animationType !== None
  20587. * @param scene defines the rendering scene
  20588. */
  20589. animate(scene: Scene): void;
  20590. private _emitDefine;
  20591. initialize(state: NodeMaterialBuildState): void;
  20592. /**
  20593. * Set the input block to its default value (based on its type)
  20594. */
  20595. setDefaultValue(): void;
  20596. private _emitConstant;
  20597. /** @hidden */
  20598. get _noContextSwitch(): boolean;
  20599. private _emit;
  20600. /** @hidden */
  20601. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20602. /** @hidden */
  20603. _transmit(effect: Effect, scene: Scene): void;
  20604. protected _buildBlock(state: NodeMaterialBuildState): void;
  20605. protected _dumpPropertiesCode(): string;
  20606. dispose(): void;
  20607. serialize(): any;
  20608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20609. }
  20610. }
  20611. declare module BABYLON {
  20612. /**
  20613. * Enum used to define the compatibility state between two connection points
  20614. */
  20615. export enum NodeMaterialConnectionPointCompatibilityStates {
  20616. /** Points are compatibles */
  20617. Compatible = 0,
  20618. /** Points are incompatible because of their types */
  20619. TypeIncompatible = 1,
  20620. /** Points are incompatible because of their targets (vertex vs fragment) */
  20621. TargetIncompatible = 2
  20622. }
  20623. /**
  20624. * Defines the direction of a connection point
  20625. */
  20626. export enum NodeMaterialConnectionPointDirection {
  20627. /** Input */
  20628. Input = 0,
  20629. /** Output */
  20630. Output = 1
  20631. }
  20632. /**
  20633. * Defines a connection point for a block
  20634. */
  20635. export class NodeMaterialConnectionPoint {
  20636. /** @hidden */
  20637. _ownerBlock: NodeMaterialBlock;
  20638. /** @hidden */
  20639. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20640. private _endpoints;
  20641. private _associatedVariableName;
  20642. private _direction;
  20643. /** @hidden */
  20644. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20645. /** @hidden */
  20646. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20647. private _type;
  20648. /** @hidden */
  20649. _enforceAssociatedVariableName: boolean;
  20650. /** Gets the direction of the point */
  20651. get direction(): NodeMaterialConnectionPointDirection;
  20652. /** Indicates that this connection point needs dual validation before being connected to another point */
  20653. needDualDirectionValidation: boolean;
  20654. /**
  20655. * Gets or sets the additional types supported by this connection point
  20656. */
  20657. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20658. /**
  20659. * Gets or sets the additional types excluded by this connection point
  20660. */
  20661. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20662. /**
  20663. * Observable triggered when this point is connected
  20664. */
  20665. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20666. /**
  20667. * Gets or sets the associated variable name in the shader
  20668. */
  20669. get associatedVariableName(): string;
  20670. set associatedVariableName(value: string);
  20671. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20672. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20673. /**
  20674. * Gets or sets the connection point type (default is float)
  20675. */
  20676. get type(): NodeMaterialBlockConnectionPointTypes;
  20677. set type(value: NodeMaterialBlockConnectionPointTypes);
  20678. /**
  20679. * Gets or sets the connection point name
  20680. */
  20681. name: string;
  20682. /**
  20683. * Gets or sets the connection point name
  20684. */
  20685. displayName: string;
  20686. /**
  20687. * Gets or sets a boolean indicating that this connection point can be omitted
  20688. */
  20689. isOptional: boolean;
  20690. /**
  20691. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20692. */
  20693. isExposedOnFrame: boolean;
  20694. /**
  20695. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20696. */
  20697. define: string;
  20698. /** @hidden */
  20699. _prioritizeVertex: boolean;
  20700. private _target;
  20701. /** Gets or sets the target of that connection point */
  20702. get target(): NodeMaterialBlockTargets;
  20703. set target(value: NodeMaterialBlockTargets);
  20704. /**
  20705. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20706. */
  20707. get isConnected(): boolean;
  20708. /**
  20709. * Gets a boolean indicating that the current point is connected to an input block
  20710. */
  20711. get isConnectedToInputBlock(): boolean;
  20712. /**
  20713. * Gets a the connected input block (if any)
  20714. */
  20715. get connectInputBlock(): Nullable<InputBlock>;
  20716. /** Get the other side of the connection (if any) */
  20717. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20718. /** Get the block that owns this connection point */
  20719. get ownerBlock(): NodeMaterialBlock;
  20720. /** Get the block connected on the other side of this connection (if any) */
  20721. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20722. /** Get the block connected on the endpoints of this connection (if any) */
  20723. get connectedBlocks(): Array<NodeMaterialBlock>;
  20724. /** Gets the list of connected endpoints */
  20725. get endpoints(): NodeMaterialConnectionPoint[];
  20726. /** Gets a boolean indicating if that output point is connected to at least one input */
  20727. get hasEndpoints(): boolean;
  20728. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20729. get isConnectedInVertexShader(): boolean;
  20730. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20731. get isConnectedInFragmentShader(): boolean;
  20732. /**
  20733. * Creates a block suitable to be used as an input for this input point.
  20734. * If null is returned, a block based on the point type will be created.
  20735. * @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
  20736. */
  20737. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20738. /**
  20739. * Creates a new connection point
  20740. * @param name defines the connection point name
  20741. * @param ownerBlock defines the block hosting this connection point
  20742. * @param direction defines the direction of the connection point
  20743. */
  20744. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20745. /**
  20746. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20747. * @returns the class name
  20748. */
  20749. getClassName(): string;
  20750. /**
  20751. * Gets a boolean indicating if the current point can be connected to another point
  20752. * @param connectionPoint defines the other connection point
  20753. * @returns a boolean
  20754. */
  20755. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20756. /**
  20757. * Gets a number indicating if the current point can be connected to another point
  20758. * @param connectionPoint defines the other connection point
  20759. * @returns a number defining the compatibility state
  20760. */
  20761. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20762. /**
  20763. * Connect this point to another connection point
  20764. * @param connectionPoint defines the other connection point
  20765. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20766. * @returns the current connection point
  20767. */
  20768. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20769. /**
  20770. * Disconnect this point from one of his endpoint
  20771. * @param endpoint defines the other connection point
  20772. * @returns the current connection point
  20773. */
  20774. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20775. /**
  20776. * Serializes this point in a JSON representation
  20777. * @param isInput defines if the connection point is an input (default is true)
  20778. * @returns the serialized point object
  20779. */
  20780. serialize(isInput?: boolean): any;
  20781. /**
  20782. * Release resources
  20783. */
  20784. dispose(): void;
  20785. }
  20786. }
  20787. declare module BABYLON {
  20788. /**
  20789. * Enum used to define the material modes
  20790. */
  20791. export enum NodeMaterialModes {
  20792. /** Regular material */
  20793. Material = 0,
  20794. /** For post process */
  20795. PostProcess = 1,
  20796. /** For particle system */
  20797. Particle = 2
  20798. }
  20799. }
  20800. declare module BABYLON {
  20801. /**
  20802. * Block used to read a texture from a sampler
  20803. */
  20804. export class TextureBlock extends NodeMaterialBlock {
  20805. private _defineName;
  20806. private _linearDefineName;
  20807. private _gammaDefineName;
  20808. private _tempTextureRead;
  20809. private _samplerName;
  20810. private _transformedUVName;
  20811. private _textureTransformName;
  20812. private _textureInfoName;
  20813. private _mainUVName;
  20814. private _mainUVDefineName;
  20815. private _fragmentOnly;
  20816. /**
  20817. * Gets or sets the texture associated with the node
  20818. */
  20819. texture: Nullable<Texture>;
  20820. /**
  20821. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20822. */
  20823. convertToGammaSpace: boolean;
  20824. /**
  20825. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20826. */
  20827. convertToLinearSpace: boolean;
  20828. /**
  20829. * Create a new TextureBlock
  20830. * @param name defines the block name
  20831. */
  20832. constructor(name: string, fragmentOnly?: boolean);
  20833. /**
  20834. * Gets the current class name
  20835. * @returns the class name
  20836. */
  20837. getClassName(): string;
  20838. /**
  20839. * Gets the uv input component
  20840. */
  20841. get uv(): NodeMaterialConnectionPoint;
  20842. /**
  20843. * Gets the rgba output component
  20844. */
  20845. get rgba(): NodeMaterialConnectionPoint;
  20846. /**
  20847. * Gets the rgb output component
  20848. */
  20849. get rgb(): NodeMaterialConnectionPoint;
  20850. /**
  20851. * Gets the r output component
  20852. */
  20853. get r(): NodeMaterialConnectionPoint;
  20854. /**
  20855. * Gets the g output component
  20856. */
  20857. get g(): NodeMaterialConnectionPoint;
  20858. /**
  20859. * Gets the b output component
  20860. */
  20861. get b(): NodeMaterialConnectionPoint;
  20862. /**
  20863. * Gets the a output component
  20864. */
  20865. get a(): NodeMaterialConnectionPoint;
  20866. get target(): NodeMaterialBlockTargets;
  20867. autoConfigure(material: NodeMaterial): void;
  20868. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20869. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20870. isReady(): boolean;
  20871. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20872. private get _isMixed();
  20873. private _injectVertexCode;
  20874. private _writeTextureRead;
  20875. private _writeOutput;
  20876. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20877. protected _dumpPropertiesCode(): string;
  20878. serialize(): any;
  20879. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20880. }
  20881. }
  20882. declare module BABYLON {
  20883. /** @hidden */
  20884. export var reflectionFunction: {
  20885. name: string;
  20886. shader: string;
  20887. };
  20888. }
  20889. declare module BABYLON {
  20890. /**
  20891. * Base block used to read a reflection texture from a sampler
  20892. */
  20893. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20894. /** @hidden */
  20895. _define3DName: string;
  20896. /** @hidden */
  20897. _defineCubicName: string;
  20898. /** @hidden */
  20899. _defineExplicitName: string;
  20900. /** @hidden */
  20901. _defineProjectionName: string;
  20902. /** @hidden */
  20903. _defineLocalCubicName: string;
  20904. /** @hidden */
  20905. _defineSphericalName: string;
  20906. /** @hidden */
  20907. _definePlanarName: string;
  20908. /** @hidden */
  20909. _defineEquirectangularName: string;
  20910. /** @hidden */
  20911. _defineMirroredEquirectangularFixedName: string;
  20912. /** @hidden */
  20913. _defineEquirectangularFixedName: string;
  20914. /** @hidden */
  20915. _defineSkyboxName: string;
  20916. /** @hidden */
  20917. _defineOppositeZ: string;
  20918. /** @hidden */
  20919. _cubeSamplerName: string;
  20920. /** @hidden */
  20921. _2DSamplerName: string;
  20922. protected _positionUVWName: string;
  20923. protected _directionWName: string;
  20924. protected _reflectionVectorName: string;
  20925. /** @hidden */
  20926. _reflectionCoordsName: string;
  20927. /** @hidden */
  20928. _reflectionMatrixName: string;
  20929. protected _reflectionColorName: string;
  20930. /**
  20931. * Gets or sets the texture associated with the node
  20932. */
  20933. texture: Nullable<BaseTexture>;
  20934. /**
  20935. * Create a new ReflectionTextureBaseBlock
  20936. * @param name defines the block name
  20937. */
  20938. constructor(name: string);
  20939. /**
  20940. * Gets the current class name
  20941. * @returns the class name
  20942. */
  20943. getClassName(): string;
  20944. /**
  20945. * Gets the world position input component
  20946. */
  20947. abstract get position(): NodeMaterialConnectionPoint;
  20948. /**
  20949. * Gets the world position input component
  20950. */
  20951. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20952. /**
  20953. * Gets the world normal input component
  20954. */
  20955. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20956. /**
  20957. * Gets the world input component
  20958. */
  20959. abstract get world(): NodeMaterialConnectionPoint;
  20960. /**
  20961. * Gets the camera (or eye) position component
  20962. */
  20963. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20964. /**
  20965. * Gets the view input component
  20966. */
  20967. abstract get view(): NodeMaterialConnectionPoint;
  20968. protected _getTexture(): Nullable<BaseTexture>;
  20969. autoConfigure(material: NodeMaterial): void;
  20970. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20971. isReady(): boolean;
  20972. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20973. /**
  20974. * Gets the code to inject in the vertex shader
  20975. * @param state current state of the node material building
  20976. * @returns the shader code
  20977. */
  20978. handleVertexSide(state: NodeMaterialBuildState): string;
  20979. /**
  20980. * Handles the inits for the fragment code path
  20981. * @param state node material build state
  20982. */
  20983. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20984. /**
  20985. * Generates the reflection coords code for the fragment code path
  20986. * @param worldNormalVarName name of the world normal variable
  20987. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20988. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20989. * @returns the shader code
  20990. */
  20991. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20992. /**
  20993. * Generates the reflection color code for the fragment code path
  20994. * @param lodVarName name of the lod variable
  20995. * @param swizzleLookupTexture swizzle to use for the final color variable
  20996. * @returns the shader code
  20997. */
  20998. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20999. /**
  21000. * Generates the code corresponding to the connected output points
  21001. * @param state node material build state
  21002. * @param varName name of the variable to output
  21003. * @returns the shader code
  21004. */
  21005. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21006. protected _buildBlock(state: NodeMaterialBuildState): this;
  21007. protected _dumpPropertiesCode(): string;
  21008. serialize(): any;
  21009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21010. }
  21011. }
  21012. declare module BABYLON {
  21013. /**
  21014. * Defines a connection point to be used for points with a custom object type
  21015. */
  21016. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21017. private _blockType;
  21018. private _blockName;
  21019. private _nameForCheking?;
  21020. /**
  21021. * Creates a new connection point
  21022. * @param name defines the connection point name
  21023. * @param ownerBlock defines the block hosting this connection point
  21024. * @param direction defines the direction of the connection point
  21025. */
  21026. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21027. /**
  21028. * Gets a number indicating if the current point can be connected to another point
  21029. * @param connectionPoint defines the other connection point
  21030. * @returns a number defining the compatibility state
  21031. */
  21032. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21033. /**
  21034. * Creates a block suitable to be used as an input for this input point.
  21035. * If null is returned, a block based on the point type will be created.
  21036. * @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
  21037. */
  21038. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21039. }
  21040. }
  21041. declare module BABYLON {
  21042. /**
  21043. * Enum defining the type of properties that can be edited in the property pages in the NME
  21044. */
  21045. export enum PropertyTypeForEdition {
  21046. /** property is a boolean */
  21047. Boolean = 0,
  21048. /** property is a float */
  21049. Float = 1,
  21050. /** property is a Vector2 */
  21051. Vector2 = 2,
  21052. /** property is a list of values */
  21053. List = 3
  21054. }
  21055. /**
  21056. * Interface that defines an option in a variable of type list
  21057. */
  21058. export interface IEditablePropertyListOption {
  21059. /** label of the option */
  21060. "label": string;
  21061. /** value of the option */
  21062. "value": number;
  21063. }
  21064. /**
  21065. * Interface that defines the options available for an editable property
  21066. */
  21067. export interface IEditablePropertyOption {
  21068. /** min value */
  21069. "min"?: number;
  21070. /** max value */
  21071. "max"?: number;
  21072. /** notifiers: indicates which actions to take when the property is changed */
  21073. "notifiers"?: {
  21074. /** the material should be rebuilt */
  21075. "rebuild"?: boolean;
  21076. /** the preview should be updated */
  21077. "update"?: boolean;
  21078. };
  21079. /** list of the options for a variable of type list */
  21080. "options"?: IEditablePropertyListOption[];
  21081. }
  21082. /**
  21083. * Interface that describes an editable property
  21084. */
  21085. export interface IPropertyDescriptionForEdition {
  21086. /** name of the property */
  21087. "propertyName": string;
  21088. /** display name of the property */
  21089. "displayName": string;
  21090. /** type of the property */
  21091. "type": PropertyTypeForEdition;
  21092. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21093. "groupName": string;
  21094. /** options for the property */
  21095. "options": IEditablePropertyOption;
  21096. }
  21097. /**
  21098. * Decorator that flags a property in a node material block as being editable
  21099. */
  21100. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21101. }
  21102. declare module BABYLON {
  21103. /**
  21104. * Block used to implement the refraction part of the sub surface module of the PBR material
  21105. */
  21106. export class RefractionBlock extends NodeMaterialBlock {
  21107. /** @hidden */
  21108. _define3DName: string;
  21109. /** @hidden */
  21110. _refractionMatrixName: string;
  21111. /** @hidden */
  21112. _defineLODRefractionAlpha: string;
  21113. /** @hidden */
  21114. _defineLinearSpecularRefraction: string;
  21115. /** @hidden */
  21116. _defineOppositeZ: string;
  21117. /** @hidden */
  21118. _cubeSamplerName: string;
  21119. /** @hidden */
  21120. _2DSamplerName: string;
  21121. /** @hidden */
  21122. _vRefractionMicrosurfaceInfosName: string;
  21123. /** @hidden */
  21124. _vRefractionInfosName: string;
  21125. private _scene;
  21126. /**
  21127. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21128. * Materials half opaque for instance using refraction could benefit from this control.
  21129. */
  21130. linkRefractionWithTransparency: boolean;
  21131. /**
  21132. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21133. */
  21134. invertRefractionY: boolean;
  21135. /**
  21136. * Gets or sets the texture associated with the node
  21137. */
  21138. texture: Nullable<BaseTexture>;
  21139. /**
  21140. * Create a new RefractionBlock
  21141. * @param name defines the block name
  21142. */
  21143. constructor(name: string);
  21144. /**
  21145. * Gets the current class name
  21146. * @returns the class name
  21147. */
  21148. getClassName(): string;
  21149. /**
  21150. * Gets the intensity input component
  21151. */
  21152. get intensity(): NodeMaterialConnectionPoint;
  21153. /**
  21154. * Gets the index of refraction input component
  21155. */
  21156. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21157. /**
  21158. * Gets the tint at distance input component
  21159. */
  21160. get tintAtDistance(): NodeMaterialConnectionPoint;
  21161. /**
  21162. * Gets the view input component
  21163. */
  21164. get view(): NodeMaterialConnectionPoint;
  21165. /**
  21166. * Gets the refraction object output component
  21167. */
  21168. get refraction(): NodeMaterialConnectionPoint;
  21169. /**
  21170. * Returns true if the block has a texture
  21171. */
  21172. get hasTexture(): boolean;
  21173. protected _getTexture(): Nullable<BaseTexture>;
  21174. autoConfigure(material: NodeMaterial): void;
  21175. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21176. isReady(): boolean;
  21177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21178. /**
  21179. * Gets the main code of the block (fragment side)
  21180. * @param state current state of the node material building
  21181. * @returns the shader code
  21182. */
  21183. getCode(state: NodeMaterialBuildState): string;
  21184. protected _buildBlock(state: NodeMaterialBuildState): this;
  21185. protected _dumpPropertiesCode(): string;
  21186. serialize(): any;
  21187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21188. }
  21189. }
  21190. declare module BABYLON {
  21191. /**
  21192. * Base block used as input for post process
  21193. */
  21194. export class CurrentScreenBlock extends NodeMaterialBlock {
  21195. private _samplerName;
  21196. private _linearDefineName;
  21197. private _gammaDefineName;
  21198. private _mainUVName;
  21199. private _tempTextureRead;
  21200. /**
  21201. * Gets or sets the texture associated with the node
  21202. */
  21203. texture: Nullable<BaseTexture>;
  21204. /**
  21205. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21206. */
  21207. convertToGammaSpace: boolean;
  21208. /**
  21209. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21210. */
  21211. convertToLinearSpace: boolean;
  21212. /**
  21213. * Create a new CurrentScreenBlock
  21214. * @param name defines the block name
  21215. */
  21216. constructor(name: string);
  21217. /**
  21218. * Gets the current class name
  21219. * @returns the class name
  21220. */
  21221. getClassName(): string;
  21222. /**
  21223. * Gets the uv input component
  21224. */
  21225. get uv(): NodeMaterialConnectionPoint;
  21226. /**
  21227. * Gets the rgba output component
  21228. */
  21229. get rgba(): NodeMaterialConnectionPoint;
  21230. /**
  21231. * Gets the rgb output component
  21232. */
  21233. get rgb(): NodeMaterialConnectionPoint;
  21234. /**
  21235. * Gets the r output component
  21236. */
  21237. get r(): NodeMaterialConnectionPoint;
  21238. /**
  21239. * Gets the g output component
  21240. */
  21241. get g(): NodeMaterialConnectionPoint;
  21242. /**
  21243. * Gets the b output component
  21244. */
  21245. get b(): NodeMaterialConnectionPoint;
  21246. /**
  21247. * Gets the a output component
  21248. */
  21249. get a(): NodeMaterialConnectionPoint;
  21250. /**
  21251. * Initialize the block and prepare the context for build
  21252. * @param state defines the state that will be used for the build
  21253. */
  21254. initialize(state: NodeMaterialBuildState): void;
  21255. get target(): NodeMaterialBlockTargets;
  21256. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21257. isReady(): boolean;
  21258. private _injectVertexCode;
  21259. private _writeTextureRead;
  21260. private _writeOutput;
  21261. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21262. serialize(): any;
  21263. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21264. }
  21265. }
  21266. declare module BABYLON {
  21267. /**
  21268. * Base block used for the particle texture
  21269. */
  21270. export class ParticleTextureBlock extends NodeMaterialBlock {
  21271. private _samplerName;
  21272. private _linearDefineName;
  21273. private _gammaDefineName;
  21274. private _tempTextureRead;
  21275. /**
  21276. * Gets or sets the texture associated with the node
  21277. */
  21278. texture: Nullable<BaseTexture>;
  21279. /**
  21280. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21281. */
  21282. convertToGammaSpace: boolean;
  21283. /**
  21284. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21285. */
  21286. convertToLinearSpace: boolean;
  21287. /**
  21288. * Create a new ParticleTextureBlock
  21289. * @param name defines the block name
  21290. */
  21291. constructor(name: string);
  21292. /**
  21293. * Gets the current class name
  21294. * @returns the class name
  21295. */
  21296. getClassName(): string;
  21297. /**
  21298. * Gets the uv input component
  21299. */
  21300. get uv(): NodeMaterialConnectionPoint;
  21301. /**
  21302. * Gets the rgba output component
  21303. */
  21304. get rgba(): NodeMaterialConnectionPoint;
  21305. /**
  21306. * Gets the rgb output component
  21307. */
  21308. get rgb(): NodeMaterialConnectionPoint;
  21309. /**
  21310. * Gets the r output component
  21311. */
  21312. get r(): NodeMaterialConnectionPoint;
  21313. /**
  21314. * Gets the g output component
  21315. */
  21316. get g(): NodeMaterialConnectionPoint;
  21317. /**
  21318. * Gets the b output component
  21319. */
  21320. get b(): NodeMaterialConnectionPoint;
  21321. /**
  21322. * Gets the a output component
  21323. */
  21324. get a(): NodeMaterialConnectionPoint;
  21325. /**
  21326. * Initialize the block and prepare the context for build
  21327. * @param state defines the state that will be used for the build
  21328. */
  21329. initialize(state: NodeMaterialBuildState): void;
  21330. autoConfigure(material: NodeMaterial): void;
  21331. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21332. isReady(): boolean;
  21333. private _writeOutput;
  21334. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21335. serialize(): any;
  21336. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21337. }
  21338. }
  21339. declare module BABYLON {
  21340. /**
  21341. * Class used to store shared data between 2 NodeMaterialBuildState
  21342. */
  21343. export class NodeMaterialBuildStateSharedData {
  21344. /**
  21345. * Gets the list of emitted varyings
  21346. */
  21347. temps: string[];
  21348. /**
  21349. * Gets the list of emitted varyings
  21350. */
  21351. varyings: string[];
  21352. /**
  21353. * Gets the varying declaration string
  21354. */
  21355. varyingDeclaration: string;
  21356. /**
  21357. * Input blocks
  21358. */
  21359. inputBlocks: InputBlock[];
  21360. /**
  21361. * Input blocks
  21362. */
  21363. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21364. /**
  21365. * Bindable blocks (Blocks that need to set data to the effect)
  21366. */
  21367. bindableBlocks: NodeMaterialBlock[];
  21368. /**
  21369. * List of blocks that can provide a compilation fallback
  21370. */
  21371. blocksWithFallbacks: NodeMaterialBlock[];
  21372. /**
  21373. * List of blocks that can provide a define update
  21374. */
  21375. blocksWithDefines: NodeMaterialBlock[];
  21376. /**
  21377. * List of blocks that can provide a repeatable content
  21378. */
  21379. repeatableContentBlocks: NodeMaterialBlock[];
  21380. /**
  21381. * List of blocks that can provide a dynamic list of uniforms
  21382. */
  21383. dynamicUniformBlocks: NodeMaterialBlock[];
  21384. /**
  21385. * List of blocks that can block the isReady function for the material
  21386. */
  21387. blockingBlocks: NodeMaterialBlock[];
  21388. /**
  21389. * Gets the list of animated inputs
  21390. */
  21391. animatedInputs: InputBlock[];
  21392. /**
  21393. * Build Id used to avoid multiple recompilations
  21394. */
  21395. buildId: number;
  21396. /** List of emitted variables */
  21397. variableNames: {
  21398. [key: string]: number;
  21399. };
  21400. /** List of emitted defines */
  21401. defineNames: {
  21402. [key: string]: number;
  21403. };
  21404. /** Should emit comments? */
  21405. emitComments: boolean;
  21406. /** Emit build activity */
  21407. verbose: boolean;
  21408. /** Gets or sets the hosting scene */
  21409. scene: Scene;
  21410. /**
  21411. * Gets the compilation hints emitted at compilation time
  21412. */
  21413. hints: {
  21414. needWorldViewMatrix: boolean;
  21415. needWorldViewProjectionMatrix: boolean;
  21416. needAlphaBlending: boolean;
  21417. needAlphaTesting: boolean;
  21418. };
  21419. /**
  21420. * List of compilation checks
  21421. */
  21422. checks: {
  21423. emitVertex: boolean;
  21424. emitFragment: boolean;
  21425. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21426. };
  21427. /**
  21428. * Is vertex program allowed to be empty?
  21429. */
  21430. allowEmptyVertexProgram: boolean;
  21431. /** Creates a new shared data */
  21432. constructor();
  21433. /**
  21434. * Emits console errors and exceptions if there is a failing check
  21435. */
  21436. emitErrors(): void;
  21437. }
  21438. }
  21439. declare module BABYLON {
  21440. /**
  21441. * Class used to store node based material build state
  21442. */
  21443. export class NodeMaterialBuildState {
  21444. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21445. supportUniformBuffers: boolean;
  21446. /**
  21447. * Gets the list of emitted attributes
  21448. */
  21449. attributes: string[];
  21450. /**
  21451. * Gets the list of emitted uniforms
  21452. */
  21453. uniforms: string[];
  21454. /**
  21455. * Gets the list of emitted constants
  21456. */
  21457. constants: string[];
  21458. /**
  21459. * Gets the list of emitted samplers
  21460. */
  21461. samplers: string[];
  21462. /**
  21463. * Gets the list of emitted functions
  21464. */
  21465. functions: {
  21466. [key: string]: string;
  21467. };
  21468. /**
  21469. * Gets the list of emitted extensions
  21470. */
  21471. extensions: {
  21472. [key: string]: string;
  21473. };
  21474. /**
  21475. * Gets the target of the compilation state
  21476. */
  21477. target: NodeMaterialBlockTargets;
  21478. /**
  21479. * Gets the list of emitted counters
  21480. */
  21481. counters: {
  21482. [key: string]: number;
  21483. };
  21484. /**
  21485. * Shared data between multiple NodeMaterialBuildState instances
  21486. */
  21487. sharedData: NodeMaterialBuildStateSharedData;
  21488. /** @hidden */
  21489. _vertexState: NodeMaterialBuildState;
  21490. /** @hidden */
  21491. _attributeDeclaration: string;
  21492. /** @hidden */
  21493. _uniformDeclaration: string;
  21494. /** @hidden */
  21495. _constantDeclaration: string;
  21496. /** @hidden */
  21497. _samplerDeclaration: string;
  21498. /** @hidden */
  21499. _varyingTransfer: string;
  21500. /** @hidden */
  21501. _injectAtEnd: string;
  21502. private _repeatableContentAnchorIndex;
  21503. /** @hidden */
  21504. _builtCompilationString: string;
  21505. /**
  21506. * Gets the emitted compilation strings
  21507. */
  21508. compilationString: string;
  21509. /**
  21510. * Finalize the compilation strings
  21511. * @param state defines the current compilation state
  21512. */
  21513. finalize(state: NodeMaterialBuildState): void;
  21514. /** @hidden */
  21515. get _repeatableContentAnchor(): string;
  21516. /** @hidden */
  21517. _getFreeVariableName(prefix: string): string;
  21518. /** @hidden */
  21519. _getFreeDefineName(prefix: string): string;
  21520. /** @hidden */
  21521. _excludeVariableName(name: string): void;
  21522. /** @hidden */
  21523. _emit2DSampler(name: string): void;
  21524. /** @hidden */
  21525. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21526. /** @hidden */
  21527. _emitExtension(name: string, extension: string, define?: string): void;
  21528. /** @hidden */
  21529. _emitFunction(name: string, code: string, comments: string): void;
  21530. /** @hidden */
  21531. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21532. replaceStrings?: {
  21533. search: RegExp;
  21534. replace: string;
  21535. }[];
  21536. repeatKey?: string;
  21537. }): string;
  21538. /** @hidden */
  21539. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21540. repeatKey?: string;
  21541. removeAttributes?: boolean;
  21542. removeUniforms?: boolean;
  21543. removeVaryings?: boolean;
  21544. removeIfDef?: boolean;
  21545. replaceStrings?: {
  21546. search: RegExp;
  21547. replace: string;
  21548. }[];
  21549. }, storeKey?: string): void;
  21550. /** @hidden */
  21551. _registerTempVariable(name: string): boolean;
  21552. /** @hidden */
  21553. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21554. /** @hidden */
  21555. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21556. /** @hidden */
  21557. _emitFloat(value: number): string;
  21558. }
  21559. }
  21560. declare module BABYLON {
  21561. /**
  21562. * Helper class used to generate session unique ID
  21563. */
  21564. export class UniqueIdGenerator {
  21565. private static _UniqueIdCounter;
  21566. /**
  21567. * Gets an unique (relatively to the current scene) Id
  21568. */
  21569. static get UniqueId(): number;
  21570. }
  21571. }
  21572. declare module BABYLON {
  21573. /**
  21574. * Defines a block that can be used inside a node based material
  21575. */
  21576. export class NodeMaterialBlock {
  21577. private _buildId;
  21578. private _buildTarget;
  21579. private _target;
  21580. private _isFinalMerger;
  21581. private _isInput;
  21582. private _name;
  21583. protected _isUnique: boolean;
  21584. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21585. inputsAreExclusive: boolean;
  21586. /** @hidden */
  21587. _codeVariableName: string;
  21588. /** @hidden */
  21589. _inputs: NodeMaterialConnectionPoint[];
  21590. /** @hidden */
  21591. _outputs: NodeMaterialConnectionPoint[];
  21592. /** @hidden */
  21593. _preparationId: number;
  21594. /**
  21595. * Gets the name of the block
  21596. */
  21597. get name(): string;
  21598. /**
  21599. * Sets the name of the block. Will check if the name is valid.
  21600. */
  21601. set name(newName: string);
  21602. /**
  21603. * Gets or sets the unique id of the node
  21604. */
  21605. uniqueId: number;
  21606. /**
  21607. * Gets or sets the comments associated with this block
  21608. */
  21609. comments: string;
  21610. /**
  21611. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21612. */
  21613. get isUnique(): boolean;
  21614. /**
  21615. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21616. */
  21617. get isFinalMerger(): boolean;
  21618. /**
  21619. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21620. */
  21621. get isInput(): boolean;
  21622. /**
  21623. * Gets or sets the build Id
  21624. */
  21625. get buildId(): number;
  21626. set buildId(value: number);
  21627. /**
  21628. * Gets or sets the target of the block
  21629. */
  21630. get target(): NodeMaterialBlockTargets;
  21631. set target(value: NodeMaterialBlockTargets);
  21632. /**
  21633. * Gets the list of input points
  21634. */
  21635. get inputs(): NodeMaterialConnectionPoint[];
  21636. /** Gets the list of output points */
  21637. get outputs(): NodeMaterialConnectionPoint[];
  21638. /**
  21639. * Find an input by its name
  21640. * @param name defines the name of the input to look for
  21641. * @returns the input or null if not found
  21642. */
  21643. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21644. /**
  21645. * Find an output by its name
  21646. * @param name defines the name of the outputto look for
  21647. * @returns the output or null if not found
  21648. */
  21649. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21650. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21651. visibleInInspector: boolean;
  21652. /**
  21653. * Creates a new NodeMaterialBlock
  21654. * @param name defines the block name
  21655. * @param target defines the target of that block (Vertex by default)
  21656. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21657. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21658. */
  21659. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21660. /**
  21661. * Initialize the block and prepare the context for build
  21662. * @param state defines the state that will be used for the build
  21663. */
  21664. initialize(state: NodeMaterialBuildState): void;
  21665. /**
  21666. * Bind data to effect. Will only be called for blocks with isBindable === true
  21667. * @param effect defines the effect to bind data to
  21668. * @param nodeMaterial defines the hosting NodeMaterial
  21669. * @param mesh defines the mesh that will be rendered
  21670. * @param subMesh defines the submesh that will be rendered
  21671. */
  21672. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21673. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21674. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21675. protected _writeFloat(value: number): string;
  21676. /**
  21677. * Gets the current class name e.g. "NodeMaterialBlock"
  21678. * @returns the class name
  21679. */
  21680. getClassName(): string;
  21681. /**
  21682. * Register a new input. Must be called inside a block constructor
  21683. * @param name defines the connection point name
  21684. * @param type defines the connection point type
  21685. * @param isOptional defines a boolean indicating that this input can be omitted
  21686. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21687. * @param point an already created connection point. If not provided, create a new one
  21688. * @returns the current block
  21689. */
  21690. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21691. /**
  21692. * Register a new output. Must be called inside a block constructor
  21693. * @param name defines the connection point name
  21694. * @param type defines the connection point type
  21695. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21696. * @param point an already created connection point. If not provided, create a new one
  21697. * @returns the current block
  21698. */
  21699. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21700. /**
  21701. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21702. * @param forOutput defines an optional connection point to check compatibility with
  21703. * @returns the first available input or null
  21704. */
  21705. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21706. /**
  21707. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21708. * @param forBlock defines an optional block to check compatibility with
  21709. * @returns the first available input or null
  21710. */
  21711. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21712. /**
  21713. * Gets the sibling of the given output
  21714. * @param current defines the current output
  21715. * @returns the next output in the list or null
  21716. */
  21717. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21718. /**
  21719. * Connect current block with another block
  21720. * @param other defines the block to connect with
  21721. * @param options define the various options to help pick the right connections
  21722. * @returns the current block
  21723. */
  21724. connectTo(other: NodeMaterialBlock, options?: {
  21725. input?: string;
  21726. output?: string;
  21727. outputSwizzle?: string;
  21728. }): this | undefined;
  21729. protected _buildBlock(state: NodeMaterialBuildState): void;
  21730. /**
  21731. * Add uniforms, samplers and uniform buffers at compilation time
  21732. * @param state defines the state to update
  21733. * @param nodeMaterial defines the node material requesting the update
  21734. * @param defines defines the material defines to update
  21735. * @param uniformBuffers defines the list of uniform buffer names
  21736. */
  21737. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21738. /**
  21739. * Add potential fallbacks if shader compilation fails
  21740. * @param mesh defines the mesh to be rendered
  21741. * @param fallbacks defines the current prioritized list of fallbacks
  21742. */
  21743. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21744. /**
  21745. * Initialize defines for shader compilation
  21746. * @param mesh defines the mesh to be rendered
  21747. * @param nodeMaterial defines the node material requesting the update
  21748. * @param defines defines the material defines to update
  21749. * @param useInstances specifies that instances should be used
  21750. */
  21751. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21752. /**
  21753. * Update defines for shader compilation
  21754. * @param mesh defines the mesh to be rendered
  21755. * @param nodeMaterial defines the node material requesting the update
  21756. * @param defines defines the material defines to update
  21757. * @param useInstances specifies that instances should be used
  21758. * @param subMesh defines which submesh to render
  21759. */
  21760. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21761. /**
  21762. * Lets the block try to connect some inputs automatically
  21763. * @param material defines the hosting NodeMaterial
  21764. */
  21765. autoConfigure(material: NodeMaterial): void;
  21766. /**
  21767. * Function called when a block is declared as repeatable content generator
  21768. * @param vertexShaderState defines the current compilation state for the vertex shader
  21769. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21770. * @param mesh defines the mesh to be rendered
  21771. * @param defines defines the material defines to update
  21772. */
  21773. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21774. /**
  21775. * Checks if the block is ready
  21776. * @param mesh defines the mesh to be rendered
  21777. * @param nodeMaterial defines the node material requesting the update
  21778. * @param defines defines the material defines to update
  21779. * @param useInstances specifies that instances should be used
  21780. * @returns true if the block is ready
  21781. */
  21782. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21783. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21784. private _processBuild;
  21785. /**
  21786. * Validates the new name for the block node.
  21787. * @param newName the new name to be given to the node.
  21788. * @returns false if the name is a reserve word, else true.
  21789. */
  21790. validateBlockName(newName: string): boolean;
  21791. /**
  21792. * Compile the current node and generate the shader code
  21793. * @param state defines the current compilation state (uniforms, samplers, current string)
  21794. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21795. * @returns true if already built
  21796. */
  21797. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21798. protected _inputRename(name: string): string;
  21799. protected _outputRename(name: string): string;
  21800. protected _dumpPropertiesCode(): string;
  21801. /** @hidden */
  21802. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21803. /** @hidden */
  21804. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21805. /**
  21806. * Clone the current block to a new identical block
  21807. * @param scene defines the hosting scene
  21808. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21809. * @returns a copy of the current block
  21810. */
  21811. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21812. /**
  21813. * Serializes this block in a JSON representation
  21814. * @returns the serialized block object
  21815. */
  21816. serialize(): any;
  21817. /** @hidden */
  21818. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21819. private _deserializePortDisplayNamesAndExposedOnFrame;
  21820. /**
  21821. * Release resources
  21822. */
  21823. dispose(): void;
  21824. }
  21825. }
  21826. declare module BABYLON {
  21827. /**
  21828. * Base class of materials working in push mode in babylon JS
  21829. * @hidden
  21830. */
  21831. export class PushMaterial extends Material {
  21832. protected _activeEffect: Effect;
  21833. protected _normalMatrix: Matrix;
  21834. constructor(name: string, scene: Scene);
  21835. getEffect(): Effect;
  21836. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21837. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21838. /**
  21839. * Binds the given world matrix to the active effect
  21840. *
  21841. * @param world the matrix to bind
  21842. */
  21843. bindOnlyWorldMatrix(world: Matrix): void;
  21844. /**
  21845. * Binds the given normal matrix to the active effect
  21846. *
  21847. * @param normalMatrix the matrix to bind
  21848. */
  21849. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21850. bind(world: Matrix, mesh?: Mesh): void;
  21851. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21852. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21853. }
  21854. }
  21855. declare module BABYLON {
  21856. /**
  21857. * Root class for all node material optimizers
  21858. */
  21859. export class NodeMaterialOptimizer {
  21860. /**
  21861. * Function used to optimize a NodeMaterial graph
  21862. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21863. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21864. */
  21865. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21866. }
  21867. }
  21868. declare module BABYLON {
  21869. /**
  21870. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21871. */
  21872. export class TransformBlock extends NodeMaterialBlock {
  21873. /**
  21874. * Defines the value to use to complement W value to transform it to a Vector4
  21875. */
  21876. complementW: number;
  21877. /**
  21878. * Defines the value to use to complement z value to transform it to a Vector4
  21879. */
  21880. complementZ: number;
  21881. /**
  21882. * Creates a new TransformBlock
  21883. * @param name defines the block name
  21884. */
  21885. constructor(name: string);
  21886. /**
  21887. * Gets the current class name
  21888. * @returns the class name
  21889. */
  21890. getClassName(): string;
  21891. /**
  21892. * Gets the vector input
  21893. */
  21894. get vector(): NodeMaterialConnectionPoint;
  21895. /**
  21896. * Gets the output component
  21897. */
  21898. get output(): NodeMaterialConnectionPoint;
  21899. /**
  21900. * Gets the xyz output component
  21901. */
  21902. get xyz(): NodeMaterialConnectionPoint;
  21903. /**
  21904. * Gets the matrix transform input
  21905. */
  21906. get transform(): NodeMaterialConnectionPoint;
  21907. protected _buildBlock(state: NodeMaterialBuildState): this;
  21908. /**
  21909. * Update defines for shader compilation
  21910. * @param mesh defines the mesh to be rendered
  21911. * @param nodeMaterial defines the node material requesting the update
  21912. * @param defines defines the material defines to update
  21913. * @param useInstances specifies that instances should be used
  21914. * @param subMesh defines which submesh to render
  21915. */
  21916. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21917. serialize(): any;
  21918. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21919. protected _dumpPropertiesCode(): string;
  21920. }
  21921. }
  21922. declare module BABYLON {
  21923. /**
  21924. * Block used to output the vertex position
  21925. */
  21926. export class VertexOutputBlock extends NodeMaterialBlock {
  21927. /**
  21928. * Creates a new VertexOutputBlock
  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 vector input component
  21939. */
  21940. get vector(): NodeMaterialConnectionPoint;
  21941. protected _buildBlock(state: NodeMaterialBuildState): this;
  21942. }
  21943. }
  21944. declare module BABYLON {
  21945. /**
  21946. * Block used to output the final color
  21947. */
  21948. export class FragmentOutputBlock extends NodeMaterialBlock {
  21949. /**
  21950. * Create a new FragmentOutputBlock
  21951. * @param name defines the block name
  21952. */
  21953. constructor(name: string);
  21954. /**
  21955. * Gets the current class name
  21956. * @returns the class name
  21957. */
  21958. getClassName(): string;
  21959. /**
  21960. * Gets the rgba input component
  21961. */
  21962. get rgba(): NodeMaterialConnectionPoint;
  21963. /**
  21964. * Gets the rgb input component
  21965. */
  21966. get rgb(): NodeMaterialConnectionPoint;
  21967. /**
  21968. * Gets the a input component
  21969. */
  21970. get a(): NodeMaterialConnectionPoint;
  21971. protected _buildBlock(state: NodeMaterialBuildState): this;
  21972. }
  21973. }
  21974. declare module BABYLON {
  21975. /**
  21976. * Block used for the particle ramp gradient section
  21977. */
  21978. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21979. /**
  21980. * Create a new ParticleRampGradientBlock
  21981. * @param name defines the block name
  21982. */
  21983. constructor(name: string);
  21984. /**
  21985. * Gets the current class name
  21986. * @returns the class name
  21987. */
  21988. getClassName(): string;
  21989. /**
  21990. * Gets the color input component
  21991. */
  21992. get color(): NodeMaterialConnectionPoint;
  21993. /**
  21994. * Gets the rampColor output component
  21995. */
  21996. get rampColor(): NodeMaterialConnectionPoint;
  21997. /**
  21998. * Initialize the block and prepare the context for build
  21999. * @param state defines the state that will be used for the build
  22000. */
  22001. initialize(state: NodeMaterialBuildState): void;
  22002. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22003. }
  22004. }
  22005. declare module BABYLON {
  22006. /**
  22007. * Block used for the particle blend multiply section
  22008. */
  22009. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22010. /**
  22011. * Create a new ParticleBlendMultiplyBlock
  22012. * @param name defines the block name
  22013. */
  22014. constructor(name: string);
  22015. /**
  22016. * Gets the current class name
  22017. * @returns the class name
  22018. */
  22019. getClassName(): string;
  22020. /**
  22021. * Gets the color input component
  22022. */
  22023. get color(): NodeMaterialConnectionPoint;
  22024. /**
  22025. * Gets the alphaTexture input component
  22026. */
  22027. get alphaTexture(): NodeMaterialConnectionPoint;
  22028. /**
  22029. * Gets the alphaColor input component
  22030. */
  22031. get alphaColor(): NodeMaterialConnectionPoint;
  22032. /**
  22033. * Gets the blendColor output component
  22034. */
  22035. get blendColor(): NodeMaterialConnectionPoint;
  22036. /**
  22037. * Initialize the block and prepare the context for build
  22038. * @param state defines the state that will be used for the build
  22039. */
  22040. initialize(state: NodeMaterialBuildState): void;
  22041. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22042. }
  22043. }
  22044. declare module BABYLON {
  22045. /**
  22046. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22047. */
  22048. export class VectorMergerBlock extends NodeMaterialBlock {
  22049. /**
  22050. * Create a new VectorMergerBlock
  22051. * @param name defines the block name
  22052. */
  22053. constructor(name: string);
  22054. /**
  22055. * Gets the current class name
  22056. * @returns the class name
  22057. */
  22058. getClassName(): string;
  22059. /**
  22060. * Gets the xyz component (input)
  22061. */
  22062. get xyzIn(): NodeMaterialConnectionPoint;
  22063. /**
  22064. * Gets the xy component (input)
  22065. */
  22066. get xyIn(): NodeMaterialConnectionPoint;
  22067. /**
  22068. * Gets the x component (input)
  22069. */
  22070. get x(): NodeMaterialConnectionPoint;
  22071. /**
  22072. * Gets the y component (input)
  22073. */
  22074. get y(): NodeMaterialConnectionPoint;
  22075. /**
  22076. * Gets the z component (input)
  22077. */
  22078. get z(): NodeMaterialConnectionPoint;
  22079. /**
  22080. * Gets the w component (input)
  22081. */
  22082. get w(): NodeMaterialConnectionPoint;
  22083. /**
  22084. * Gets the xyzw component (output)
  22085. */
  22086. get xyzw(): NodeMaterialConnectionPoint;
  22087. /**
  22088. * Gets the xyz component (output)
  22089. */
  22090. get xyzOut(): NodeMaterialConnectionPoint;
  22091. /**
  22092. * Gets the xy component (output)
  22093. */
  22094. get xyOut(): NodeMaterialConnectionPoint;
  22095. /**
  22096. * Gets the xy component (output)
  22097. * @deprecated Please use xyOut instead.
  22098. */
  22099. get xy(): NodeMaterialConnectionPoint;
  22100. /**
  22101. * Gets the xyz component (output)
  22102. * @deprecated Please use xyzOut instead.
  22103. */
  22104. get xyz(): NodeMaterialConnectionPoint;
  22105. protected _buildBlock(state: NodeMaterialBuildState): this;
  22106. }
  22107. }
  22108. declare module BABYLON {
  22109. /**
  22110. * Block used to remap a float from a range to a new one
  22111. */
  22112. export class RemapBlock extends NodeMaterialBlock {
  22113. /**
  22114. * Gets or sets the source range
  22115. */
  22116. sourceRange: Vector2;
  22117. /**
  22118. * Gets or sets the target range
  22119. */
  22120. targetRange: Vector2;
  22121. /**
  22122. * Creates a new RemapBlock
  22123. * @param name defines the block name
  22124. */
  22125. constructor(name: string);
  22126. /**
  22127. * Gets the current class name
  22128. * @returns the class name
  22129. */
  22130. getClassName(): string;
  22131. /**
  22132. * Gets the input component
  22133. */
  22134. get input(): NodeMaterialConnectionPoint;
  22135. /**
  22136. * Gets the source min input component
  22137. */
  22138. get sourceMin(): NodeMaterialConnectionPoint;
  22139. /**
  22140. * Gets the source max input component
  22141. */
  22142. get sourceMax(): NodeMaterialConnectionPoint;
  22143. /**
  22144. * Gets the target min input component
  22145. */
  22146. get targetMin(): NodeMaterialConnectionPoint;
  22147. /**
  22148. * Gets the target max input component
  22149. */
  22150. get targetMax(): NodeMaterialConnectionPoint;
  22151. /**
  22152. * Gets the output component
  22153. */
  22154. get output(): NodeMaterialConnectionPoint;
  22155. protected _buildBlock(state: NodeMaterialBuildState): this;
  22156. protected _dumpPropertiesCode(): string;
  22157. serialize(): any;
  22158. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22159. }
  22160. }
  22161. declare module BABYLON {
  22162. /**
  22163. * Block used to multiply 2 values
  22164. */
  22165. export class MultiplyBlock extends NodeMaterialBlock {
  22166. /**
  22167. * Creates a new MultiplyBlock
  22168. * @param name defines the block name
  22169. */
  22170. constructor(name: string);
  22171. /**
  22172. * Gets the current class name
  22173. * @returns the class name
  22174. */
  22175. getClassName(): string;
  22176. /**
  22177. * Gets the left operand input component
  22178. */
  22179. get left(): NodeMaterialConnectionPoint;
  22180. /**
  22181. * Gets the right operand input component
  22182. */
  22183. get right(): NodeMaterialConnectionPoint;
  22184. /**
  22185. * Gets the output component
  22186. */
  22187. get output(): NodeMaterialConnectionPoint;
  22188. protected _buildBlock(state: NodeMaterialBuildState): this;
  22189. }
  22190. }
  22191. declare module BABYLON {
  22192. /**
  22193. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22194. */
  22195. export class ColorSplitterBlock extends NodeMaterialBlock {
  22196. /**
  22197. * Create a new ColorSplitterBlock
  22198. * @param name defines the block name
  22199. */
  22200. constructor(name: string);
  22201. /**
  22202. * Gets the current class name
  22203. * @returns the class name
  22204. */
  22205. getClassName(): string;
  22206. /**
  22207. * Gets the rgba component (input)
  22208. */
  22209. get rgba(): NodeMaterialConnectionPoint;
  22210. /**
  22211. * Gets the rgb component (input)
  22212. */
  22213. get rgbIn(): NodeMaterialConnectionPoint;
  22214. /**
  22215. * Gets the rgb component (output)
  22216. */
  22217. get rgbOut(): NodeMaterialConnectionPoint;
  22218. /**
  22219. * Gets the r component (output)
  22220. */
  22221. get r(): NodeMaterialConnectionPoint;
  22222. /**
  22223. * Gets the g component (output)
  22224. */
  22225. get g(): NodeMaterialConnectionPoint;
  22226. /**
  22227. * Gets the b component (output)
  22228. */
  22229. get b(): NodeMaterialConnectionPoint;
  22230. /**
  22231. * Gets the a component (output)
  22232. */
  22233. get a(): NodeMaterialConnectionPoint;
  22234. protected _inputRename(name: string): string;
  22235. protected _outputRename(name: string): string;
  22236. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22237. }
  22238. }
  22239. declare module BABYLON {
  22240. /**
  22241. * Interface used to configure the node material editor
  22242. */
  22243. export interface INodeMaterialEditorOptions {
  22244. /** Define the URl to load node editor script */
  22245. editorURL?: string;
  22246. }
  22247. /** @hidden */
  22248. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22249. NORMAL: boolean;
  22250. TANGENT: boolean;
  22251. UV1: boolean;
  22252. /** BONES */
  22253. NUM_BONE_INFLUENCERS: number;
  22254. BonesPerMesh: number;
  22255. BONETEXTURE: boolean;
  22256. /** MORPH TARGETS */
  22257. MORPHTARGETS: boolean;
  22258. MORPHTARGETS_NORMAL: boolean;
  22259. MORPHTARGETS_TANGENT: boolean;
  22260. MORPHTARGETS_UV: boolean;
  22261. NUM_MORPH_INFLUENCERS: number;
  22262. /** IMAGE PROCESSING */
  22263. IMAGEPROCESSING: boolean;
  22264. VIGNETTE: boolean;
  22265. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22266. VIGNETTEBLENDMODEOPAQUE: boolean;
  22267. TONEMAPPING: boolean;
  22268. TONEMAPPING_ACES: boolean;
  22269. CONTRAST: boolean;
  22270. EXPOSURE: boolean;
  22271. COLORCURVES: boolean;
  22272. COLORGRADING: boolean;
  22273. COLORGRADING3D: boolean;
  22274. SAMPLER3DGREENDEPTH: boolean;
  22275. SAMPLER3DBGRMAP: boolean;
  22276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22277. /** MISC. */
  22278. BUMPDIRECTUV: number;
  22279. constructor();
  22280. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22281. }
  22282. /**
  22283. * Class used to configure NodeMaterial
  22284. */
  22285. export interface INodeMaterialOptions {
  22286. /**
  22287. * Defines if blocks should emit comments
  22288. */
  22289. emitComments: boolean;
  22290. }
  22291. /**
  22292. * Class used to create a node based material built by assembling shader blocks
  22293. */
  22294. export class NodeMaterial extends PushMaterial {
  22295. private static _BuildIdGenerator;
  22296. private _options;
  22297. private _vertexCompilationState;
  22298. private _fragmentCompilationState;
  22299. private _sharedData;
  22300. private _buildId;
  22301. private _buildWasSuccessful;
  22302. private _cachedWorldViewMatrix;
  22303. private _cachedWorldViewProjectionMatrix;
  22304. private _optimizers;
  22305. private _animationFrame;
  22306. /** Define the Url to load node editor script */
  22307. static EditorURL: string;
  22308. /** Define the Url to load snippets */
  22309. static SnippetUrl: string;
  22310. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22311. static IgnoreTexturesAtLoadTime: boolean;
  22312. private BJSNODEMATERIALEDITOR;
  22313. /** Get the inspector from bundle or global */
  22314. private _getGlobalNodeMaterialEditor;
  22315. /**
  22316. * Snippet ID if the material was created from the snippet server
  22317. */
  22318. snippetId: string;
  22319. /**
  22320. * Gets or sets data used by visual editor
  22321. * @see https://nme.babylonjs.com
  22322. */
  22323. editorData: any;
  22324. /**
  22325. * 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)
  22326. */
  22327. ignoreAlpha: boolean;
  22328. /**
  22329. * Defines the maximum number of lights that can be used in the material
  22330. */
  22331. maxSimultaneousLights: number;
  22332. /**
  22333. * Observable raised when the material is built
  22334. */
  22335. onBuildObservable: Observable<NodeMaterial>;
  22336. /**
  22337. * Gets or sets the root nodes of the material vertex shader
  22338. */
  22339. _vertexOutputNodes: NodeMaterialBlock[];
  22340. /**
  22341. * Gets or sets the root nodes of the material fragment (pixel) shader
  22342. */
  22343. _fragmentOutputNodes: NodeMaterialBlock[];
  22344. /** Gets or sets options to control the node material overall behavior */
  22345. get options(): INodeMaterialOptions;
  22346. set options(options: INodeMaterialOptions);
  22347. /**
  22348. * Default configuration related to image processing available in the standard Material.
  22349. */
  22350. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22351. /**
  22352. * Gets the image processing configuration used either in this material.
  22353. */
  22354. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22355. /**
  22356. * Sets the Default image processing configuration used either in the this material.
  22357. *
  22358. * If sets to null, the scene one is in use.
  22359. */
  22360. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22361. /**
  22362. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22363. */
  22364. attachedBlocks: NodeMaterialBlock[];
  22365. /**
  22366. * Specifies the mode of the node material
  22367. * @hidden
  22368. */
  22369. _mode: NodeMaterialModes;
  22370. /**
  22371. * Gets the mode property
  22372. */
  22373. get mode(): NodeMaterialModes;
  22374. /**
  22375. * Create a new node based material
  22376. * @param name defines the material name
  22377. * @param scene defines the hosting scene
  22378. * @param options defines creation option
  22379. */
  22380. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22381. /**
  22382. * Gets the current class name of the material e.g. "NodeMaterial"
  22383. * @returns the class name
  22384. */
  22385. getClassName(): string;
  22386. /**
  22387. * Keep track of the image processing observer to allow dispose and replace.
  22388. */
  22389. private _imageProcessingObserver;
  22390. /**
  22391. * Attaches a new image processing configuration to the Standard Material.
  22392. * @param configuration
  22393. */
  22394. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22395. /**
  22396. * Get a block by its name
  22397. * @param name defines the name of the block to retrieve
  22398. * @returns the required block or null if not found
  22399. */
  22400. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22401. /**
  22402. * Get a block by its name
  22403. * @param predicate defines the predicate used to find the good candidate
  22404. * @returns the required block or null if not found
  22405. */
  22406. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22407. /**
  22408. * Get an input block by its name
  22409. * @param predicate defines the predicate used to find the good candidate
  22410. * @returns the required input block or null if not found
  22411. */
  22412. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22413. /**
  22414. * Gets the list of input blocks attached to this material
  22415. * @returns an array of InputBlocks
  22416. */
  22417. getInputBlocks(): InputBlock[];
  22418. /**
  22419. * Adds a new optimizer to the list of optimizers
  22420. * @param optimizer defines the optimizers to add
  22421. * @returns the current material
  22422. */
  22423. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22424. /**
  22425. * Remove an optimizer from the list of optimizers
  22426. * @param optimizer defines the optimizers to remove
  22427. * @returns the current material
  22428. */
  22429. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22430. /**
  22431. * Add a new block to the list of output nodes
  22432. * @param node defines the node to add
  22433. * @returns the current material
  22434. */
  22435. addOutputNode(node: NodeMaterialBlock): this;
  22436. /**
  22437. * Remove a block from the list of root nodes
  22438. * @param node defines the node to remove
  22439. * @returns the current material
  22440. */
  22441. removeOutputNode(node: NodeMaterialBlock): this;
  22442. private _addVertexOutputNode;
  22443. private _removeVertexOutputNode;
  22444. private _addFragmentOutputNode;
  22445. private _removeFragmentOutputNode;
  22446. /**
  22447. * Specifies if the material will require alpha blending
  22448. * @returns a boolean specifying if alpha blending is needed
  22449. */
  22450. needAlphaBlending(): boolean;
  22451. /**
  22452. * Specifies if this material should be rendered in alpha test mode
  22453. * @returns a boolean specifying if an alpha test is needed.
  22454. */
  22455. needAlphaTesting(): boolean;
  22456. private _initializeBlock;
  22457. private _resetDualBlocks;
  22458. /**
  22459. * Remove a block from the current node material
  22460. * @param block defines the block to remove
  22461. */
  22462. removeBlock(block: NodeMaterialBlock): void;
  22463. /**
  22464. * Build the material and generates the inner effect
  22465. * @param verbose defines if the build should log activity
  22466. */
  22467. build(verbose?: boolean): void;
  22468. /**
  22469. * Runs an otpimization phase to try to improve the shader code
  22470. */
  22471. optimize(): void;
  22472. private _prepareDefinesForAttributes;
  22473. /**
  22474. * Create a post process from the material
  22475. * @param camera The camera to apply the render pass to.
  22476. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22478. * @param engine The engine which the post process will be applied. (default: current engine)
  22479. * @param reusable If the post process can be reused on the same frame. (default: false)
  22480. * @param textureType Type of textures used when performing the post process. (default: 0)
  22481. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22482. * @returns the post process created
  22483. */
  22484. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22485. /**
  22486. * Create the post process effect from the material
  22487. * @param postProcess The post process to create the effect for
  22488. */
  22489. createEffectForPostProcess(postProcess: PostProcess): void;
  22490. private _createEffectOrPostProcess;
  22491. private _createEffectForParticles;
  22492. /**
  22493. * Create the effect to be used as the custom effect for a particle system
  22494. * @param particleSystem Particle system to create the effect for
  22495. * @param onCompiled defines a function to call when the effect creation is successful
  22496. * @param onError defines a function to call when the effect creation has failed
  22497. */
  22498. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22499. private _processDefines;
  22500. /**
  22501. * Get if the submesh is ready to be used and all its information available.
  22502. * Child classes can use it to update shaders
  22503. * @param mesh defines the mesh to check
  22504. * @param subMesh defines which submesh to check
  22505. * @param useInstances specifies that instances should be used
  22506. * @returns a boolean indicating that the submesh is ready or not
  22507. */
  22508. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22509. /**
  22510. * Get a string representing the shaders built by the current node graph
  22511. */
  22512. get compiledShaders(): string;
  22513. /**
  22514. * Binds the world matrix to the material
  22515. * @param world defines the world transformation matrix
  22516. */
  22517. bindOnlyWorldMatrix(world: Matrix): void;
  22518. /**
  22519. * Binds the submesh to this material by preparing the effect and shader to draw
  22520. * @param world defines the world transformation matrix
  22521. * @param mesh defines the mesh containing the submesh
  22522. * @param subMesh defines the submesh to bind the material to
  22523. */
  22524. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22525. /**
  22526. * Gets the active textures from the material
  22527. * @returns an array of textures
  22528. */
  22529. getActiveTextures(): BaseTexture[];
  22530. /**
  22531. * Gets the list of texture blocks
  22532. * @returns an array of texture blocks
  22533. */
  22534. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22535. /**
  22536. * Specifies if the material uses a texture
  22537. * @param texture defines the texture to check against the material
  22538. * @returns a boolean specifying if the material uses the texture
  22539. */
  22540. hasTexture(texture: BaseTexture): boolean;
  22541. /**
  22542. * Disposes the material
  22543. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22544. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22545. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22546. */
  22547. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22548. /** Creates the node editor window. */
  22549. private _createNodeEditor;
  22550. /**
  22551. * Launch the node material editor
  22552. * @param config Define the configuration of the editor
  22553. * @return a promise fulfilled when the node editor is visible
  22554. */
  22555. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22556. /**
  22557. * Clear the current material
  22558. */
  22559. clear(): void;
  22560. /**
  22561. * Clear the current material and set it to a default state
  22562. */
  22563. setToDefault(): void;
  22564. /**
  22565. * Clear the current material and set it to a default state for post process
  22566. */
  22567. setToDefaultPostProcess(): void;
  22568. /**
  22569. * Clear the current material and set it to a default state for particle
  22570. */
  22571. setToDefaultParticle(): void;
  22572. /**
  22573. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22574. * @param url defines the url to load from
  22575. * @returns a promise that will fullfil when the material is fully loaded
  22576. */
  22577. loadAsync(url: string): Promise<void>;
  22578. private _gatherBlocks;
  22579. /**
  22580. * Generate a string containing the code declaration required to create an equivalent of this material
  22581. * @returns a string
  22582. */
  22583. generateCode(): string;
  22584. /**
  22585. * Serializes this material in a JSON representation
  22586. * @returns the serialized material object
  22587. */
  22588. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22589. private _restoreConnections;
  22590. /**
  22591. * Clear the current graph and load a new one from a serialization object
  22592. * @param source defines the JSON representation of the material
  22593. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22594. * @param merge defines whether or not the source must be merged or replace the current content
  22595. */
  22596. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22597. /**
  22598. * Makes a duplicate of the current material.
  22599. * @param name - name to use for the new material.
  22600. */
  22601. clone(name: string): NodeMaterial;
  22602. /**
  22603. * Creates a node material from parsed material data
  22604. * @param source defines the JSON representation of the material
  22605. * @param scene defines the hosting scene
  22606. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22607. * @returns a new node material
  22608. */
  22609. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22610. /**
  22611. * Creates a node material from a snippet saved in a remote file
  22612. * @param name defines the name of the material to create
  22613. * @param url defines the url to load from
  22614. * @param scene defines the hosting scene
  22615. * @returns a promise that will resolve to the new node material
  22616. */
  22617. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22618. /**
  22619. * Creates a node material from a snippet saved by the node material editor
  22620. * @param snippetId defines the snippet to load
  22621. * @param scene defines the hosting scene
  22622. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22623. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22624. * @returns a promise that will resolve to the new node material
  22625. */
  22626. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22627. /**
  22628. * Creates a new node material set to default basic configuration
  22629. * @param name defines the name of the material
  22630. * @param scene defines the hosting scene
  22631. * @returns a new NodeMaterial
  22632. */
  22633. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22634. }
  22635. }
  22636. declare module BABYLON {
  22637. /**
  22638. * Size options for a post process
  22639. */
  22640. export type PostProcessOptions = {
  22641. width: number;
  22642. height: number;
  22643. };
  22644. /**
  22645. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22646. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22647. */
  22648. export class PostProcess {
  22649. /**
  22650. * Gets or sets the unique id of the post process
  22651. */
  22652. uniqueId: number;
  22653. /** Name of the PostProcess. */
  22654. name: string;
  22655. /**
  22656. * Width of the texture to apply the post process on
  22657. */
  22658. width: number;
  22659. /**
  22660. * Height of the texture to apply the post process on
  22661. */
  22662. height: number;
  22663. /**
  22664. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22665. */
  22666. nodeMaterialSource: Nullable<NodeMaterial>;
  22667. /**
  22668. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22669. * @hidden
  22670. */
  22671. _outputTexture: Nullable<InternalTexture>;
  22672. /**
  22673. * Sampling mode used by the shader
  22674. * See https://doc.babylonjs.com/classes/3.1/texture
  22675. */
  22676. renderTargetSamplingMode: number;
  22677. /**
  22678. * Clear color to use when screen clearing
  22679. */
  22680. clearColor: Color4;
  22681. /**
  22682. * If the buffer needs to be cleared before applying the post process. (default: true)
  22683. * Should be set to false if shader will overwrite all previous pixels.
  22684. */
  22685. autoClear: boolean;
  22686. /**
  22687. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22688. */
  22689. alphaMode: number;
  22690. /**
  22691. * Sets the setAlphaBlendConstants of the babylon engine
  22692. */
  22693. alphaConstants: Color4;
  22694. /**
  22695. * Animations to be used for the post processing
  22696. */
  22697. animations: Animation[];
  22698. /**
  22699. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22700. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22701. */
  22702. enablePixelPerfectMode: boolean;
  22703. /**
  22704. * Force the postprocess to be applied without taking in account viewport
  22705. */
  22706. forceFullscreenViewport: boolean;
  22707. /**
  22708. * List of inspectable custom properties (used by the Inspector)
  22709. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22710. */
  22711. inspectableCustomProperties: IInspectable[];
  22712. /**
  22713. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22714. *
  22715. * | Value | Type | Description |
  22716. * | ----- | ----------------------------------- | ----------- |
  22717. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22718. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22719. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22720. *
  22721. */
  22722. scaleMode: number;
  22723. /**
  22724. * Force textures to be a power of two (default: false)
  22725. */
  22726. alwaysForcePOT: boolean;
  22727. private _samples;
  22728. /**
  22729. * Number of sample textures (default: 1)
  22730. */
  22731. get samples(): number;
  22732. set samples(n: number);
  22733. /**
  22734. * Modify the scale of the post process to be the same as the viewport (default: false)
  22735. */
  22736. adaptScaleToCurrentViewport: boolean;
  22737. private _camera;
  22738. protected _scene: Scene;
  22739. private _engine;
  22740. private _options;
  22741. private _reusable;
  22742. private _textureType;
  22743. private _textureFormat;
  22744. /**
  22745. * Smart array of input and output textures for the post process.
  22746. * @hidden
  22747. */
  22748. _textures: SmartArray<InternalTexture>;
  22749. /**
  22750. * The index in _textures that corresponds to the output texture.
  22751. * @hidden
  22752. */
  22753. _currentRenderTextureInd: number;
  22754. private _effect;
  22755. private _samplers;
  22756. private _fragmentUrl;
  22757. private _vertexUrl;
  22758. private _parameters;
  22759. private _scaleRatio;
  22760. protected _indexParameters: any;
  22761. private _shareOutputWithPostProcess;
  22762. private _texelSize;
  22763. private _forcedOutputTexture;
  22764. /**
  22765. * Returns the fragment url or shader name used in the post process.
  22766. * @returns the fragment url or name in the shader store.
  22767. */
  22768. getEffectName(): string;
  22769. /**
  22770. * An event triggered when the postprocess is activated.
  22771. */
  22772. onActivateObservable: Observable<Camera>;
  22773. private _onActivateObserver;
  22774. /**
  22775. * A function that is added to the onActivateObservable
  22776. */
  22777. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22778. /**
  22779. * An event triggered when the postprocess changes its size.
  22780. */
  22781. onSizeChangedObservable: Observable<PostProcess>;
  22782. private _onSizeChangedObserver;
  22783. /**
  22784. * A function that is added to the onSizeChangedObservable
  22785. */
  22786. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22787. /**
  22788. * An event triggered when the postprocess applies its effect.
  22789. */
  22790. onApplyObservable: Observable<Effect>;
  22791. private _onApplyObserver;
  22792. /**
  22793. * A function that is added to the onApplyObservable
  22794. */
  22795. set onApply(callback: (effect: Effect) => void);
  22796. /**
  22797. * An event triggered before rendering the postprocess
  22798. */
  22799. onBeforeRenderObservable: Observable<Effect>;
  22800. private _onBeforeRenderObserver;
  22801. /**
  22802. * A function that is added to the onBeforeRenderObservable
  22803. */
  22804. set onBeforeRender(callback: (effect: Effect) => void);
  22805. /**
  22806. * An event triggered after rendering the postprocess
  22807. */
  22808. onAfterRenderObservable: Observable<Effect>;
  22809. private _onAfterRenderObserver;
  22810. /**
  22811. * A function that is added to the onAfterRenderObservable
  22812. */
  22813. set onAfterRender(callback: (efect: Effect) => void);
  22814. /**
  22815. * 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
  22816. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22817. */
  22818. get inputTexture(): InternalTexture;
  22819. set inputTexture(value: InternalTexture);
  22820. /**
  22821. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22822. * the only way to unset it is to use this function to restore its internal state
  22823. */
  22824. restoreDefaultInputTexture(): void;
  22825. /**
  22826. * Gets the camera which post process is applied to.
  22827. * @returns The camera the post process is applied to.
  22828. */
  22829. getCamera(): Camera;
  22830. /**
  22831. * Gets the texel size of the postprocess.
  22832. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22833. */
  22834. get texelSize(): Vector2;
  22835. /**
  22836. * Creates a new instance PostProcess
  22837. * @param name The name of the PostProcess.
  22838. * @param fragmentUrl The url of the fragment shader to be used.
  22839. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22840. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22841. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22842. * @param camera The camera to apply the render pass to.
  22843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22844. * @param engine The engine which the post process will be applied. (default: current engine)
  22845. * @param reusable If the post process can be reused on the same frame. (default: false)
  22846. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22847. * @param textureType Type of textures used when performing the post process. (default: 0)
  22848. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22849. * @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
  22850. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22851. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22852. */
  22853. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  22854. /**
  22855. * Gets a string identifying the name of the class
  22856. * @returns "PostProcess" string
  22857. */
  22858. getClassName(): string;
  22859. /**
  22860. * Gets the engine which this post process belongs to.
  22861. * @returns The engine the post process was enabled with.
  22862. */
  22863. getEngine(): Engine;
  22864. /**
  22865. * The effect that is created when initializing the post process.
  22866. * @returns The created effect corresponding the the postprocess.
  22867. */
  22868. getEffect(): Effect;
  22869. /**
  22870. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22871. * @param postProcess The post process to share the output with.
  22872. * @returns This post process.
  22873. */
  22874. shareOutputWith(postProcess: PostProcess): PostProcess;
  22875. /**
  22876. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22877. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22878. */
  22879. useOwnOutput(): void;
  22880. /**
  22881. * Updates the effect with the current post process compile time values and recompiles the shader.
  22882. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22883. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22884. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22885. * @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
  22886. * @param onCompiled Called when the shader has been compiled.
  22887. * @param onError Called if there is an error when compiling a shader.
  22888. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22889. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22890. */
  22891. 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;
  22892. /**
  22893. * The post process is reusable if it can be used multiple times within one frame.
  22894. * @returns If the post process is reusable
  22895. */
  22896. isReusable(): boolean;
  22897. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22898. markTextureDirty(): void;
  22899. /**
  22900. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22901. * 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.
  22902. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22903. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22904. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22905. * @returns The target texture that was bound to be written to.
  22906. */
  22907. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22908. /**
  22909. * If the post process is supported.
  22910. */
  22911. get isSupported(): boolean;
  22912. /**
  22913. * The aspect ratio of the output texture.
  22914. */
  22915. get aspectRatio(): number;
  22916. /**
  22917. * Get a value indicating if the post-process is ready to be used
  22918. * @returns true if the post-process is ready (shader is compiled)
  22919. */
  22920. isReady(): boolean;
  22921. /**
  22922. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22923. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22924. */
  22925. apply(): Nullable<Effect>;
  22926. private _disposeTextures;
  22927. /**
  22928. * Disposes the post process.
  22929. * @param camera The camera to dispose the post process on.
  22930. */
  22931. dispose(camera?: Camera): void;
  22932. /**
  22933. * Serializes the particle system to a JSON object
  22934. * @returns the JSON object
  22935. */
  22936. serialize(): any;
  22937. /**
  22938. * Creates a material from parsed material data
  22939. * @param parsedPostProcess defines parsed post process data
  22940. * @param scene defines the hosting scene
  22941. * @param rootUrl defines the root URL to use to load textures
  22942. * @returns a new post process
  22943. */
  22944. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22945. }
  22946. }
  22947. declare module BABYLON {
  22948. /** @hidden */
  22949. export var kernelBlurVaryingDeclaration: {
  22950. name: string;
  22951. shader: string;
  22952. };
  22953. }
  22954. declare module BABYLON {
  22955. /** @hidden */
  22956. export var kernelBlurFragment: {
  22957. name: string;
  22958. shader: string;
  22959. };
  22960. }
  22961. declare module BABYLON {
  22962. /** @hidden */
  22963. export var kernelBlurFragment2: {
  22964. name: string;
  22965. shader: string;
  22966. };
  22967. }
  22968. declare module BABYLON {
  22969. /** @hidden */
  22970. export var kernelBlurPixelShader: {
  22971. name: string;
  22972. shader: string;
  22973. };
  22974. }
  22975. declare module BABYLON {
  22976. /** @hidden */
  22977. export var kernelBlurVertex: {
  22978. name: string;
  22979. shader: string;
  22980. };
  22981. }
  22982. declare module BABYLON {
  22983. /** @hidden */
  22984. export var kernelBlurVertexShader: {
  22985. name: string;
  22986. shader: string;
  22987. };
  22988. }
  22989. declare module BABYLON {
  22990. /**
  22991. * The Blur Post Process which blurs an image based on a kernel and direction.
  22992. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22993. */
  22994. export class BlurPostProcess extends PostProcess {
  22995. private blockCompilation;
  22996. protected _kernel: number;
  22997. protected _idealKernel: number;
  22998. protected _packedFloat: boolean;
  22999. private _staticDefines;
  23000. /** The direction in which to blur the image. */
  23001. direction: Vector2;
  23002. /**
  23003. * Sets the length in pixels of the blur sample region
  23004. */
  23005. set kernel(v: number);
  23006. /**
  23007. * Gets the length in pixels of the blur sample region
  23008. */
  23009. get kernel(): number;
  23010. /**
  23011. * Sets wether or not the blur needs to unpack/repack floats
  23012. */
  23013. set packedFloat(v: boolean);
  23014. /**
  23015. * Gets wether or not the blur is unpacking/repacking floats
  23016. */
  23017. get packedFloat(): boolean;
  23018. /**
  23019. * Gets a string identifying the name of the class
  23020. * @returns "BlurPostProcess" string
  23021. */
  23022. getClassName(): string;
  23023. /**
  23024. * Creates a new instance BlurPostProcess
  23025. * @param name The name of the effect.
  23026. * @param direction The direction in which to blur the image.
  23027. * @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.
  23028. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23029. * @param camera The camera to apply the render pass to.
  23030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23031. * @param engine The engine which the post process will be applied. (default: current engine)
  23032. * @param reusable If the post process can be reused on the same frame. (default: false)
  23033. * @param textureType Type of textures used when performing the post process. (default: 0)
  23034. * @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)
  23035. */
  23036. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23037. /**
  23038. * Updates the effect with the current post process compile time values and recompiles the shader.
  23039. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23040. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23041. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23042. * @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
  23043. * @param onCompiled Called when the shader has been compiled.
  23044. * @param onError Called if there is an error when compiling a shader.
  23045. */
  23046. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23047. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23048. /**
  23049. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23050. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23051. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23052. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23053. * The gaps between physical kernels are compensated for in the weighting of the samples
  23054. * @param idealKernel Ideal blur kernel.
  23055. * @return Nearest best kernel.
  23056. */
  23057. protected _nearestBestKernel(idealKernel: number): number;
  23058. /**
  23059. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23060. * @param x The point on the Gaussian distribution to sample.
  23061. * @return the value of the Gaussian function at x.
  23062. */
  23063. protected _gaussianWeight(x: number): number;
  23064. /**
  23065. * Generates a string that can be used as a floating point number in GLSL.
  23066. * @param x Value to print.
  23067. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23068. * @return GLSL float string.
  23069. */
  23070. protected _glslFloat(x: number, decimalFigures?: number): string;
  23071. /** @hidden */
  23072. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23073. }
  23074. }
  23075. declare module BABYLON {
  23076. /**
  23077. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23078. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23079. * You can then easily use it as a reflectionTexture on a flat surface.
  23080. * In case the surface is not a plane, please consider relying on reflection probes.
  23081. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23082. */
  23083. export class MirrorTexture extends RenderTargetTexture {
  23084. private scene;
  23085. /**
  23086. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23087. * 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.
  23088. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23089. */
  23090. mirrorPlane: Plane;
  23091. /**
  23092. * Define the blur ratio used to blur the reflection if needed.
  23093. */
  23094. set blurRatio(value: number);
  23095. get blurRatio(): number;
  23096. /**
  23097. * Define the adaptive blur kernel used to blur the reflection if needed.
  23098. * This will autocompute the closest best match for the `blurKernel`
  23099. */
  23100. set adaptiveBlurKernel(value: number);
  23101. /**
  23102. * Define the blur kernel used to blur the reflection if needed.
  23103. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23104. */
  23105. set blurKernel(value: number);
  23106. /**
  23107. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23108. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23109. */
  23110. set blurKernelX(value: number);
  23111. get blurKernelX(): number;
  23112. /**
  23113. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23114. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23115. */
  23116. set blurKernelY(value: number);
  23117. get blurKernelY(): number;
  23118. private _autoComputeBlurKernel;
  23119. protected _onRatioRescale(): void;
  23120. private _updateGammaSpace;
  23121. private _imageProcessingConfigChangeObserver;
  23122. private _transformMatrix;
  23123. private _mirrorMatrix;
  23124. private _savedViewMatrix;
  23125. private _blurX;
  23126. private _blurY;
  23127. private _adaptiveBlurKernel;
  23128. private _blurKernelX;
  23129. private _blurKernelY;
  23130. private _blurRatio;
  23131. /**
  23132. * Instantiates a Mirror Texture.
  23133. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23134. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23135. * You can then easily use it as a reflectionTexture on a flat surface.
  23136. * In case the surface is not a plane, please consider relying on reflection probes.
  23137. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23138. * @param name
  23139. * @param size
  23140. * @param scene
  23141. * @param generateMipMaps
  23142. * @param type
  23143. * @param samplingMode
  23144. * @param generateDepthBuffer
  23145. */
  23146. constructor(name: string, size: number | {
  23147. width: number;
  23148. height: number;
  23149. } | {
  23150. ratio: number;
  23151. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23152. private _preparePostProcesses;
  23153. /**
  23154. * Clone the mirror texture.
  23155. * @returns the cloned texture
  23156. */
  23157. clone(): MirrorTexture;
  23158. /**
  23159. * Serialize the texture to a JSON representation you could use in Parse later on
  23160. * @returns the serialized JSON representation
  23161. */
  23162. serialize(): any;
  23163. /**
  23164. * Dispose the texture and release its associated resources.
  23165. */
  23166. dispose(): void;
  23167. }
  23168. }
  23169. declare module BABYLON {
  23170. /**
  23171. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23172. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23173. */
  23174. export class Texture extends BaseTexture {
  23175. /**
  23176. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23177. */
  23178. static SerializeBuffers: boolean;
  23179. /** @hidden */
  23180. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23181. /** @hidden */
  23182. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23183. /** @hidden */
  23184. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23185. /** nearest is mag = nearest and min = nearest and mip = linear */
  23186. static readonly NEAREST_SAMPLINGMODE: number;
  23187. /** nearest is mag = nearest and min = nearest and mip = linear */
  23188. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23189. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23190. static readonly BILINEAR_SAMPLINGMODE: number;
  23191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23192. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23193. /** Trilinear is mag = linear and min = linear and mip = linear */
  23194. static readonly TRILINEAR_SAMPLINGMODE: number;
  23195. /** Trilinear is mag = linear and min = linear and mip = linear */
  23196. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23197. /** mag = nearest and min = nearest and mip = nearest */
  23198. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23199. /** mag = nearest and min = linear and mip = nearest */
  23200. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23201. /** mag = nearest and min = linear and mip = linear */
  23202. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23203. /** mag = nearest and min = linear and mip = none */
  23204. static readonly NEAREST_LINEAR: number;
  23205. /** mag = nearest and min = nearest and mip = none */
  23206. static readonly NEAREST_NEAREST: number;
  23207. /** mag = linear and min = nearest and mip = nearest */
  23208. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23209. /** mag = linear and min = nearest and mip = linear */
  23210. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23211. /** mag = linear and min = linear and mip = none */
  23212. static readonly LINEAR_LINEAR: number;
  23213. /** mag = linear and min = nearest and mip = none */
  23214. static readonly LINEAR_NEAREST: number;
  23215. /** Explicit coordinates mode */
  23216. static readonly EXPLICIT_MODE: number;
  23217. /** Spherical coordinates mode */
  23218. static readonly SPHERICAL_MODE: number;
  23219. /** Planar coordinates mode */
  23220. static readonly PLANAR_MODE: number;
  23221. /** Cubic coordinates mode */
  23222. static readonly CUBIC_MODE: number;
  23223. /** Projection coordinates mode */
  23224. static readonly PROJECTION_MODE: number;
  23225. /** Inverse Cubic coordinates mode */
  23226. static readonly SKYBOX_MODE: number;
  23227. /** Inverse Cubic coordinates mode */
  23228. static readonly INVCUBIC_MODE: number;
  23229. /** Equirectangular coordinates mode */
  23230. static readonly EQUIRECTANGULAR_MODE: number;
  23231. /** Equirectangular Fixed coordinates mode */
  23232. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23233. /** Equirectangular Fixed Mirrored coordinates mode */
  23234. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23235. /** Texture is not repeating outside of 0..1 UVs */
  23236. static readonly CLAMP_ADDRESSMODE: number;
  23237. /** Texture is repeating outside of 0..1 UVs */
  23238. static readonly WRAP_ADDRESSMODE: number;
  23239. /** Texture is repeating and mirrored */
  23240. static readonly MIRROR_ADDRESSMODE: number;
  23241. /**
  23242. * 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
  23243. */
  23244. static UseSerializedUrlIfAny: boolean;
  23245. /**
  23246. * Define the url of the texture.
  23247. */
  23248. url: Nullable<string>;
  23249. /**
  23250. * Define an offset on the texture to offset the u coordinates of the UVs
  23251. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23252. */
  23253. uOffset: number;
  23254. /**
  23255. * Define an offset on the texture to offset the v coordinates of the UVs
  23256. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23257. */
  23258. vOffset: number;
  23259. /**
  23260. * Define an offset on the texture to scale the u coordinates of the UVs
  23261. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23262. */
  23263. uScale: number;
  23264. /**
  23265. * Define an offset on the texture to scale the v coordinates of the UVs
  23266. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23267. */
  23268. vScale: number;
  23269. /**
  23270. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23271. * @see https://doc.babylonjs.com/how_to/more_materials
  23272. */
  23273. uAng: number;
  23274. /**
  23275. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23276. * @see https://doc.babylonjs.com/how_to/more_materials
  23277. */
  23278. vAng: number;
  23279. /**
  23280. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23281. * @see https://doc.babylonjs.com/how_to/more_materials
  23282. */
  23283. wAng: number;
  23284. /**
  23285. * Defines the center of rotation (U)
  23286. */
  23287. uRotationCenter: number;
  23288. /**
  23289. * Defines the center of rotation (V)
  23290. */
  23291. vRotationCenter: number;
  23292. /**
  23293. * Defines the center of rotation (W)
  23294. */
  23295. wRotationCenter: number;
  23296. /**
  23297. * Are mip maps generated for this texture or not.
  23298. */
  23299. get noMipmap(): boolean;
  23300. /**
  23301. * List of inspectable custom properties (used by the Inspector)
  23302. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23303. */
  23304. inspectableCustomProperties: Nullable<IInspectable[]>;
  23305. private _noMipmap;
  23306. /** @hidden */
  23307. _invertY: boolean;
  23308. private _rowGenerationMatrix;
  23309. private _cachedTextureMatrix;
  23310. private _projectionModeMatrix;
  23311. private _t0;
  23312. private _t1;
  23313. private _t2;
  23314. private _cachedUOffset;
  23315. private _cachedVOffset;
  23316. private _cachedUScale;
  23317. private _cachedVScale;
  23318. private _cachedUAng;
  23319. private _cachedVAng;
  23320. private _cachedWAng;
  23321. private _cachedProjectionMatrixId;
  23322. private _cachedCoordinatesMode;
  23323. /** @hidden */
  23324. protected _initialSamplingMode: number;
  23325. /** @hidden */
  23326. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23327. private _deleteBuffer;
  23328. protected _format: Nullable<number>;
  23329. private _delayedOnLoad;
  23330. private _delayedOnError;
  23331. private _mimeType?;
  23332. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23333. get mimeType(): string | undefined;
  23334. /**
  23335. * Observable triggered once the texture has been loaded.
  23336. */
  23337. onLoadObservable: Observable<Texture>;
  23338. protected _isBlocking: boolean;
  23339. /**
  23340. * Is the texture preventing material to render while loading.
  23341. * If false, a default texture will be used instead of the loading one during the preparation step.
  23342. */
  23343. set isBlocking(value: boolean);
  23344. get isBlocking(): boolean;
  23345. /**
  23346. * Get the current sampling mode associated with the texture.
  23347. */
  23348. get samplingMode(): number;
  23349. /**
  23350. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23351. */
  23352. get invertY(): boolean;
  23353. /**
  23354. * Instantiates a new texture.
  23355. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23356. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23357. * @param url defines the url of the picture to load as a texture
  23358. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23359. * @param noMipmap defines if the texture will require mip maps or not
  23360. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23361. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23362. * @param onLoad defines a callback triggered when the texture has been loaded
  23363. * @param onError defines a callback triggered when an error occurred during the loading session
  23364. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23365. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23366. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23367. * @param mimeType defines an optional mime type information
  23368. */
  23369. 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);
  23370. /**
  23371. * Update the url (and optional buffer) of this texture if url was null during construction.
  23372. * @param url the url of the texture
  23373. * @param buffer the buffer of the texture (defaults to null)
  23374. * @param onLoad callback called when the texture is loaded (defaults to null)
  23375. */
  23376. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23377. /**
  23378. * Finish the loading sequence of a texture flagged as delayed load.
  23379. * @hidden
  23380. */
  23381. delayLoad(): void;
  23382. private _prepareRowForTextureGeneration;
  23383. /**
  23384. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23385. * @returns the transform matrix of the texture.
  23386. */
  23387. getTextureMatrix(uBase?: number): Matrix;
  23388. /**
  23389. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23390. * @returns The reflection texture transform
  23391. */
  23392. getReflectionTextureMatrix(): Matrix;
  23393. /**
  23394. * Clones the texture.
  23395. * @returns the cloned texture
  23396. */
  23397. clone(): Texture;
  23398. /**
  23399. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23400. * @returns The JSON representation of the texture
  23401. */
  23402. serialize(): any;
  23403. /**
  23404. * Get the current class name of the texture useful for serialization or dynamic coding.
  23405. * @returns "Texture"
  23406. */
  23407. getClassName(): string;
  23408. /**
  23409. * Dispose the texture and release its associated resources.
  23410. */
  23411. dispose(): void;
  23412. /**
  23413. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23414. * @param parsedTexture Define the JSON representation of the texture
  23415. * @param scene Define the scene the parsed texture should be instantiated in
  23416. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23417. * @returns The parsed texture if successful
  23418. */
  23419. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23420. /**
  23421. * Creates a texture from its base 64 representation.
  23422. * @param data Define the base64 payload without the data: prefix
  23423. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23424. * @param scene Define the scene the texture should belong to
  23425. * @param noMipmap Forces the texture to not create mip map information if true
  23426. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23427. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23428. * @param onLoad define a callback triggered when the texture has been loaded
  23429. * @param onError define a callback triggered when an error occurred during the loading session
  23430. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23431. * @returns the created texture
  23432. */
  23433. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23434. /**
  23435. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23436. * @param data Define the base64 payload without the data: prefix
  23437. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23438. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23439. * @param scene Define the scene the texture should belong to
  23440. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23441. * @param noMipmap Forces the texture to not create mip map information if true
  23442. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23443. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23444. * @param onLoad define a callback triggered when the texture has been loaded
  23445. * @param onError define a callback triggered when an error occurred during the loading session
  23446. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23447. * @returns the created texture
  23448. */
  23449. 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;
  23450. }
  23451. }
  23452. declare module BABYLON {
  23453. /**
  23454. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23455. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23456. */
  23457. export class PostProcessManager {
  23458. private _scene;
  23459. private _indexBuffer;
  23460. private _vertexBuffers;
  23461. /**
  23462. * Creates a new instance PostProcess
  23463. * @param scene The scene that the post process is associated with.
  23464. */
  23465. constructor(scene: Scene);
  23466. private _prepareBuffers;
  23467. private _buildIndexBuffer;
  23468. /**
  23469. * Rebuilds the vertex buffers of the manager.
  23470. * @hidden
  23471. */
  23472. _rebuild(): void;
  23473. /**
  23474. * Prepares a frame to be run through a post process.
  23475. * @param sourceTexture The input texture to the post procesess. (default: null)
  23476. * @param postProcesses An array of post processes to be run. (default: null)
  23477. * @returns True if the post processes were able to be run.
  23478. * @hidden
  23479. */
  23480. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23481. /**
  23482. * Manually render a set of post processes to a texture.
  23483. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23484. * @param postProcesses An array of post processes to be run.
  23485. * @param targetTexture The target texture to render to.
  23486. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23487. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23488. * @param lodLevel defines which lod of the texture to render to
  23489. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23490. */
  23491. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23492. /**
  23493. * Finalize the result of the output of the postprocesses.
  23494. * @param doNotPresent If true the result will not be displayed to the screen.
  23495. * @param targetTexture The target texture to render to.
  23496. * @param faceIndex The index of the face to bind the target texture to.
  23497. * @param postProcesses The array of post processes to render.
  23498. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23499. * @hidden
  23500. */
  23501. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23502. /**
  23503. * Disposes of the post process manager.
  23504. */
  23505. dispose(): void;
  23506. }
  23507. }
  23508. declare module BABYLON {
  23509. /**
  23510. * This Helps creating a texture that will be created from a camera in your scene.
  23511. * It is basically a dynamic texture that could be used to create special effects for instance.
  23512. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23513. */
  23514. export class RenderTargetTexture extends Texture {
  23515. /**
  23516. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23517. */
  23518. static readonly REFRESHRATE_RENDER_ONCE: number;
  23519. /**
  23520. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23521. */
  23522. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23523. /**
  23524. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23525. * the central point of your effect and can save a lot of performances.
  23526. */
  23527. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23528. /**
  23529. * Use this predicate to dynamically define the list of mesh you want to render.
  23530. * If set, the renderList property will be overwritten.
  23531. */
  23532. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23533. private _renderList;
  23534. /**
  23535. * Use this list to define the list of mesh you want to render.
  23536. */
  23537. get renderList(): Nullable<Array<AbstractMesh>>;
  23538. set renderList(value: Nullable<Array<AbstractMesh>>);
  23539. /**
  23540. * Use this function to overload the renderList array at rendering time.
  23541. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23542. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23543. * the cube (if the RTT is a cube, else layerOrFace=0).
  23544. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23545. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23546. * hold dummy elements!
  23547. */
  23548. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23549. private _hookArray;
  23550. /**
  23551. * Define if particles should be rendered in your texture.
  23552. */
  23553. renderParticles: boolean;
  23554. /**
  23555. * Define if sprites should be rendered in your texture.
  23556. */
  23557. renderSprites: boolean;
  23558. /**
  23559. * Define the camera used to render the texture.
  23560. */
  23561. activeCamera: Nullable<Camera>;
  23562. /**
  23563. * Override the mesh isReady function with your own one.
  23564. */
  23565. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23566. /**
  23567. * Override the render function of the texture with your own one.
  23568. */
  23569. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23570. /**
  23571. * Define if camera post processes should be use while rendering the texture.
  23572. */
  23573. useCameraPostProcesses: boolean;
  23574. /**
  23575. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23576. */
  23577. ignoreCameraViewport: boolean;
  23578. private _postProcessManager;
  23579. private _postProcesses;
  23580. private _resizeObserver;
  23581. /**
  23582. * An event triggered when the texture is unbind.
  23583. */
  23584. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23585. /**
  23586. * An event triggered when the texture is unbind.
  23587. */
  23588. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23589. private _onAfterUnbindObserver;
  23590. /**
  23591. * Set a after unbind callback in the texture.
  23592. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23593. */
  23594. set onAfterUnbind(callback: () => void);
  23595. /**
  23596. * An event triggered before rendering the texture
  23597. */
  23598. onBeforeRenderObservable: Observable<number>;
  23599. private _onBeforeRenderObserver;
  23600. /**
  23601. * Set a before render callback in the texture.
  23602. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23603. */
  23604. set onBeforeRender(callback: (faceIndex: number) => void);
  23605. /**
  23606. * An event triggered after rendering the texture
  23607. */
  23608. onAfterRenderObservable: Observable<number>;
  23609. private _onAfterRenderObserver;
  23610. /**
  23611. * Set a after render callback in the texture.
  23612. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23613. */
  23614. set onAfterRender(callback: (faceIndex: number) => void);
  23615. /**
  23616. * An event triggered after the texture clear
  23617. */
  23618. onClearObservable: Observable<Engine>;
  23619. private _onClearObserver;
  23620. /**
  23621. * Set a clear callback in the texture.
  23622. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23623. */
  23624. set onClear(callback: (Engine: Engine) => void);
  23625. /**
  23626. * An event triggered when the texture is resized.
  23627. */
  23628. onResizeObservable: Observable<RenderTargetTexture>;
  23629. /**
  23630. * Define the clear color of the Render Target if it should be different from the scene.
  23631. */
  23632. clearColor: Color4;
  23633. protected _size: number | {
  23634. width: number;
  23635. height: number;
  23636. layers?: number;
  23637. };
  23638. protected _initialSizeParameter: number | {
  23639. width: number;
  23640. height: number;
  23641. } | {
  23642. ratio: number;
  23643. };
  23644. protected _sizeRatio: Nullable<number>;
  23645. /** @hidden */
  23646. _generateMipMaps: boolean;
  23647. protected _renderingManager: RenderingManager;
  23648. /** @hidden */
  23649. _waitingRenderList?: string[];
  23650. protected _doNotChangeAspectRatio: boolean;
  23651. protected _currentRefreshId: number;
  23652. protected _refreshRate: number;
  23653. protected _textureMatrix: Matrix;
  23654. protected _samples: number;
  23655. protected _renderTargetOptions: RenderTargetCreationOptions;
  23656. /**
  23657. * Gets render target creation options that were used.
  23658. */
  23659. get renderTargetOptions(): RenderTargetCreationOptions;
  23660. protected _onRatioRescale(): void;
  23661. /**
  23662. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23663. * It must define where the camera used to render the texture is set
  23664. */
  23665. boundingBoxPosition: Vector3;
  23666. private _boundingBoxSize;
  23667. /**
  23668. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23669. * When defined, the cubemap will switch to local mode
  23670. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23671. * @example https://www.babylonjs-playground.com/#RNASML
  23672. */
  23673. set boundingBoxSize(value: Vector3);
  23674. get boundingBoxSize(): Vector3;
  23675. /**
  23676. * In case the RTT has been created with a depth texture, get the associated
  23677. * depth texture.
  23678. * Otherwise, return null.
  23679. */
  23680. get depthStencilTexture(): Nullable<InternalTexture>;
  23681. /**
  23682. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23683. * or used a shadow, depth texture...
  23684. * @param name The friendly name of the texture
  23685. * @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)
  23686. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23687. * @param generateMipMaps True if mip maps need to be generated after render.
  23688. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23689. * @param type The type of the buffer in the RTT (int, half float, float...)
  23690. * @param isCube True if a cube texture needs to be created
  23691. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23692. * @param generateDepthBuffer True to generate a depth buffer
  23693. * @param generateStencilBuffer True to generate a stencil buffer
  23694. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23695. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23696. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23697. */
  23698. constructor(name: string, size: number | {
  23699. width: number;
  23700. height: number;
  23701. layers?: number;
  23702. } | {
  23703. ratio: number;
  23704. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23705. /**
  23706. * Creates a depth stencil texture.
  23707. * This is only available in WebGL 2 or with the depth texture extension available.
  23708. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23709. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23710. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23711. */
  23712. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23713. private _processSizeParameter;
  23714. /**
  23715. * Define the number of samples to use in case of MSAA.
  23716. * It defaults to one meaning no MSAA has been enabled.
  23717. */
  23718. get samples(): number;
  23719. set samples(value: number);
  23720. /**
  23721. * Resets the refresh counter of the texture and start bak from scratch.
  23722. * Could be useful to regenerate the texture if it is setup to render only once.
  23723. */
  23724. resetRefreshCounter(): void;
  23725. /**
  23726. * Define the refresh rate of the texture or the rendering frequency.
  23727. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23728. */
  23729. get refreshRate(): number;
  23730. set refreshRate(value: number);
  23731. /**
  23732. * Adds a post process to the render target rendering passes.
  23733. * @param postProcess define the post process to add
  23734. */
  23735. addPostProcess(postProcess: PostProcess): void;
  23736. /**
  23737. * Clear all the post processes attached to the render target
  23738. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23739. */
  23740. clearPostProcesses(dispose?: boolean): void;
  23741. /**
  23742. * Remove one of the post process from the list of attached post processes to the texture
  23743. * @param postProcess define the post process to remove from the list
  23744. */
  23745. removePostProcess(postProcess: PostProcess): void;
  23746. /** @hidden */
  23747. _shouldRender(): boolean;
  23748. /**
  23749. * Gets the actual render size of the texture.
  23750. * @returns the width of the render size
  23751. */
  23752. getRenderSize(): number;
  23753. /**
  23754. * Gets the actual render width of the texture.
  23755. * @returns the width of the render size
  23756. */
  23757. getRenderWidth(): number;
  23758. /**
  23759. * Gets the actual render height of the texture.
  23760. * @returns the height of the render size
  23761. */
  23762. getRenderHeight(): number;
  23763. /**
  23764. * Gets the actual number of layers of the texture.
  23765. * @returns the number of layers
  23766. */
  23767. getRenderLayers(): number;
  23768. /**
  23769. * Get if the texture can be rescaled or not.
  23770. */
  23771. get canRescale(): boolean;
  23772. /**
  23773. * Resize the texture using a ratio.
  23774. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23775. */
  23776. scale(ratio: number): void;
  23777. /**
  23778. * Get the texture reflection matrix used to rotate/transform the reflection.
  23779. * @returns the reflection matrix
  23780. */
  23781. getReflectionTextureMatrix(): Matrix;
  23782. /**
  23783. * Resize the texture to a new desired size.
  23784. * Be carrefull as it will recreate all the data in the new texture.
  23785. * @param size Define the new size. It can be:
  23786. * - a number for squared texture,
  23787. * - an object containing { width: number, height: number }
  23788. * - or an object containing a ratio { ratio: number }
  23789. */
  23790. resize(size: number | {
  23791. width: number;
  23792. height: number;
  23793. } | {
  23794. ratio: number;
  23795. }): void;
  23796. private _defaultRenderListPrepared;
  23797. /**
  23798. * Renders all the objects from the render list into the texture.
  23799. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23800. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23801. */
  23802. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23803. private _bestReflectionRenderTargetDimension;
  23804. private _prepareRenderingManager;
  23805. /**
  23806. * @hidden
  23807. * @param faceIndex face index to bind to if this is a cubetexture
  23808. * @param layer defines the index of the texture to bind in the array
  23809. */
  23810. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23811. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23812. private renderToTarget;
  23813. /**
  23814. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23815. * This allowed control for front to back rendering or reversly depending of the special needs.
  23816. *
  23817. * @param renderingGroupId The rendering group id corresponding to its index
  23818. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23819. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23820. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23821. */
  23822. 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;
  23823. /**
  23824. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23825. *
  23826. * @param renderingGroupId The rendering group id corresponding to its index
  23827. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23828. */
  23829. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23830. /**
  23831. * Clones the texture.
  23832. * @returns the cloned texture
  23833. */
  23834. clone(): RenderTargetTexture;
  23835. /**
  23836. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23837. * @returns The JSON representation of the texture
  23838. */
  23839. serialize(): any;
  23840. /**
  23841. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23842. */
  23843. disposeFramebufferObjects(): void;
  23844. /**
  23845. * Dispose the texture and release its associated resources.
  23846. */
  23847. dispose(): void;
  23848. /** @hidden */
  23849. _rebuild(): void;
  23850. /**
  23851. * Clear the info related to rendering groups preventing retention point in material dispose.
  23852. */
  23853. freeRenderingGroups(): void;
  23854. /**
  23855. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23856. * @returns the view count
  23857. */
  23858. getViewCount(): number;
  23859. }
  23860. }
  23861. declare module BABYLON {
  23862. /**
  23863. * Class used to manipulate GUIDs
  23864. */
  23865. export class GUID {
  23866. /**
  23867. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23868. * Be aware Math.random() could cause collisions, but:
  23869. * "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"
  23870. * @returns a pseudo random id
  23871. */
  23872. static RandomId(): string;
  23873. }
  23874. }
  23875. declare module BABYLON {
  23876. /**
  23877. * Options to be used when creating a shadow depth material
  23878. */
  23879. export interface IIOptionShadowDepthMaterial {
  23880. /** Variables in the vertex shader code that need to have their names remapped.
  23881. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23882. * "var_name" should be either: worldPos or vNormalW
  23883. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23884. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23885. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23886. */
  23887. remappedVariables?: string[];
  23888. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23889. standalone?: boolean;
  23890. }
  23891. /**
  23892. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23893. */
  23894. export class ShadowDepthWrapper {
  23895. private _scene;
  23896. private _options?;
  23897. private _baseMaterial;
  23898. private _onEffectCreatedObserver;
  23899. private _subMeshToEffect;
  23900. private _subMeshToDepthEffect;
  23901. private _meshes;
  23902. /** @hidden */
  23903. _matriceNames: any;
  23904. /** Gets the standalone status of the wrapper */
  23905. get standalone(): boolean;
  23906. /** Gets the base material the wrapper is built upon */
  23907. get baseMaterial(): Material;
  23908. /**
  23909. * Instantiate a new shadow depth wrapper.
  23910. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23911. * generate the shadow depth map. For more information, please refer to the documentation:
  23912. * https://doc.babylonjs.com/babylon101/shadows
  23913. * @param baseMaterial Material to wrap
  23914. * @param scene Define the scene the material belongs to
  23915. * @param options Options used to create the wrapper
  23916. */
  23917. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23918. /**
  23919. * Gets the effect to use to generate the depth map
  23920. * @param subMesh subMesh to get the effect for
  23921. * @param shadowGenerator shadow generator to get the effect for
  23922. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23923. */
  23924. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23925. /**
  23926. * Specifies that the submesh is ready to be used for depth rendering
  23927. * @param subMesh submesh to check
  23928. * @param defines the list of defines to take into account when checking the effect
  23929. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23930. * @param useInstances specifies that instances should be used
  23931. * @returns a boolean indicating that the submesh is ready or not
  23932. */
  23933. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23934. /**
  23935. * Disposes the resources
  23936. */
  23937. dispose(): void;
  23938. private _makeEffect;
  23939. }
  23940. }
  23941. declare module BABYLON {
  23942. interface ThinEngine {
  23943. /**
  23944. * Unbind a list of render target textures from the webGL context
  23945. * This is used only when drawBuffer extension or webGL2 are active
  23946. * @param textures defines the render target textures to unbind
  23947. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23948. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23949. */
  23950. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23951. /**
  23952. * Create a multi render target texture
  23953. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23954. * @param size defines the size of the texture
  23955. * @param options defines the creation options
  23956. * @returns the cube texture as an InternalTexture
  23957. */
  23958. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23959. /**
  23960. * Update the sample count for a given multiple render target texture
  23961. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23962. * @param textures defines the textures to update
  23963. * @param samples defines the sample count to set
  23964. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23965. */
  23966. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23967. /**
  23968. * Select a subsets of attachments to draw to.
  23969. * @param attachments gl attachments
  23970. */
  23971. bindAttachments(attachments: number[]): void;
  23972. }
  23973. }
  23974. declare module BABYLON {
  23975. /**
  23976. * Creation options of the multi render target texture.
  23977. */
  23978. export interface IMultiRenderTargetOptions {
  23979. /**
  23980. * Define if the texture needs to create mip maps after render.
  23981. */
  23982. generateMipMaps?: boolean;
  23983. /**
  23984. * Define the types of all the draw buffers we want to create
  23985. */
  23986. types?: number[];
  23987. /**
  23988. * Define the sampling modes of all the draw buffers we want to create
  23989. */
  23990. samplingModes?: number[];
  23991. /**
  23992. * Define if a depth buffer is required
  23993. */
  23994. generateDepthBuffer?: boolean;
  23995. /**
  23996. * Define if a stencil buffer is required
  23997. */
  23998. generateStencilBuffer?: boolean;
  23999. /**
  24000. * Define if a depth texture is required instead of a depth buffer
  24001. */
  24002. generateDepthTexture?: boolean;
  24003. /**
  24004. * Define the number of desired draw buffers
  24005. */
  24006. textureCount?: number;
  24007. /**
  24008. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24009. */
  24010. doNotChangeAspectRatio?: boolean;
  24011. /**
  24012. * Define the default type of the buffers we are creating
  24013. */
  24014. defaultType?: number;
  24015. }
  24016. /**
  24017. * A multi render target, like a render target provides the ability to render to a texture.
  24018. * Unlike the render target, it can render to several draw buffers in one draw.
  24019. * This is specially interesting in deferred rendering or for any effects requiring more than
  24020. * just one color from a single pass.
  24021. */
  24022. export class MultiRenderTarget extends RenderTargetTexture {
  24023. private _internalTextures;
  24024. private _textures;
  24025. private _multiRenderTargetOptions;
  24026. private _count;
  24027. /**
  24028. * Get if draw buffers are currently supported by the used hardware and browser.
  24029. */
  24030. get isSupported(): boolean;
  24031. /**
  24032. * Get the list of textures generated by the multi render target.
  24033. */
  24034. get textures(): Texture[];
  24035. /**
  24036. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24037. */
  24038. get count(): number;
  24039. /**
  24040. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24041. */
  24042. get depthTexture(): Texture;
  24043. /**
  24044. * Set the wrapping mode on U of all the textures we are rendering to.
  24045. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24046. */
  24047. set wrapU(wrap: number);
  24048. /**
  24049. * Set the wrapping mode on V of all the textures we are rendering to.
  24050. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24051. */
  24052. set wrapV(wrap: number);
  24053. /**
  24054. * Instantiate a new multi render target texture.
  24055. * A multi render target, like a render target provides the ability to render to a texture.
  24056. * Unlike the render target, it can render to several draw buffers in one draw.
  24057. * This is specially interesting in deferred rendering or for any effects requiring more than
  24058. * just one color from a single pass.
  24059. * @param name Define the name of the texture
  24060. * @param size Define the size of the buffers to render to
  24061. * @param count Define the number of target we are rendering into
  24062. * @param scene Define the scene the texture belongs to
  24063. * @param options Define the options used to create the multi render target
  24064. */
  24065. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24066. /** @hidden */
  24067. _rebuild(): void;
  24068. private _createInternalTextures;
  24069. private _createTextures;
  24070. /**
  24071. * Define the number of samples used if MSAA is enabled.
  24072. */
  24073. get samples(): number;
  24074. set samples(value: number);
  24075. /**
  24076. * Resize all the textures in the multi render target.
  24077. * Be carrefull as it will recreate all the data in the new texture.
  24078. * @param size Define the new size
  24079. */
  24080. resize(size: any): void;
  24081. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24082. /**
  24083. * Dispose the render targets and their associated resources
  24084. */
  24085. dispose(): void;
  24086. /**
  24087. * Release all the underlying texture used as draw buffers.
  24088. */
  24089. releaseInternalTextures(): void;
  24090. }
  24091. }
  24092. declare module BABYLON {
  24093. /** @hidden */
  24094. export var imageProcessingPixelShader: {
  24095. name: string;
  24096. shader: string;
  24097. };
  24098. }
  24099. declare module BABYLON {
  24100. /**
  24101. * ImageProcessingPostProcess
  24102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24103. */
  24104. export class ImageProcessingPostProcess extends PostProcess {
  24105. /**
  24106. * Default configuration related to image processing available in the PBR Material.
  24107. */
  24108. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24109. /**
  24110. * Gets the image processing configuration used either in this material.
  24111. */
  24112. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24113. /**
  24114. * Sets the Default image processing configuration used either in the this material.
  24115. *
  24116. * If sets to null, the scene one is in use.
  24117. */
  24118. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24119. /**
  24120. * Keep track of the image processing observer to allow dispose and replace.
  24121. */
  24122. private _imageProcessingObserver;
  24123. /**
  24124. * Attaches a new image processing configuration to the PBR Material.
  24125. * @param configuration
  24126. */
  24127. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24128. /**
  24129. * If the post process is supported.
  24130. */
  24131. get isSupported(): boolean;
  24132. /**
  24133. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24134. */
  24135. get colorCurves(): Nullable<ColorCurves>;
  24136. /**
  24137. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24138. */
  24139. set colorCurves(value: Nullable<ColorCurves>);
  24140. /**
  24141. * Gets wether the color curves effect is enabled.
  24142. */
  24143. get colorCurvesEnabled(): boolean;
  24144. /**
  24145. * Sets wether the color curves effect is enabled.
  24146. */
  24147. set colorCurvesEnabled(value: boolean);
  24148. /**
  24149. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24150. */
  24151. get colorGradingTexture(): Nullable<BaseTexture>;
  24152. /**
  24153. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24154. */
  24155. set colorGradingTexture(value: Nullable<BaseTexture>);
  24156. /**
  24157. * Gets wether the color grading effect is enabled.
  24158. */
  24159. get colorGradingEnabled(): boolean;
  24160. /**
  24161. * Gets wether the color grading effect is enabled.
  24162. */
  24163. set colorGradingEnabled(value: boolean);
  24164. /**
  24165. * Gets exposure used in the effect.
  24166. */
  24167. get exposure(): number;
  24168. /**
  24169. * Sets exposure used in the effect.
  24170. */
  24171. set exposure(value: number);
  24172. /**
  24173. * Gets wether tonemapping is enabled or not.
  24174. */
  24175. get toneMappingEnabled(): boolean;
  24176. /**
  24177. * Sets wether tonemapping is enabled or not
  24178. */
  24179. set toneMappingEnabled(value: boolean);
  24180. /**
  24181. * Gets the type of tone mapping effect.
  24182. */
  24183. get toneMappingType(): number;
  24184. /**
  24185. * Sets the type of tone mapping effect.
  24186. */
  24187. set toneMappingType(value: number);
  24188. /**
  24189. * Gets contrast used in the effect.
  24190. */
  24191. get contrast(): number;
  24192. /**
  24193. * Sets contrast used in the effect.
  24194. */
  24195. set contrast(value: number);
  24196. /**
  24197. * Gets Vignette stretch size.
  24198. */
  24199. get vignetteStretch(): number;
  24200. /**
  24201. * Sets Vignette stretch size.
  24202. */
  24203. set vignetteStretch(value: number);
  24204. /**
  24205. * Gets Vignette centre X Offset.
  24206. */
  24207. get vignetteCentreX(): number;
  24208. /**
  24209. * Sets Vignette centre X Offset.
  24210. */
  24211. set vignetteCentreX(value: number);
  24212. /**
  24213. * Gets Vignette centre Y Offset.
  24214. */
  24215. get vignetteCentreY(): number;
  24216. /**
  24217. * Sets Vignette centre Y Offset.
  24218. */
  24219. set vignetteCentreY(value: number);
  24220. /**
  24221. * Gets Vignette weight or intensity of the vignette effect.
  24222. */
  24223. get vignetteWeight(): number;
  24224. /**
  24225. * Sets Vignette weight or intensity of the vignette effect.
  24226. */
  24227. set vignetteWeight(value: number);
  24228. /**
  24229. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24230. * if vignetteEnabled is set to true.
  24231. */
  24232. get vignetteColor(): Color4;
  24233. /**
  24234. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24235. * if vignetteEnabled is set to true.
  24236. */
  24237. set vignetteColor(value: Color4);
  24238. /**
  24239. * Gets Camera field of view used by the Vignette effect.
  24240. */
  24241. get vignetteCameraFov(): number;
  24242. /**
  24243. * Sets Camera field of view used by the Vignette effect.
  24244. */
  24245. set vignetteCameraFov(value: number);
  24246. /**
  24247. * Gets the vignette blend mode allowing different kind of effect.
  24248. */
  24249. get vignetteBlendMode(): number;
  24250. /**
  24251. * Sets the vignette blend mode allowing different kind of effect.
  24252. */
  24253. set vignetteBlendMode(value: number);
  24254. /**
  24255. * Gets wether the vignette effect is enabled.
  24256. */
  24257. get vignetteEnabled(): boolean;
  24258. /**
  24259. * Sets wether the vignette effect is enabled.
  24260. */
  24261. set vignetteEnabled(value: boolean);
  24262. private _fromLinearSpace;
  24263. /**
  24264. * Gets wether the input of the processing is in Gamma or Linear Space.
  24265. */
  24266. get fromLinearSpace(): boolean;
  24267. /**
  24268. * Sets wether the input of the processing is in Gamma or Linear Space.
  24269. */
  24270. set fromLinearSpace(value: boolean);
  24271. /**
  24272. * Defines cache preventing GC.
  24273. */
  24274. private _defines;
  24275. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24276. /**
  24277. * "ImageProcessingPostProcess"
  24278. * @returns "ImageProcessingPostProcess"
  24279. */
  24280. getClassName(): string;
  24281. /**
  24282. * @hidden
  24283. */
  24284. _updateParameters(): void;
  24285. dispose(camera?: Camera): void;
  24286. }
  24287. }
  24288. declare module BABYLON {
  24289. /** @hidden */
  24290. export var fibonacci: {
  24291. name: string;
  24292. shader: string;
  24293. };
  24294. }
  24295. declare module BABYLON {
  24296. /** @hidden */
  24297. export var subSurfaceScatteringFunctions: {
  24298. name: string;
  24299. shader: string;
  24300. };
  24301. }
  24302. declare module BABYLON {
  24303. /** @hidden */
  24304. export var diffusionProfile: {
  24305. name: string;
  24306. shader: string;
  24307. };
  24308. }
  24309. declare module BABYLON {
  24310. /** @hidden */
  24311. export var subSurfaceScatteringPixelShader: {
  24312. name: string;
  24313. shader: string;
  24314. };
  24315. }
  24316. declare module BABYLON {
  24317. /**
  24318. * Sub surface scattering post process
  24319. */
  24320. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24321. /**
  24322. * Gets a string identifying the name of the class
  24323. * @returns "SubSurfaceScatteringPostProcess" string
  24324. */
  24325. getClassName(): string;
  24326. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24327. }
  24328. }
  24329. declare module BABYLON {
  24330. /**
  24331. * Interface for defining prepass effects in the prepass post-process pipeline
  24332. */
  24333. export interface PrePassEffectConfiguration {
  24334. /**
  24335. * Post process to attach for this effect
  24336. */
  24337. postProcess: PostProcess;
  24338. /**
  24339. * Is the effect enabled
  24340. */
  24341. enabled: boolean;
  24342. /**
  24343. * Disposes the effect configuration
  24344. */
  24345. dispose(): void;
  24346. /**
  24347. * Disposes the effect configuration
  24348. */
  24349. createPostProcess: () => PostProcess;
  24350. }
  24351. }
  24352. declare module BABYLON {
  24353. /**
  24354. * Contains all parameters needed for the prepass to perform
  24355. * screen space subsurface scattering
  24356. */
  24357. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24358. private _ssDiffusionS;
  24359. private _ssFilterRadii;
  24360. private _ssDiffusionD;
  24361. /**
  24362. * Post process to attach for screen space subsurface scattering
  24363. */
  24364. postProcess: SubSurfaceScatteringPostProcess;
  24365. /**
  24366. * Diffusion profile color for subsurface scattering
  24367. */
  24368. get ssDiffusionS(): number[];
  24369. /**
  24370. * Diffusion profile max color channel value for subsurface scattering
  24371. */
  24372. get ssDiffusionD(): number[];
  24373. /**
  24374. * Diffusion profile filter radius for subsurface scattering
  24375. */
  24376. get ssFilterRadii(): number[];
  24377. /**
  24378. * Is subsurface enabled
  24379. */
  24380. enabled: boolean;
  24381. /**
  24382. * Diffusion profile colors for subsurface scattering
  24383. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24384. * See ...
  24385. * Note that you can only store up to 5 of them
  24386. */
  24387. ssDiffusionProfileColors: Color3[];
  24388. /**
  24389. * Defines the ratio real world => scene units.
  24390. * Used for subsurface scattering
  24391. */
  24392. metersPerUnit: number;
  24393. private _scene;
  24394. /**
  24395. * Builds a subsurface configuration object
  24396. * @param scene The scene
  24397. */
  24398. constructor(scene: Scene);
  24399. /**
  24400. * Adds a new diffusion profile.
  24401. * Useful for more realistic subsurface scattering on diverse materials.
  24402. * @param color The color of the diffusion profile. Should be the average color of the material.
  24403. * @return The index of the diffusion profile for the material subsurface configuration
  24404. */
  24405. addDiffusionProfile(color: Color3): number;
  24406. /**
  24407. * Creates the sss post process
  24408. * @return The created post process
  24409. */
  24410. createPostProcess(): SubSurfaceScatteringPostProcess;
  24411. /**
  24412. * Deletes all diffusion profiles.
  24413. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24414. */
  24415. clearAllDiffusionProfiles(): void;
  24416. /**
  24417. * Disposes this object
  24418. */
  24419. dispose(): void;
  24420. /**
  24421. * @hidden
  24422. * https://zero-radiance.github.io/post/sampling-diffusion/
  24423. *
  24424. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24425. * ------------------------------------------------------------------------------------
  24426. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24427. * PDF[r, phi, s] = r * R[r, phi, s]
  24428. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24429. * ------------------------------------------------------------------------------------
  24430. * We importance sample the color channel with the widest scattering distance.
  24431. */
  24432. getDiffusionProfileParameters(color: Color3): number;
  24433. /**
  24434. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24435. * 'u' is the random number (the value of the CDF): [0, 1).
  24436. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24437. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24438. */
  24439. private _sampleBurleyDiffusionProfile;
  24440. }
  24441. }
  24442. declare module BABYLON {
  24443. /**
  24444. * Renders a pre pass of the scene
  24445. * This means every mesh in the scene will be rendered to a render target texture
  24446. * And then this texture will be composited to the rendering canvas with post processes
  24447. * It is necessary for effects like subsurface scattering or deferred shading
  24448. */
  24449. export class PrePassRenderer {
  24450. /** @hidden */
  24451. static _SceneComponentInitialization: (scene: Scene) => void;
  24452. private _scene;
  24453. private _engine;
  24454. private _isDirty;
  24455. /**
  24456. * Number of textures in the multi render target texture where the scene is directly rendered
  24457. */
  24458. readonly mrtCount: number;
  24459. /**
  24460. * The render target where the scene is directly rendered
  24461. */
  24462. prePassRT: MultiRenderTarget;
  24463. private _mrtTypes;
  24464. private _multiRenderAttachments;
  24465. private _defaultAttachments;
  24466. private _clearAttachments;
  24467. private _postProcesses;
  24468. private readonly _clearColor;
  24469. /**
  24470. * Image processing post process for composition
  24471. */
  24472. imageProcessingPostProcess: ImageProcessingPostProcess;
  24473. /**
  24474. * Configuration for sub surface scattering post process
  24475. */
  24476. subSurfaceConfiguration: SubSurfaceConfiguration;
  24477. /**
  24478. * Should materials render their geometry on the MRT
  24479. */
  24480. materialsShouldRenderGeometry: boolean;
  24481. /**
  24482. * Should materials render the irradiance information on the MRT
  24483. */
  24484. materialsShouldRenderIrradiance: boolean;
  24485. private _enabled;
  24486. /**
  24487. * Indicates if the prepass is enabled
  24488. */
  24489. get enabled(): boolean;
  24490. /**
  24491. * How many samples are used for MSAA of the scene render target
  24492. */
  24493. get samples(): number;
  24494. set samples(n: number);
  24495. /**
  24496. * Instanciates a prepass renderer
  24497. * @param scene The scene
  24498. */
  24499. constructor(scene: Scene);
  24500. private _initializeAttachments;
  24501. private _createCompositionEffect;
  24502. /**
  24503. * Indicates if rendering a prepass is supported
  24504. */
  24505. get isSupported(): boolean;
  24506. /**
  24507. * Sets the proper output textures to draw in the engine.
  24508. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24509. */
  24510. bindAttachmentsForEffect(effect: Effect): void;
  24511. /**
  24512. * @hidden
  24513. */
  24514. _beforeCameraDraw(): void;
  24515. /**
  24516. * @hidden
  24517. */
  24518. _afterCameraDraw(): void;
  24519. private _checkRTSize;
  24520. private _bindFrameBuffer;
  24521. /**
  24522. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24523. */
  24524. clear(): void;
  24525. private _setState;
  24526. private _enable;
  24527. private _disable;
  24528. private _resetPostProcessChain;
  24529. private _bindPostProcessChain;
  24530. /**
  24531. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24532. */
  24533. markAsDirty(): void;
  24534. private _update;
  24535. /**
  24536. * Disposes the prepass renderer.
  24537. */
  24538. dispose(): void;
  24539. }
  24540. }
  24541. declare module BABYLON {
  24542. /**
  24543. * Options for compiling materials.
  24544. */
  24545. export interface IMaterialCompilationOptions {
  24546. /**
  24547. * Defines whether clip planes are enabled.
  24548. */
  24549. clipPlane: boolean;
  24550. /**
  24551. * Defines whether instances are enabled.
  24552. */
  24553. useInstances: boolean;
  24554. }
  24555. /**
  24556. * Options passed when calling customShaderNameResolve
  24557. */
  24558. export interface ICustomShaderNameResolveOptions {
  24559. /**
  24560. * 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
  24561. */
  24562. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24563. }
  24564. /**
  24565. * Base class for the main features of a material in Babylon.js
  24566. */
  24567. export class Material implements IAnimatable {
  24568. /**
  24569. * Returns the triangle fill mode
  24570. */
  24571. static readonly TriangleFillMode: number;
  24572. /**
  24573. * Returns the wireframe mode
  24574. */
  24575. static readonly WireFrameFillMode: number;
  24576. /**
  24577. * Returns the point fill mode
  24578. */
  24579. static readonly PointFillMode: number;
  24580. /**
  24581. * Returns the point list draw mode
  24582. */
  24583. static readonly PointListDrawMode: number;
  24584. /**
  24585. * Returns the line list draw mode
  24586. */
  24587. static readonly LineListDrawMode: number;
  24588. /**
  24589. * Returns the line loop draw mode
  24590. */
  24591. static readonly LineLoopDrawMode: number;
  24592. /**
  24593. * Returns the line strip draw mode
  24594. */
  24595. static readonly LineStripDrawMode: number;
  24596. /**
  24597. * Returns the triangle strip draw mode
  24598. */
  24599. static readonly TriangleStripDrawMode: number;
  24600. /**
  24601. * Returns the triangle fan draw mode
  24602. */
  24603. static readonly TriangleFanDrawMode: number;
  24604. /**
  24605. * Stores the clock-wise side orientation
  24606. */
  24607. static readonly ClockWiseSideOrientation: number;
  24608. /**
  24609. * Stores the counter clock-wise side orientation
  24610. */
  24611. static readonly CounterClockWiseSideOrientation: number;
  24612. /**
  24613. * The dirty texture flag value
  24614. */
  24615. static readonly TextureDirtyFlag: number;
  24616. /**
  24617. * The dirty light flag value
  24618. */
  24619. static readonly LightDirtyFlag: number;
  24620. /**
  24621. * The dirty fresnel flag value
  24622. */
  24623. static readonly FresnelDirtyFlag: number;
  24624. /**
  24625. * The dirty attribute flag value
  24626. */
  24627. static readonly AttributesDirtyFlag: number;
  24628. /**
  24629. * The dirty misc flag value
  24630. */
  24631. static readonly MiscDirtyFlag: number;
  24632. /**
  24633. * The all dirty flag value
  24634. */
  24635. static readonly AllDirtyFlag: number;
  24636. /**
  24637. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24638. */
  24639. static readonly MATERIAL_OPAQUE: number;
  24640. /**
  24641. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24642. */
  24643. static readonly MATERIAL_ALPHATEST: number;
  24644. /**
  24645. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24646. */
  24647. static readonly MATERIAL_ALPHABLEND: number;
  24648. /**
  24649. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24650. * They are also discarded below the alpha cutoff threshold to improve performances.
  24651. */
  24652. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24653. /**
  24654. * The Whiteout method is used to blend normals.
  24655. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24656. */
  24657. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24658. /**
  24659. * The Reoriented Normal Mapping method is used to blend normals.
  24660. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24661. */
  24662. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24663. /**
  24664. * Custom callback helping to override the default shader used in the material.
  24665. */
  24666. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24667. /**
  24668. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24669. */
  24670. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24671. /**
  24672. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24673. * This means that the material can keep using a previous shader while a new one is being compiled.
  24674. * This is mostly used when shader parallel compilation is supported (true by default)
  24675. */
  24676. allowShaderHotSwapping: boolean;
  24677. /**
  24678. * The ID of the material
  24679. */
  24680. id: string;
  24681. /**
  24682. * Gets or sets the unique id of the material
  24683. */
  24684. uniqueId: number;
  24685. /**
  24686. * The name of the material
  24687. */
  24688. name: string;
  24689. /**
  24690. * Gets or sets user defined metadata
  24691. */
  24692. metadata: any;
  24693. /**
  24694. * For internal use only. Please do not use.
  24695. */
  24696. reservedDataStore: any;
  24697. /**
  24698. * Specifies if the ready state should be checked on each call
  24699. */
  24700. checkReadyOnEveryCall: boolean;
  24701. /**
  24702. * Specifies if the ready state should be checked once
  24703. */
  24704. checkReadyOnlyOnce: boolean;
  24705. /**
  24706. * The state of the material
  24707. */
  24708. state: string;
  24709. /**
  24710. * If the material can be rendered to several textures with MRT extension
  24711. */
  24712. get canRenderToMRT(): boolean;
  24713. /**
  24714. * The alpha value of the material
  24715. */
  24716. protected _alpha: number;
  24717. /**
  24718. * List of inspectable custom properties (used by the Inspector)
  24719. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24720. */
  24721. inspectableCustomProperties: IInspectable[];
  24722. /**
  24723. * Sets the alpha value of the material
  24724. */
  24725. set alpha(value: number);
  24726. /**
  24727. * Gets the alpha value of the material
  24728. */
  24729. get alpha(): number;
  24730. /**
  24731. * Specifies if back face culling is enabled
  24732. */
  24733. protected _backFaceCulling: boolean;
  24734. /**
  24735. * Sets the back-face culling state
  24736. */
  24737. set backFaceCulling(value: boolean);
  24738. /**
  24739. * Gets the back-face culling state
  24740. */
  24741. get backFaceCulling(): boolean;
  24742. /**
  24743. * Stores the value for side orientation
  24744. */
  24745. sideOrientation: number;
  24746. /**
  24747. * Callback triggered when the material is compiled
  24748. */
  24749. onCompiled: Nullable<(effect: Effect) => void>;
  24750. /**
  24751. * Callback triggered when an error occurs
  24752. */
  24753. onError: Nullable<(effect: Effect, errors: string) => void>;
  24754. /**
  24755. * Callback triggered to get the render target textures
  24756. */
  24757. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24758. /**
  24759. * Gets a boolean indicating that current material needs to register RTT
  24760. */
  24761. get hasRenderTargetTextures(): boolean;
  24762. /**
  24763. * Specifies if the material should be serialized
  24764. */
  24765. doNotSerialize: boolean;
  24766. /**
  24767. * @hidden
  24768. */
  24769. _storeEffectOnSubMeshes: boolean;
  24770. /**
  24771. * Stores the animations for the material
  24772. */
  24773. animations: Nullable<Array<Animation>>;
  24774. /**
  24775. * An event triggered when the material is disposed
  24776. */
  24777. onDisposeObservable: Observable<Material>;
  24778. /**
  24779. * An observer which watches for dispose events
  24780. */
  24781. private _onDisposeObserver;
  24782. private _onUnBindObservable;
  24783. /**
  24784. * Called during a dispose event
  24785. */
  24786. set onDispose(callback: () => void);
  24787. private _onBindObservable;
  24788. /**
  24789. * An event triggered when the material is bound
  24790. */
  24791. get onBindObservable(): Observable<AbstractMesh>;
  24792. /**
  24793. * An observer which watches for bind events
  24794. */
  24795. private _onBindObserver;
  24796. /**
  24797. * Called during a bind event
  24798. */
  24799. set onBind(callback: (Mesh: AbstractMesh) => void);
  24800. /**
  24801. * An event triggered when the material is unbound
  24802. */
  24803. get onUnBindObservable(): Observable<Material>;
  24804. protected _onEffectCreatedObservable: Nullable<Observable<{
  24805. effect: Effect;
  24806. subMesh: Nullable<SubMesh>;
  24807. }>>;
  24808. /**
  24809. * An event triggered when the effect is (re)created
  24810. */
  24811. get onEffectCreatedObservable(): Observable<{
  24812. effect: Effect;
  24813. subMesh: Nullable<SubMesh>;
  24814. }>;
  24815. /**
  24816. * Stores the value of the alpha mode
  24817. */
  24818. private _alphaMode;
  24819. /**
  24820. * Sets the value of the alpha mode.
  24821. *
  24822. * | Value | Type | Description |
  24823. * | --- | --- | --- |
  24824. * | 0 | ALPHA_DISABLE | |
  24825. * | 1 | ALPHA_ADD | |
  24826. * | 2 | ALPHA_COMBINE | |
  24827. * | 3 | ALPHA_SUBTRACT | |
  24828. * | 4 | ALPHA_MULTIPLY | |
  24829. * | 5 | ALPHA_MAXIMIZED | |
  24830. * | 6 | ALPHA_ONEONE | |
  24831. * | 7 | ALPHA_PREMULTIPLIED | |
  24832. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24833. * | 9 | ALPHA_INTERPOLATE | |
  24834. * | 10 | ALPHA_SCREENMODE | |
  24835. *
  24836. */
  24837. set alphaMode(value: number);
  24838. /**
  24839. * Gets the value of the alpha mode
  24840. */
  24841. get alphaMode(): number;
  24842. /**
  24843. * Stores the state of the need depth pre-pass value
  24844. */
  24845. private _needDepthPrePass;
  24846. /**
  24847. * Sets the need depth pre-pass value
  24848. */
  24849. set needDepthPrePass(value: boolean);
  24850. /**
  24851. * Gets the depth pre-pass value
  24852. */
  24853. get needDepthPrePass(): boolean;
  24854. /**
  24855. * Specifies if depth writing should be disabled
  24856. */
  24857. disableDepthWrite: boolean;
  24858. /**
  24859. * Specifies if color writing should be disabled
  24860. */
  24861. disableColorWrite: boolean;
  24862. /**
  24863. * Specifies if depth writing should be forced
  24864. */
  24865. forceDepthWrite: boolean;
  24866. /**
  24867. * Specifies the depth function that should be used. 0 means the default engine function
  24868. */
  24869. depthFunction: number;
  24870. /**
  24871. * Specifies if there should be a separate pass for culling
  24872. */
  24873. separateCullingPass: boolean;
  24874. /**
  24875. * Stores the state specifing if fog should be enabled
  24876. */
  24877. private _fogEnabled;
  24878. /**
  24879. * Sets the state for enabling fog
  24880. */
  24881. set fogEnabled(value: boolean);
  24882. /**
  24883. * Gets the value of the fog enabled state
  24884. */
  24885. get fogEnabled(): boolean;
  24886. /**
  24887. * Stores the size of points
  24888. */
  24889. pointSize: number;
  24890. /**
  24891. * Stores the z offset value
  24892. */
  24893. zOffset: number;
  24894. get wireframe(): boolean;
  24895. /**
  24896. * Sets the state of wireframe mode
  24897. */
  24898. set wireframe(value: boolean);
  24899. /**
  24900. * Gets the value specifying if point clouds are enabled
  24901. */
  24902. get pointsCloud(): boolean;
  24903. /**
  24904. * Sets the state of point cloud mode
  24905. */
  24906. set pointsCloud(value: boolean);
  24907. /**
  24908. * Gets the material fill mode
  24909. */
  24910. get fillMode(): number;
  24911. /**
  24912. * Sets the material fill mode
  24913. */
  24914. set fillMode(value: number);
  24915. /**
  24916. * @hidden
  24917. * Stores the effects for the material
  24918. */
  24919. _effect: Nullable<Effect>;
  24920. /**
  24921. * Specifies if uniform buffers should be used
  24922. */
  24923. private _useUBO;
  24924. /**
  24925. * Stores a reference to the scene
  24926. */
  24927. private _scene;
  24928. /**
  24929. * Stores the fill mode state
  24930. */
  24931. private _fillMode;
  24932. /**
  24933. * Specifies if the depth write state should be cached
  24934. */
  24935. private _cachedDepthWriteState;
  24936. /**
  24937. * Specifies if the color write state should be cached
  24938. */
  24939. private _cachedColorWriteState;
  24940. /**
  24941. * Specifies if the depth function state should be cached
  24942. */
  24943. private _cachedDepthFunctionState;
  24944. /**
  24945. * Stores the uniform buffer
  24946. */
  24947. protected _uniformBuffer: UniformBuffer;
  24948. /** @hidden */
  24949. _indexInSceneMaterialArray: number;
  24950. /** @hidden */
  24951. meshMap: Nullable<{
  24952. [id: string]: AbstractMesh | undefined;
  24953. }>;
  24954. /**
  24955. * Creates a material instance
  24956. * @param name defines the name of the material
  24957. * @param scene defines the scene to reference
  24958. * @param doNotAdd specifies if the material should be added to the scene
  24959. */
  24960. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24961. /**
  24962. * Returns a string representation of the current material
  24963. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24964. * @returns a string with material information
  24965. */
  24966. toString(fullDetails?: boolean): string;
  24967. /**
  24968. * Gets the class name of the material
  24969. * @returns a string with the class name of the material
  24970. */
  24971. getClassName(): string;
  24972. /**
  24973. * Specifies if updates for the material been locked
  24974. */
  24975. get isFrozen(): boolean;
  24976. /**
  24977. * Locks updates for the material
  24978. */
  24979. freeze(): void;
  24980. /**
  24981. * Unlocks updates for the material
  24982. */
  24983. unfreeze(): void;
  24984. /**
  24985. * Specifies if the material is ready to be used
  24986. * @param mesh defines the mesh to check
  24987. * @param useInstances specifies if instances should be used
  24988. * @returns a boolean indicating if the material is ready to be used
  24989. */
  24990. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24991. /**
  24992. * Specifies that the submesh is ready to be used
  24993. * @param mesh defines the mesh to check
  24994. * @param subMesh defines which submesh to check
  24995. * @param useInstances specifies that instances should be used
  24996. * @returns a boolean indicating that the submesh is ready or not
  24997. */
  24998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24999. /**
  25000. * Returns the material effect
  25001. * @returns the effect associated with the material
  25002. */
  25003. getEffect(): Nullable<Effect>;
  25004. /**
  25005. * Returns the current scene
  25006. * @returns a Scene
  25007. */
  25008. getScene(): Scene;
  25009. /**
  25010. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25011. */
  25012. protected _forceAlphaTest: boolean;
  25013. /**
  25014. * The transparency mode of the material.
  25015. */
  25016. protected _transparencyMode: Nullable<number>;
  25017. /**
  25018. * Gets the current transparency mode.
  25019. */
  25020. get transparencyMode(): Nullable<number>;
  25021. /**
  25022. * Sets the transparency mode of the material.
  25023. *
  25024. * | Value | Type | Description |
  25025. * | ----- | ----------------------------------- | ----------- |
  25026. * | 0 | OPAQUE | |
  25027. * | 1 | ALPHATEST | |
  25028. * | 2 | ALPHABLEND | |
  25029. * | 3 | ALPHATESTANDBLEND | |
  25030. *
  25031. */
  25032. set transparencyMode(value: Nullable<number>);
  25033. /**
  25034. * Returns true if alpha blending should be disabled.
  25035. */
  25036. protected get _disableAlphaBlending(): boolean;
  25037. /**
  25038. * Specifies whether or not this material should be rendered in alpha blend mode.
  25039. * @returns a boolean specifying if alpha blending is needed
  25040. */
  25041. needAlphaBlending(): boolean;
  25042. /**
  25043. * Specifies if the mesh will require alpha blending
  25044. * @param mesh defines the mesh to check
  25045. * @returns a boolean specifying if alpha blending is needed for the mesh
  25046. */
  25047. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25048. /**
  25049. * Specifies whether or not this material should be rendered in alpha test mode.
  25050. * @returns a boolean specifying if an alpha test is needed.
  25051. */
  25052. needAlphaTesting(): boolean;
  25053. /**
  25054. * Specifies if material alpha testing should be turned on for the mesh
  25055. * @param mesh defines the mesh to check
  25056. */
  25057. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25058. /**
  25059. * Gets the texture used for the alpha test
  25060. * @returns the texture to use for alpha testing
  25061. */
  25062. getAlphaTestTexture(): Nullable<BaseTexture>;
  25063. /**
  25064. * Marks the material to indicate that it needs to be re-calculated
  25065. */
  25066. markDirty(): void;
  25067. /** @hidden */
  25068. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25069. /**
  25070. * Binds the material to the mesh
  25071. * @param world defines the world transformation matrix
  25072. * @param mesh defines the mesh to bind the material to
  25073. */
  25074. bind(world: Matrix, mesh?: Mesh): void;
  25075. /**
  25076. * Binds the submesh to the material
  25077. * @param world defines the world transformation matrix
  25078. * @param mesh defines the mesh containing the submesh
  25079. * @param subMesh defines the submesh to bind the material to
  25080. */
  25081. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25082. /**
  25083. * Binds the world matrix to the material
  25084. * @param world defines the world transformation matrix
  25085. */
  25086. bindOnlyWorldMatrix(world: Matrix): void;
  25087. /**
  25088. * Binds the scene's uniform buffer to the effect.
  25089. * @param effect defines the effect to bind to the scene uniform buffer
  25090. * @param sceneUbo defines the uniform buffer storing scene data
  25091. */
  25092. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25093. /**
  25094. * Binds the view matrix to the effect
  25095. * @param effect defines the effect to bind the view matrix to
  25096. */
  25097. bindView(effect: Effect): void;
  25098. /**
  25099. * Binds the view projection matrix to the effect
  25100. * @param effect defines the effect to bind the view projection matrix to
  25101. */
  25102. bindViewProjection(effect: Effect): void;
  25103. /**
  25104. * Processes to execute after binding the material to a mesh
  25105. * @param mesh defines the rendered mesh
  25106. */
  25107. protected _afterBind(mesh?: Mesh): void;
  25108. /**
  25109. * Unbinds the material from the mesh
  25110. */
  25111. unbind(): void;
  25112. /**
  25113. * Gets the active textures from the material
  25114. * @returns an array of textures
  25115. */
  25116. getActiveTextures(): BaseTexture[];
  25117. /**
  25118. * Specifies if the material uses a texture
  25119. * @param texture defines the texture to check against the material
  25120. * @returns a boolean specifying if the material uses the texture
  25121. */
  25122. hasTexture(texture: BaseTexture): boolean;
  25123. /**
  25124. * Makes a duplicate of the material, and gives it a new name
  25125. * @param name defines the new name for the duplicated material
  25126. * @returns the cloned material
  25127. */
  25128. clone(name: string): Nullable<Material>;
  25129. /**
  25130. * Gets the meshes bound to the material
  25131. * @returns an array of meshes bound to the material
  25132. */
  25133. getBindedMeshes(): AbstractMesh[];
  25134. /**
  25135. * Force shader compilation
  25136. * @param mesh defines the mesh associated with this material
  25137. * @param onCompiled defines a function to execute once the material is compiled
  25138. * @param options defines the options to configure the compilation
  25139. * @param onError defines a function to execute if the material fails compiling
  25140. */
  25141. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25142. /**
  25143. * Force shader compilation
  25144. * @param mesh defines the mesh that will use this material
  25145. * @param options defines additional options for compiling the shaders
  25146. * @returns a promise that resolves when the compilation completes
  25147. */
  25148. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25149. private static readonly _AllDirtyCallBack;
  25150. private static readonly _ImageProcessingDirtyCallBack;
  25151. private static readonly _TextureDirtyCallBack;
  25152. private static readonly _FresnelDirtyCallBack;
  25153. private static readonly _MiscDirtyCallBack;
  25154. private static readonly _LightsDirtyCallBack;
  25155. private static readonly _AttributeDirtyCallBack;
  25156. private static _FresnelAndMiscDirtyCallBack;
  25157. private static _TextureAndMiscDirtyCallBack;
  25158. private static readonly _DirtyCallbackArray;
  25159. private static readonly _RunDirtyCallBacks;
  25160. /**
  25161. * Marks a define in the material to indicate that it needs to be re-computed
  25162. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25163. */
  25164. markAsDirty(flag: number): void;
  25165. /**
  25166. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25167. * @param func defines a function which checks material defines against the submeshes
  25168. */
  25169. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25170. /**
  25171. * Indicates that the scene should check if the rendering now needs a prepass
  25172. */
  25173. protected _markScenePrePassDirty(): void;
  25174. /**
  25175. * Indicates that we need to re-calculated for all submeshes
  25176. */
  25177. protected _markAllSubMeshesAsAllDirty(): void;
  25178. /**
  25179. * Indicates that image processing needs to be re-calculated for all submeshes
  25180. */
  25181. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25182. /**
  25183. * Indicates that textures need to be re-calculated for all submeshes
  25184. */
  25185. protected _markAllSubMeshesAsTexturesDirty(): void;
  25186. /**
  25187. * Indicates that fresnel needs to be re-calculated for all submeshes
  25188. */
  25189. protected _markAllSubMeshesAsFresnelDirty(): void;
  25190. /**
  25191. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25192. */
  25193. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25194. /**
  25195. * Indicates that lights need to be re-calculated for all submeshes
  25196. */
  25197. protected _markAllSubMeshesAsLightsDirty(): void;
  25198. /**
  25199. * Indicates that attributes need to be re-calculated for all submeshes
  25200. */
  25201. protected _markAllSubMeshesAsAttributesDirty(): void;
  25202. /**
  25203. * Indicates that misc needs to be re-calculated for all submeshes
  25204. */
  25205. protected _markAllSubMeshesAsMiscDirty(): void;
  25206. /**
  25207. * Indicates that textures and misc need to be re-calculated for all submeshes
  25208. */
  25209. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25210. /**
  25211. * Sets the required values to the prepass renderer.
  25212. * @param prePassRenderer defines the prepass renderer to setup.
  25213. * @returns true if the pre pass is needed.
  25214. */
  25215. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25216. /**
  25217. * Disposes the material
  25218. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25219. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25220. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25221. */
  25222. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25223. /** @hidden */
  25224. private releaseVertexArrayObject;
  25225. /**
  25226. * Serializes this material
  25227. * @returns the serialized material object
  25228. */
  25229. serialize(): any;
  25230. /**
  25231. * Creates a material from parsed material data
  25232. * @param parsedMaterial defines parsed material data
  25233. * @param scene defines the hosting scene
  25234. * @param rootUrl defines the root URL to use to load textures
  25235. * @returns a new material
  25236. */
  25237. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25238. }
  25239. }
  25240. declare module BABYLON {
  25241. /**
  25242. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25243. * separate meshes. This can be use to improve performances.
  25244. * @see https://doc.babylonjs.com/how_to/multi_materials
  25245. */
  25246. export class MultiMaterial extends Material {
  25247. private _subMaterials;
  25248. /**
  25249. * Gets or Sets the list of Materials used within the multi material.
  25250. * They need to be ordered according to the submeshes order in the associated mesh
  25251. */
  25252. get subMaterials(): Nullable<Material>[];
  25253. set subMaterials(value: Nullable<Material>[]);
  25254. /**
  25255. * Function used to align with Node.getChildren()
  25256. * @returns the list of Materials used within the multi material
  25257. */
  25258. getChildren(): Nullable<Material>[];
  25259. /**
  25260. * Instantiates a new Multi Material
  25261. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25262. * separate meshes. This can be use to improve performances.
  25263. * @see https://doc.babylonjs.com/how_to/multi_materials
  25264. * @param name Define the name in the scene
  25265. * @param scene Define the scene the material belongs to
  25266. */
  25267. constructor(name: string, scene: Scene);
  25268. private _hookArray;
  25269. /**
  25270. * Get one of the submaterial by its index in the submaterials array
  25271. * @param index The index to look the sub material at
  25272. * @returns The Material if the index has been defined
  25273. */
  25274. getSubMaterial(index: number): Nullable<Material>;
  25275. /**
  25276. * Get the list of active textures for the whole sub materials list.
  25277. * @returns All the textures that will be used during the rendering
  25278. */
  25279. getActiveTextures(): BaseTexture[];
  25280. /**
  25281. * Gets the current class name of the material e.g. "MultiMaterial"
  25282. * Mainly use in serialization.
  25283. * @returns the class name
  25284. */
  25285. getClassName(): string;
  25286. /**
  25287. * Checks if the material is ready to render the requested sub mesh
  25288. * @param mesh Define the mesh the submesh belongs to
  25289. * @param subMesh Define the sub mesh to look readyness for
  25290. * @param useInstances Define whether or not the material is used with instances
  25291. * @returns true if ready, otherwise false
  25292. */
  25293. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25294. /**
  25295. * Clones the current material and its related sub materials
  25296. * @param name Define the name of the newly cloned material
  25297. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25298. * @returns the cloned material
  25299. */
  25300. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25301. /**
  25302. * Serializes the materials into a JSON representation.
  25303. * @returns the JSON representation
  25304. */
  25305. serialize(): any;
  25306. /**
  25307. * Dispose the material and release its associated resources
  25308. * @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)
  25309. * @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)
  25310. * @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)
  25311. */
  25312. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25313. /**
  25314. * Creates a MultiMaterial from parsed MultiMaterial data.
  25315. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25316. * @param scene defines the hosting scene
  25317. * @returns a new MultiMaterial
  25318. */
  25319. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25320. }
  25321. }
  25322. declare module BABYLON {
  25323. /**
  25324. * Defines a subdivision inside a mesh
  25325. */
  25326. export class SubMesh implements ICullable {
  25327. /** the material index to use */
  25328. materialIndex: number;
  25329. /** vertex index start */
  25330. verticesStart: number;
  25331. /** vertices count */
  25332. verticesCount: number;
  25333. /** index start */
  25334. indexStart: number;
  25335. /** indices count */
  25336. indexCount: number;
  25337. /** @hidden */
  25338. _materialDefines: Nullable<MaterialDefines>;
  25339. /** @hidden */
  25340. _materialEffect: Nullable<Effect>;
  25341. /** @hidden */
  25342. _effectOverride: Nullable<Effect>;
  25343. /**
  25344. * Gets material defines used by the effect associated to the sub mesh
  25345. */
  25346. get materialDefines(): Nullable<MaterialDefines>;
  25347. /**
  25348. * Sets material defines used by the effect associated to the sub mesh
  25349. */
  25350. set materialDefines(defines: Nullable<MaterialDefines>);
  25351. /**
  25352. * Gets associated effect
  25353. */
  25354. get effect(): Nullable<Effect>;
  25355. /**
  25356. * Sets associated effect (effect used to render this submesh)
  25357. * @param effect defines the effect to associate with
  25358. * @param defines defines the set of defines used to compile this effect
  25359. */
  25360. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25361. /** @hidden */
  25362. _linesIndexCount: number;
  25363. private _mesh;
  25364. private _renderingMesh;
  25365. private _boundingInfo;
  25366. private _linesIndexBuffer;
  25367. /** @hidden */
  25368. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25369. /** @hidden */
  25370. _trianglePlanes: Plane[];
  25371. /** @hidden */
  25372. _lastColliderTransformMatrix: Nullable<Matrix>;
  25373. /** @hidden */
  25374. _renderId: number;
  25375. /** @hidden */
  25376. _alphaIndex: number;
  25377. /** @hidden */
  25378. _distanceToCamera: number;
  25379. /** @hidden */
  25380. _id: number;
  25381. private _currentMaterial;
  25382. /**
  25383. * Add a new submesh to a mesh
  25384. * @param materialIndex defines the material index to use
  25385. * @param verticesStart defines vertex index start
  25386. * @param verticesCount defines vertices count
  25387. * @param indexStart defines index start
  25388. * @param indexCount defines indices count
  25389. * @param mesh defines the parent mesh
  25390. * @param renderingMesh defines an optional rendering mesh
  25391. * @param createBoundingBox defines if bounding box should be created for this submesh
  25392. * @returns the new submesh
  25393. */
  25394. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25395. /**
  25396. * Creates a new submesh
  25397. * @param materialIndex defines the material index to use
  25398. * @param verticesStart defines vertex index start
  25399. * @param verticesCount defines vertices count
  25400. * @param indexStart defines index start
  25401. * @param indexCount defines indices count
  25402. * @param mesh defines the parent mesh
  25403. * @param renderingMesh defines an optional rendering mesh
  25404. * @param createBoundingBox defines if bounding box should be created for this submesh
  25405. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25406. */
  25407. constructor(
  25408. /** the material index to use */
  25409. materialIndex: number,
  25410. /** vertex index start */
  25411. verticesStart: number,
  25412. /** vertices count */
  25413. verticesCount: number,
  25414. /** index start */
  25415. indexStart: number,
  25416. /** indices count */
  25417. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25418. /**
  25419. * Returns true if this submesh covers the entire parent mesh
  25420. * @ignorenaming
  25421. */
  25422. get IsGlobal(): boolean;
  25423. /**
  25424. * Returns the submesh BoudingInfo object
  25425. * @returns current bounding info (or mesh's one if the submesh is global)
  25426. */
  25427. getBoundingInfo(): BoundingInfo;
  25428. /**
  25429. * Sets the submesh BoundingInfo
  25430. * @param boundingInfo defines the new bounding info to use
  25431. * @returns the SubMesh
  25432. */
  25433. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25434. /**
  25435. * Returns the mesh of the current submesh
  25436. * @return the parent mesh
  25437. */
  25438. getMesh(): AbstractMesh;
  25439. /**
  25440. * Returns the rendering mesh of the submesh
  25441. * @returns the rendering mesh (could be different from parent mesh)
  25442. */
  25443. getRenderingMesh(): Mesh;
  25444. /**
  25445. * Returns the replacement mesh of the submesh
  25446. * @returns the replacement mesh (could be different from parent mesh)
  25447. */
  25448. getReplacementMesh(): Nullable<AbstractMesh>;
  25449. /**
  25450. * Returns the effective mesh of the submesh
  25451. * @returns the effective mesh (could be different from parent mesh)
  25452. */
  25453. getEffectiveMesh(): AbstractMesh;
  25454. /**
  25455. * Returns the submesh material
  25456. * @returns null or the current material
  25457. */
  25458. getMaterial(): Nullable<Material>;
  25459. private _IsMultiMaterial;
  25460. /**
  25461. * Sets a new updated BoundingInfo object to the submesh
  25462. * @param data defines an optional position array to use to determine the bounding info
  25463. * @returns the SubMesh
  25464. */
  25465. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25466. /** @hidden */
  25467. _checkCollision(collider: Collider): boolean;
  25468. /**
  25469. * Updates the submesh BoundingInfo
  25470. * @param world defines the world matrix to use to update the bounding info
  25471. * @returns the submesh
  25472. */
  25473. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25474. /**
  25475. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25476. * @param frustumPlanes defines the frustum planes
  25477. * @returns true if the submesh is intersecting with the frustum
  25478. */
  25479. isInFrustum(frustumPlanes: Plane[]): boolean;
  25480. /**
  25481. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25482. * @param frustumPlanes defines the frustum planes
  25483. * @returns true if the submesh is inside the frustum
  25484. */
  25485. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25486. /**
  25487. * Renders the submesh
  25488. * @param enableAlphaMode defines if alpha needs to be used
  25489. * @returns the submesh
  25490. */
  25491. render(enableAlphaMode: boolean): SubMesh;
  25492. /**
  25493. * @hidden
  25494. */
  25495. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25496. /**
  25497. * Checks if the submesh intersects with a ray
  25498. * @param ray defines the ray to test
  25499. * @returns true is the passed ray intersects the submesh bounding box
  25500. */
  25501. canIntersects(ray: Ray): boolean;
  25502. /**
  25503. * Intersects current submesh with a ray
  25504. * @param ray defines the ray to test
  25505. * @param positions defines mesh's positions array
  25506. * @param indices defines mesh's indices array
  25507. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25508. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25509. * @returns intersection info or null if no intersection
  25510. */
  25511. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25512. /** @hidden */
  25513. private _intersectLines;
  25514. /** @hidden */
  25515. private _intersectUnIndexedLines;
  25516. /** @hidden */
  25517. private _intersectTriangles;
  25518. /** @hidden */
  25519. private _intersectUnIndexedTriangles;
  25520. /** @hidden */
  25521. _rebuild(): void;
  25522. /**
  25523. * Creates a new submesh from the passed mesh
  25524. * @param newMesh defines the new hosting mesh
  25525. * @param newRenderingMesh defines an optional rendering mesh
  25526. * @returns the new submesh
  25527. */
  25528. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25529. /**
  25530. * Release associated resources
  25531. */
  25532. dispose(): void;
  25533. /**
  25534. * Gets the class name
  25535. * @returns the string "SubMesh".
  25536. */
  25537. getClassName(): string;
  25538. /**
  25539. * Creates a new submesh from indices data
  25540. * @param materialIndex the index of the main mesh material
  25541. * @param startIndex the index where to start the copy in the mesh indices array
  25542. * @param indexCount the number of indices to copy then from the startIndex
  25543. * @param mesh the main mesh to create the submesh from
  25544. * @param renderingMesh the optional rendering mesh
  25545. * @returns a new submesh
  25546. */
  25547. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25548. }
  25549. }
  25550. declare module BABYLON {
  25551. /**
  25552. * Class used to represent data loading progression
  25553. */
  25554. export class SceneLoaderFlags {
  25555. private static _ForceFullSceneLoadingForIncremental;
  25556. private static _ShowLoadingScreen;
  25557. private static _CleanBoneMatrixWeights;
  25558. private static _loggingLevel;
  25559. /**
  25560. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25561. */
  25562. static get ForceFullSceneLoadingForIncremental(): boolean;
  25563. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25564. /**
  25565. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25566. */
  25567. static get ShowLoadingScreen(): boolean;
  25568. static set ShowLoadingScreen(value: boolean);
  25569. /**
  25570. * Defines the current logging level (while loading the scene)
  25571. * @ignorenaming
  25572. */
  25573. static get loggingLevel(): number;
  25574. static set loggingLevel(value: number);
  25575. /**
  25576. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25577. */
  25578. static get CleanBoneMatrixWeights(): boolean;
  25579. static set CleanBoneMatrixWeights(value: boolean);
  25580. }
  25581. }
  25582. declare module BABYLON {
  25583. /**
  25584. * Class used to store geometry data (vertex buffers + index buffer)
  25585. */
  25586. export class Geometry implements IGetSetVerticesData {
  25587. /**
  25588. * Gets or sets the ID of the geometry
  25589. */
  25590. id: string;
  25591. /**
  25592. * Gets or sets the unique ID of the geometry
  25593. */
  25594. uniqueId: number;
  25595. /**
  25596. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25597. */
  25598. delayLoadState: number;
  25599. /**
  25600. * Gets the file containing the data to load when running in delay load state
  25601. */
  25602. delayLoadingFile: Nullable<string>;
  25603. /**
  25604. * Callback called when the geometry is updated
  25605. */
  25606. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25607. private _scene;
  25608. private _engine;
  25609. private _meshes;
  25610. private _totalVertices;
  25611. /** @hidden */
  25612. _indices: IndicesArray;
  25613. /** @hidden */
  25614. _vertexBuffers: {
  25615. [key: string]: VertexBuffer;
  25616. };
  25617. private _isDisposed;
  25618. private _extend;
  25619. private _boundingBias;
  25620. /** @hidden */
  25621. _delayInfo: Array<string>;
  25622. private _indexBuffer;
  25623. private _indexBufferIsUpdatable;
  25624. /** @hidden */
  25625. _boundingInfo: Nullable<BoundingInfo>;
  25626. /** @hidden */
  25627. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25628. /** @hidden */
  25629. _softwareSkinningFrameId: number;
  25630. private _vertexArrayObjects;
  25631. private _updatable;
  25632. /** @hidden */
  25633. _positions: Nullable<Vector3[]>;
  25634. /**
  25635. * 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
  25636. */
  25637. get boundingBias(): Vector2;
  25638. /**
  25639. * 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
  25640. */
  25641. set boundingBias(value: Vector2);
  25642. /**
  25643. * Static function used to attach a new empty geometry to a mesh
  25644. * @param mesh defines the mesh to attach the geometry to
  25645. * @returns the new Geometry
  25646. */
  25647. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25648. /** Get the list of meshes using this geometry */
  25649. get meshes(): Mesh[];
  25650. /**
  25651. * 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
  25652. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25653. */
  25654. useBoundingInfoFromGeometry: boolean;
  25655. /**
  25656. * Creates a new geometry
  25657. * @param id defines the unique ID
  25658. * @param scene defines the hosting scene
  25659. * @param vertexData defines the VertexData used to get geometry data
  25660. * @param updatable defines if geometry must be updatable (false by default)
  25661. * @param mesh defines the mesh that will be associated with the geometry
  25662. */
  25663. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25664. /**
  25665. * Gets the current extend of the geometry
  25666. */
  25667. get extend(): {
  25668. minimum: Vector3;
  25669. maximum: Vector3;
  25670. };
  25671. /**
  25672. * Gets the hosting scene
  25673. * @returns the hosting Scene
  25674. */
  25675. getScene(): Scene;
  25676. /**
  25677. * Gets the hosting engine
  25678. * @returns the hosting Engine
  25679. */
  25680. getEngine(): Engine;
  25681. /**
  25682. * Defines if the geometry is ready to use
  25683. * @returns true if the geometry is ready to be used
  25684. */
  25685. isReady(): boolean;
  25686. /**
  25687. * Gets a value indicating that the geometry should not be serialized
  25688. */
  25689. get doNotSerialize(): boolean;
  25690. /** @hidden */
  25691. _rebuild(): void;
  25692. /**
  25693. * Affects all geometry data in one call
  25694. * @param vertexData defines the geometry data
  25695. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25696. */
  25697. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25698. /**
  25699. * Set specific vertex data
  25700. * @param kind defines the data kind (Position, normal, etc...)
  25701. * @param data defines the vertex data to use
  25702. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25703. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25704. */
  25705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25706. /**
  25707. * Removes a specific vertex data
  25708. * @param kind defines the data kind (Position, normal, etc...)
  25709. */
  25710. removeVerticesData(kind: string): void;
  25711. /**
  25712. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25713. * @param buffer defines the vertex buffer to use
  25714. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25715. */
  25716. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25717. /**
  25718. * Update a specific vertex buffer
  25719. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25720. * It will do nothing if the buffer is not updatable
  25721. * @param kind defines the data kind (Position, normal, etc...)
  25722. * @param data defines the data to use
  25723. * @param offset defines the offset in the target buffer where to store the data
  25724. * @param useBytes set to true if the offset is in bytes
  25725. */
  25726. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25727. /**
  25728. * Update a specific vertex buffer
  25729. * This function will create a new buffer if the current one is not updatable
  25730. * @param kind defines the data kind (Position, normal, etc...)
  25731. * @param data defines the data to use
  25732. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25733. */
  25734. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25735. private _updateBoundingInfo;
  25736. /** @hidden */
  25737. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25738. /**
  25739. * Gets total number of vertices
  25740. * @returns the total number of vertices
  25741. */
  25742. getTotalVertices(): number;
  25743. /**
  25744. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25745. * @param kind defines the data kind (Position, normal, etc...)
  25746. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25748. * @returns a float array containing vertex data
  25749. */
  25750. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25751. /**
  25752. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25753. * @param kind defines the data kind (Position, normal, etc...)
  25754. * @returns true if the vertex buffer with the specified kind is updatable
  25755. */
  25756. isVertexBufferUpdatable(kind: string): boolean;
  25757. /**
  25758. * Gets a specific vertex buffer
  25759. * @param kind defines the data kind (Position, normal, etc...)
  25760. * @returns a VertexBuffer
  25761. */
  25762. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25763. /**
  25764. * Returns all vertex buffers
  25765. * @return an object holding all vertex buffers indexed by kind
  25766. */
  25767. getVertexBuffers(): Nullable<{
  25768. [key: string]: VertexBuffer;
  25769. }>;
  25770. /**
  25771. * Gets a boolean indicating if specific vertex buffer is present
  25772. * @param kind defines the data kind (Position, normal, etc...)
  25773. * @returns true if data is present
  25774. */
  25775. isVerticesDataPresent(kind: string): boolean;
  25776. /**
  25777. * Gets a list of all attached data kinds (Position, normal, etc...)
  25778. * @returns a list of string containing all kinds
  25779. */
  25780. getVerticesDataKinds(): string[];
  25781. /**
  25782. * Update index buffer
  25783. * @param indices defines the indices to store in the index buffer
  25784. * @param offset defines the offset in the target buffer where to store the data
  25785. * @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)
  25786. */
  25787. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25788. /**
  25789. * Creates a new index buffer
  25790. * @param indices defines the indices to store in the index buffer
  25791. * @param totalVertices defines the total number of vertices (could be null)
  25792. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25793. */
  25794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25795. /**
  25796. * Return the total number of indices
  25797. * @returns the total number of indices
  25798. */
  25799. getTotalIndices(): number;
  25800. /**
  25801. * Gets the index buffer array
  25802. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25803. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25804. * @returns the index buffer array
  25805. */
  25806. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25807. /**
  25808. * Gets the index buffer
  25809. * @return the index buffer
  25810. */
  25811. getIndexBuffer(): Nullable<DataBuffer>;
  25812. /** @hidden */
  25813. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25814. /**
  25815. * Release the associated resources for a specific mesh
  25816. * @param mesh defines the source mesh
  25817. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25818. */
  25819. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25820. /**
  25821. * Apply current geometry to a given mesh
  25822. * @param mesh defines the mesh to apply geometry to
  25823. */
  25824. applyToMesh(mesh: Mesh): void;
  25825. private _updateExtend;
  25826. private _applyToMesh;
  25827. private notifyUpdate;
  25828. /**
  25829. * Load the geometry if it was flagged as delay loaded
  25830. * @param scene defines the hosting scene
  25831. * @param onLoaded defines a callback called when the geometry is loaded
  25832. */
  25833. load(scene: Scene, onLoaded?: () => void): void;
  25834. private _queueLoad;
  25835. /**
  25836. * Invert the geometry to move from a right handed system to a left handed one.
  25837. */
  25838. toLeftHanded(): void;
  25839. /** @hidden */
  25840. _resetPointsArrayCache(): void;
  25841. /** @hidden */
  25842. _generatePointsArray(): boolean;
  25843. /**
  25844. * Gets a value indicating if the geometry is disposed
  25845. * @returns true if the geometry was disposed
  25846. */
  25847. isDisposed(): boolean;
  25848. private _disposeVertexArrayObjects;
  25849. /**
  25850. * Free all associated resources
  25851. */
  25852. dispose(): void;
  25853. /**
  25854. * Clone the current geometry into a new geometry
  25855. * @param id defines the unique ID of the new geometry
  25856. * @returns a new geometry object
  25857. */
  25858. copy(id: string): Geometry;
  25859. /**
  25860. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25861. * @return a JSON representation of the current geometry data (without the vertices data)
  25862. */
  25863. serialize(): any;
  25864. private toNumberArray;
  25865. /**
  25866. * Serialize all vertices data into a JSON oject
  25867. * @returns a JSON representation of the current geometry data
  25868. */
  25869. serializeVerticeData(): any;
  25870. /**
  25871. * Extracts a clone of a mesh geometry
  25872. * @param mesh defines the source mesh
  25873. * @param id defines the unique ID of the new geometry object
  25874. * @returns the new geometry object
  25875. */
  25876. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25877. /**
  25878. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25879. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25880. * Be aware Math.random() could cause collisions, but:
  25881. * "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"
  25882. * @returns a string containing a new GUID
  25883. */
  25884. static RandomId(): string;
  25885. /** @hidden */
  25886. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25887. private static _CleanMatricesWeights;
  25888. /**
  25889. * Create a new geometry from persisted data (Using .babylon file format)
  25890. * @param parsedVertexData defines the persisted data
  25891. * @param scene defines the hosting scene
  25892. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25893. * @returns the new geometry object
  25894. */
  25895. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25896. }
  25897. }
  25898. declare module BABYLON {
  25899. /**
  25900. * Define an interface for all classes that will get and set the data on vertices
  25901. */
  25902. export interface IGetSetVerticesData {
  25903. /**
  25904. * Gets a boolean indicating if specific vertex data is present
  25905. * @param kind defines the vertex data kind to use
  25906. * @returns true is data kind is present
  25907. */
  25908. isVerticesDataPresent(kind: string): boolean;
  25909. /**
  25910. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25911. * @param kind defines the data kind (Position, normal, etc...)
  25912. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25913. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25914. * @returns a float array containing vertex data
  25915. */
  25916. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25917. /**
  25918. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25919. * @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.
  25920. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25921. * @returns the indices array or an empty array if the mesh has no geometry
  25922. */
  25923. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25924. /**
  25925. * Set specific vertex data
  25926. * @param kind defines the data kind (Position, normal, etc...)
  25927. * @param data defines the vertex data to use
  25928. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25929. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25930. */
  25931. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25932. /**
  25933. * Update a specific associated vertex buffer
  25934. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25935. * - VertexBuffer.PositionKind
  25936. * - VertexBuffer.UVKind
  25937. * - VertexBuffer.UV2Kind
  25938. * - VertexBuffer.UV3Kind
  25939. * - VertexBuffer.UV4Kind
  25940. * - VertexBuffer.UV5Kind
  25941. * - VertexBuffer.UV6Kind
  25942. * - VertexBuffer.ColorKind
  25943. * - VertexBuffer.MatricesIndicesKind
  25944. * - VertexBuffer.MatricesIndicesExtraKind
  25945. * - VertexBuffer.MatricesWeightsKind
  25946. * - VertexBuffer.MatricesWeightsExtraKind
  25947. * @param data defines the data source
  25948. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25949. * @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)
  25950. */
  25951. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25952. /**
  25953. * Creates a new index buffer
  25954. * @param indices defines the indices to store in the index buffer
  25955. * @param totalVertices defines the total number of vertices (could be null)
  25956. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25957. */
  25958. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25959. }
  25960. /**
  25961. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25962. */
  25963. export class VertexData {
  25964. /**
  25965. * Mesh side orientation : usually the external or front surface
  25966. */
  25967. static readonly FRONTSIDE: number;
  25968. /**
  25969. * Mesh side orientation : usually the internal or back surface
  25970. */
  25971. static readonly BACKSIDE: number;
  25972. /**
  25973. * Mesh side orientation : both internal and external or front and back surfaces
  25974. */
  25975. static readonly DOUBLESIDE: number;
  25976. /**
  25977. * Mesh side orientation : by default, `FRONTSIDE`
  25978. */
  25979. static readonly DEFAULTSIDE: number;
  25980. /**
  25981. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25982. */
  25983. positions: Nullable<FloatArray>;
  25984. /**
  25985. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25986. */
  25987. normals: Nullable<FloatArray>;
  25988. /**
  25989. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25990. */
  25991. tangents: Nullable<FloatArray>;
  25992. /**
  25993. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25994. */
  25995. uvs: Nullable<FloatArray>;
  25996. /**
  25997. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25998. */
  25999. uvs2: Nullable<FloatArray>;
  26000. /**
  26001. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26002. */
  26003. uvs3: Nullable<FloatArray>;
  26004. /**
  26005. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26006. */
  26007. uvs4: Nullable<FloatArray>;
  26008. /**
  26009. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26010. */
  26011. uvs5: Nullable<FloatArray>;
  26012. /**
  26013. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26014. */
  26015. uvs6: Nullable<FloatArray>;
  26016. /**
  26017. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26018. */
  26019. colors: Nullable<FloatArray>;
  26020. /**
  26021. * 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).
  26022. */
  26023. matricesIndices: Nullable<FloatArray>;
  26024. /**
  26025. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26026. */
  26027. matricesWeights: Nullable<FloatArray>;
  26028. /**
  26029. * An array extending the number of possible indices
  26030. */
  26031. matricesIndicesExtra: Nullable<FloatArray>;
  26032. /**
  26033. * An array extending the number of possible weights when the number of indices is extended
  26034. */
  26035. matricesWeightsExtra: Nullable<FloatArray>;
  26036. /**
  26037. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26038. */
  26039. indices: Nullable<IndicesArray>;
  26040. /**
  26041. * Uses the passed data array to set the set the values for the specified kind of data
  26042. * @param data a linear array of floating numbers
  26043. * @param kind the type of data that is being set, eg positions, colors etc
  26044. */
  26045. set(data: FloatArray, kind: string): void;
  26046. /**
  26047. * Associates the vertexData to the passed Mesh.
  26048. * Sets it as updatable or not (default `false`)
  26049. * @param mesh the mesh the vertexData is applied to
  26050. * @param updatable when used and having the value true allows new data to update the vertexData
  26051. * @returns the VertexData
  26052. */
  26053. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26054. /**
  26055. * Associates the vertexData to the passed Geometry.
  26056. * Sets it as updatable or not (default `false`)
  26057. * @param geometry the geometry the vertexData is applied to
  26058. * @param updatable when used and having the value true allows new data to update the vertexData
  26059. * @returns VertexData
  26060. */
  26061. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26062. /**
  26063. * Updates the associated mesh
  26064. * @param mesh the mesh to be updated
  26065. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26066. * @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
  26067. * @returns VertexData
  26068. */
  26069. updateMesh(mesh: Mesh): VertexData;
  26070. /**
  26071. * Updates the associated geometry
  26072. * @param geometry the geometry to be updated
  26073. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26074. * @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
  26075. * @returns VertexData.
  26076. */
  26077. updateGeometry(geometry: Geometry): VertexData;
  26078. private _applyTo;
  26079. private _update;
  26080. /**
  26081. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26082. * @param matrix the transforming matrix
  26083. * @returns the VertexData
  26084. */
  26085. transform(matrix: Matrix): VertexData;
  26086. /**
  26087. * Merges the passed VertexData into the current one
  26088. * @param other the VertexData to be merged into the current one
  26089. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26090. * @returns the modified VertexData
  26091. */
  26092. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26093. private _mergeElement;
  26094. private _validate;
  26095. /**
  26096. * Serializes the VertexData
  26097. * @returns a serialized object
  26098. */
  26099. serialize(): any;
  26100. /**
  26101. * Extracts the vertexData from a mesh
  26102. * @param mesh the mesh from which to extract the VertexData
  26103. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26104. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26105. * @returns the object VertexData associated to the passed mesh
  26106. */
  26107. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26108. /**
  26109. * Extracts the vertexData from the geometry
  26110. * @param geometry the geometry from which to extract the VertexData
  26111. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26112. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26113. * @returns the object VertexData associated to the passed mesh
  26114. */
  26115. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26116. private static _ExtractFrom;
  26117. /**
  26118. * Creates the VertexData for a Ribbon
  26119. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26120. * * pathArray array of paths, each of which an array of successive Vector3
  26121. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26122. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26123. * * 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
  26124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26125. * * 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)
  26126. * * 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)
  26127. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26128. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26129. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26130. * @returns the VertexData of the ribbon
  26131. */
  26132. static CreateRibbon(options: {
  26133. pathArray: Vector3[][];
  26134. closeArray?: boolean;
  26135. closePath?: boolean;
  26136. offset?: number;
  26137. sideOrientation?: number;
  26138. frontUVs?: Vector4;
  26139. backUVs?: Vector4;
  26140. invertUV?: boolean;
  26141. uvs?: Vector2[];
  26142. colors?: Color4[];
  26143. }): VertexData;
  26144. /**
  26145. * Creates the VertexData for a box
  26146. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26147. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26148. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26149. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26150. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26151. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26152. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26154. * * 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)
  26155. * * 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)
  26156. * @returns the VertexData of the box
  26157. */
  26158. static CreateBox(options: {
  26159. size?: number;
  26160. width?: number;
  26161. height?: number;
  26162. depth?: number;
  26163. faceUV?: Vector4[];
  26164. faceColors?: Color4[];
  26165. sideOrientation?: number;
  26166. frontUVs?: Vector4;
  26167. backUVs?: Vector4;
  26168. }): VertexData;
  26169. /**
  26170. * Creates the VertexData for a tiled box
  26171. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26172. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26173. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26174. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26176. * @returns the VertexData of the box
  26177. */
  26178. static CreateTiledBox(options: {
  26179. pattern?: number;
  26180. width?: number;
  26181. height?: number;
  26182. depth?: number;
  26183. tileSize?: number;
  26184. tileWidth?: number;
  26185. tileHeight?: number;
  26186. alignHorizontal?: number;
  26187. alignVertical?: number;
  26188. faceUV?: Vector4[];
  26189. faceColors?: Color4[];
  26190. sideOrientation?: number;
  26191. }): VertexData;
  26192. /**
  26193. * Creates the VertexData for a tiled plane
  26194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26195. * * pattern a limited pattern arrangement depending on the number
  26196. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26197. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26198. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26200. * * 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)
  26201. * * 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)
  26202. * @returns the VertexData of the tiled plane
  26203. */
  26204. static CreateTiledPlane(options: {
  26205. pattern?: number;
  26206. tileSize?: number;
  26207. tileWidth?: number;
  26208. tileHeight?: number;
  26209. size?: number;
  26210. width?: number;
  26211. height?: number;
  26212. alignHorizontal?: number;
  26213. alignVertical?: number;
  26214. sideOrientation?: number;
  26215. frontUVs?: Vector4;
  26216. backUVs?: Vector4;
  26217. }): VertexData;
  26218. /**
  26219. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26220. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26221. * * segments sets the number of horizontal strips optional, default 32
  26222. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26223. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26224. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26225. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26226. * * 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
  26227. * * 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
  26228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26229. * * 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. * * 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. * @returns the VertexData of the ellipsoid
  26232. */
  26233. static CreateSphere(options: {
  26234. segments?: number;
  26235. diameter?: number;
  26236. diameterX?: number;
  26237. diameterY?: number;
  26238. diameterZ?: number;
  26239. arc?: number;
  26240. slice?: number;
  26241. sideOrientation?: number;
  26242. frontUVs?: Vector4;
  26243. backUVs?: Vector4;
  26244. }): VertexData;
  26245. /**
  26246. * Creates the VertexData for a cylinder, cone or prism
  26247. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26248. * * height sets the height (y direction) of the cylinder, optional, default 2
  26249. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26250. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26251. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26252. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26253. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26254. * * 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
  26255. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26256. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26257. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26258. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26260. * * 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)
  26261. * * 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)
  26262. * @returns the VertexData of the cylinder, cone or prism
  26263. */
  26264. static CreateCylinder(options: {
  26265. height?: number;
  26266. diameterTop?: number;
  26267. diameterBottom?: number;
  26268. diameter?: number;
  26269. tessellation?: number;
  26270. subdivisions?: number;
  26271. arc?: number;
  26272. faceColors?: Color4[];
  26273. faceUV?: Vector4[];
  26274. hasRings?: boolean;
  26275. enclose?: boolean;
  26276. sideOrientation?: number;
  26277. frontUVs?: Vector4;
  26278. backUVs?: Vector4;
  26279. }): VertexData;
  26280. /**
  26281. * Creates the VertexData for a torus
  26282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26283. * * diameter the diameter of the torus, optional default 1
  26284. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26285. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26287. * * 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)
  26288. * * 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)
  26289. * @returns the VertexData of the torus
  26290. */
  26291. static CreateTorus(options: {
  26292. diameter?: number;
  26293. thickness?: number;
  26294. tessellation?: number;
  26295. sideOrientation?: number;
  26296. frontUVs?: Vector4;
  26297. backUVs?: Vector4;
  26298. }): VertexData;
  26299. /**
  26300. * Creates the VertexData of the LineSystem
  26301. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26302. * - lines an array of lines, each line being an array of successive Vector3
  26303. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26304. * @returns the VertexData of the LineSystem
  26305. */
  26306. static CreateLineSystem(options: {
  26307. lines: Vector3[][];
  26308. colors?: Nullable<Color4[][]>;
  26309. }): VertexData;
  26310. /**
  26311. * Create the VertexData for a DashedLines
  26312. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26313. * - points an array successive Vector3
  26314. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26315. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26316. * - dashNb the intended total number of dashes, optional, default 200
  26317. * @returns the VertexData for the DashedLines
  26318. */
  26319. static CreateDashedLines(options: {
  26320. points: Vector3[];
  26321. dashSize?: number;
  26322. gapSize?: number;
  26323. dashNb?: number;
  26324. }): VertexData;
  26325. /**
  26326. * Creates the VertexData for a Ground
  26327. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26328. * - width the width (x direction) of the ground, optional, default 1
  26329. * - height the height (z direction) of the ground, optional, default 1
  26330. * - subdivisions the number of subdivisions per side, optional, default 1
  26331. * @returns the VertexData of the Ground
  26332. */
  26333. static CreateGround(options: {
  26334. width?: number;
  26335. height?: number;
  26336. subdivisions?: number;
  26337. subdivisionsX?: number;
  26338. subdivisionsY?: number;
  26339. }): VertexData;
  26340. /**
  26341. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26343. * * xmin the ground minimum X coordinate, optional, default -1
  26344. * * zmin the ground minimum Z coordinate, optional, default -1
  26345. * * xmax the ground maximum X coordinate, optional, default 1
  26346. * * zmax the ground maximum Z coordinate, optional, default 1
  26347. * * 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}
  26348. * * 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}
  26349. * @returns the VertexData of the TiledGround
  26350. */
  26351. static CreateTiledGround(options: {
  26352. xmin: number;
  26353. zmin: number;
  26354. xmax: number;
  26355. zmax: number;
  26356. subdivisions?: {
  26357. w: number;
  26358. h: number;
  26359. };
  26360. precision?: {
  26361. w: number;
  26362. h: number;
  26363. };
  26364. }): VertexData;
  26365. /**
  26366. * Creates the VertexData of the Ground designed from a heightmap
  26367. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26368. * * width the width (x direction) of the ground
  26369. * * height the height (z direction) of the ground
  26370. * * subdivisions the number of subdivisions per side
  26371. * * minHeight the minimum altitude on the ground, optional, default 0
  26372. * * maxHeight the maximum altitude on the ground, optional default 1
  26373. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26374. * * buffer the array holding the image color data
  26375. * * bufferWidth the width of image
  26376. * * bufferHeight the height of image
  26377. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26378. * @returns the VertexData of the Ground designed from a heightmap
  26379. */
  26380. static CreateGroundFromHeightMap(options: {
  26381. width: number;
  26382. height: number;
  26383. subdivisions: number;
  26384. minHeight: number;
  26385. maxHeight: number;
  26386. colorFilter: Color3;
  26387. buffer: Uint8Array;
  26388. bufferWidth: number;
  26389. bufferHeight: number;
  26390. alphaFilter: number;
  26391. }): VertexData;
  26392. /**
  26393. * Creates the VertexData for a Plane
  26394. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26395. * * size sets the width and height of the plane to the value of size, optional default 1
  26396. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26397. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26399. * * 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)
  26400. * * 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)
  26401. * @returns the VertexData of the box
  26402. */
  26403. static CreatePlane(options: {
  26404. size?: number;
  26405. width?: number;
  26406. height?: number;
  26407. sideOrientation?: number;
  26408. frontUVs?: Vector4;
  26409. backUVs?: Vector4;
  26410. }): VertexData;
  26411. /**
  26412. * Creates the VertexData of the Disc or regular Polygon
  26413. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26414. * * radius the radius of the disc, optional default 0.5
  26415. * * tessellation the number of polygon sides, optional, default 64
  26416. * * 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
  26417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26418. * * 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)
  26419. * * 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)
  26420. * @returns the VertexData of the box
  26421. */
  26422. static CreateDisc(options: {
  26423. radius?: number;
  26424. tessellation?: number;
  26425. arc?: number;
  26426. sideOrientation?: number;
  26427. frontUVs?: Vector4;
  26428. backUVs?: Vector4;
  26429. }): VertexData;
  26430. /**
  26431. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26432. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26433. * @param polygon a mesh built from polygonTriangulation.build()
  26434. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26435. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26436. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26437. * @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)
  26438. * @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)
  26439. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26440. * @returns the VertexData of the Polygon
  26441. */
  26442. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26443. /**
  26444. * Creates the VertexData of the IcoSphere
  26445. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26446. * * radius the radius of the IcoSphere, optional default 1
  26447. * * radiusX allows stretching in the x direction, optional, default radius
  26448. * * radiusY allows stretching in the y direction, optional, default radius
  26449. * * radiusZ allows stretching in the z direction, optional, default radius
  26450. * * flat when true creates a flat shaded mesh, optional, default true
  26451. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26453. * * 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)
  26454. * * 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)
  26455. * @returns the VertexData of the IcoSphere
  26456. */
  26457. static CreateIcoSphere(options: {
  26458. radius?: number;
  26459. radiusX?: number;
  26460. radiusY?: number;
  26461. radiusZ?: number;
  26462. flat?: boolean;
  26463. subdivisions?: number;
  26464. sideOrientation?: number;
  26465. frontUVs?: Vector4;
  26466. backUVs?: Vector4;
  26467. }): VertexData;
  26468. /**
  26469. * Creates the VertexData for a Polyhedron
  26470. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26471. * * type provided types are:
  26472. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26473. * * 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)
  26474. * * size the size of the IcoSphere, optional default 1
  26475. * * sizeX allows stretching in the x direction, optional, default size
  26476. * * sizeY allows stretching in the y direction, optional, default size
  26477. * * sizeZ allows stretching in the z direction, optional, default size
  26478. * * 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
  26479. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26480. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26481. * * flat when true creates a flat shaded mesh, optional, default true
  26482. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26484. * * 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)
  26485. * * 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)
  26486. * @returns the VertexData of the Polyhedron
  26487. */
  26488. static CreatePolyhedron(options: {
  26489. type?: number;
  26490. size?: number;
  26491. sizeX?: number;
  26492. sizeY?: number;
  26493. sizeZ?: number;
  26494. custom?: any;
  26495. faceUV?: Vector4[];
  26496. faceColors?: Color4[];
  26497. flat?: boolean;
  26498. sideOrientation?: number;
  26499. frontUVs?: Vector4;
  26500. backUVs?: Vector4;
  26501. }): VertexData;
  26502. /**
  26503. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  26504. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  26505. * @returns the VertexData of the Capsule
  26506. */
  26507. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  26508. /**
  26509. * Creates the VertexData for a TorusKnot
  26510. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26511. * * radius the radius of the torus knot, optional, default 2
  26512. * * tube the thickness of the tube, optional, default 0.5
  26513. * * radialSegments the number of sides on each tube segments, optional, default 32
  26514. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26515. * * p the number of windings around the z axis, optional, default 2
  26516. * * q the number of windings around the x axis, optional, default 3
  26517. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26518. * * 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)
  26519. * * 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)
  26520. * @returns the VertexData of the Torus Knot
  26521. */
  26522. static CreateTorusKnot(options: {
  26523. radius?: number;
  26524. tube?: number;
  26525. radialSegments?: number;
  26526. tubularSegments?: number;
  26527. p?: number;
  26528. q?: number;
  26529. sideOrientation?: number;
  26530. frontUVs?: Vector4;
  26531. backUVs?: Vector4;
  26532. }): VertexData;
  26533. /**
  26534. * Compute normals for given positions and indices
  26535. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26536. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26537. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26538. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26539. * * facetNormals : optional array of facet normals (vector3)
  26540. * * facetPositions : optional array of facet positions (vector3)
  26541. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26542. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26543. * * bInfo : optional bounding info, required for facetPartitioning computation
  26544. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26545. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26546. * * useRightHandedSystem: optional boolean to for right handed system computation
  26547. * * depthSort : optional boolean to enable the facet depth sort computation
  26548. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26549. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26550. */
  26551. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26552. facetNormals?: any;
  26553. facetPositions?: any;
  26554. facetPartitioning?: any;
  26555. ratio?: number;
  26556. bInfo?: any;
  26557. bbSize?: Vector3;
  26558. subDiv?: any;
  26559. useRightHandedSystem?: boolean;
  26560. depthSort?: boolean;
  26561. distanceTo?: Vector3;
  26562. depthSortedFacets?: any;
  26563. }): void;
  26564. /** @hidden */
  26565. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26566. /**
  26567. * Applies VertexData created from the imported parameters to the geometry
  26568. * @param parsedVertexData the parsed data from an imported file
  26569. * @param geometry the geometry to apply the VertexData to
  26570. */
  26571. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26572. }
  26573. }
  26574. declare module BABYLON {
  26575. /**
  26576. * Defines a target to use with MorphTargetManager
  26577. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26578. */
  26579. export class MorphTarget implements IAnimatable {
  26580. /** defines the name of the target */
  26581. name: string;
  26582. /**
  26583. * Gets or sets the list of animations
  26584. */
  26585. animations: Animation[];
  26586. private _scene;
  26587. private _positions;
  26588. private _normals;
  26589. private _tangents;
  26590. private _uvs;
  26591. private _influence;
  26592. private _uniqueId;
  26593. /**
  26594. * Observable raised when the influence changes
  26595. */
  26596. onInfluenceChanged: Observable<boolean>;
  26597. /** @hidden */
  26598. _onDataLayoutChanged: Observable<void>;
  26599. /**
  26600. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26601. */
  26602. get influence(): number;
  26603. set influence(influence: number);
  26604. /**
  26605. * Gets or sets the id of the morph Target
  26606. */
  26607. id: string;
  26608. private _animationPropertiesOverride;
  26609. /**
  26610. * Gets or sets the animation properties override
  26611. */
  26612. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26613. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26614. /**
  26615. * Creates a new MorphTarget
  26616. * @param name defines the name of the target
  26617. * @param influence defines the influence to use
  26618. * @param scene defines the scene the morphtarget belongs to
  26619. */
  26620. constructor(
  26621. /** defines the name of the target */
  26622. name: string, influence?: number, scene?: Nullable<Scene>);
  26623. /**
  26624. * Gets the unique ID of this manager
  26625. */
  26626. get uniqueId(): number;
  26627. /**
  26628. * Gets a boolean defining if the target contains position data
  26629. */
  26630. get hasPositions(): boolean;
  26631. /**
  26632. * Gets a boolean defining if the target contains normal data
  26633. */
  26634. get hasNormals(): boolean;
  26635. /**
  26636. * Gets a boolean defining if the target contains tangent data
  26637. */
  26638. get hasTangents(): boolean;
  26639. /**
  26640. * Gets a boolean defining if the target contains texture coordinates data
  26641. */
  26642. get hasUVs(): boolean;
  26643. /**
  26644. * Affects position data to this target
  26645. * @param data defines the position data to use
  26646. */
  26647. setPositions(data: Nullable<FloatArray>): void;
  26648. /**
  26649. * Gets the position data stored in this target
  26650. * @returns a FloatArray containing the position data (or null if not present)
  26651. */
  26652. getPositions(): Nullable<FloatArray>;
  26653. /**
  26654. * Affects normal data to this target
  26655. * @param data defines the normal data to use
  26656. */
  26657. setNormals(data: Nullable<FloatArray>): void;
  26658. /**
  26659. * Gets the normal data stored in this target
  26660. * @returns a FloatArray containing the normal data (or null if not present)
  26661. */
  26662. getNormals(): Nullable<FloatArray>;
  26663. /**
  26664. * Affects tangent data to this target
  26665. * @param data defines the tangent data to use
  26666. */
  26667. setTangents(data: Nullable<FloatArray>): void;
  26668. /**
  26669. * Gets the tangent data stored in this target
  26670. * @returns a FloatArray containing the tangent data (or null if not present)
  26671. */
  26672. getTangents(): Nullable<FloatArray>;
  26673. /**
  26674. * Affects texture coordinates data to this target
  26675. * @param data defines the texture coordinates data to use
  26676. */
  26677. setUVs(data: Nullable<FloatArray>): void;
  26678. /**
  26679. * Gets the texture coordinates data stored in this target
  26680. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26681. */
  26682. getUVs(): Nullable<FloatArray>;
  26683. /**
  26684. * Clone the current target
  26685. * @returns a new MorphTarget
  26686. */
  26687. clone(): MorphTarget;
  26688. /**
  26689. * Serializes the current target into a Serialization object
  26690. * @returns the serialized object
  26691. */
  26692. serialize(): any;
  26693. /**
  26694. * Returns the string "MorphTarget"
  26695. * @returns "MorphTarget"
  26696. */
  26697. getClassName(): string;
  26698. /**
  26699. * Creates a new target from serialized data
  26700. * @param serializationObject defines the serialized data to use
  26701. * @returns a new MorphTarget
  26702. */
  26703. static Parse(serializationObject: any): MorphTarget;
  26704. /**
  26705. * Creates a MorphTarget from mesh data
  26706. * @param mesh defines the source mesh
  26707. * @param name defines the name to use for the new target
  26708. * @param influence defines the influence to attach to the target
  26709. * @returns a new MorphTarget
  26710. */
  26711. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26712. }
  26713. }
  26714. declare module BABYLON {
  26715. /**
  26716. * This class is used to deform meshes using morphing between different targets
  26717. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26718. */
  26719. export class MorphTargetManager {
  26720. private _targets;
  26721. private _targetInfluenceChangedObservers;
  26722. private _targetDataLayoutChangedObservers;
  26723. private _activeTargets;
  26724. private _scene;
  26725. private _influences;
  26726. private _supportsNormals;
  26727. private _supportsTangents;
  26728. private _supportsUVs;
  26729. private _vertexCount;
  26730. private _uniqueId;
  26731. private _tempInfluences;
  26732. /**
  26733. * Gets or sets a boolean indicating if normals must be morphed
  26734. */
  26735. enableNormalMorphing: boolean;
  26736. /**
  26737. * Gets or sets a boolean indicating if tangents must be morphed
  26738. */
  26739. enableTangentMorphing: boolean;
  26740. /**
  26741. * Gets or sets a boolean indicating if UV must be morphed
  26742. */
  26743. enableUVMorphing: boolean;
  26744. /**
  26745. * Creates a new MorphTargetManager
  26746. * @param scene defines the current scene
  26747. */
  26748. constructor(scene?: Nullable<Scene>);
  26749. /**
  26750. * Gets the unique ID of this manager
  26751. */
  26752. get uniqueId(): number;
  26753. /**
  26754. * Gets the number of vertices handled by this manager
  26755. */
  26756. get vertexCount(): number;
  26757. /**
  26758. * Gets a boolean indicating if this manager supports morphing of normals
  26759. */
  26760. get supportsNormals(): boolean;
  26761. /**
  26762. * Gets a boolean indicating if this manager supports morphing of tangents
  26763. */
  26764. get supportsTangents(): boolean;
  26765. /**
  26766. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26767. */
  26768. get supportsUVs(): boolean;
  26769. /**
  26770. * Gets the number of targets stored in this manager
  26771. */
  26772. get numTargets(): number;
  26773. /**
  26774. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26775. */
  26776. get numInfluencers(): number;
  26777. /**
  26778. * Gets the list of influences (one per target)
  26779. */
  26780. get influences(): Float32Array;
  26781. /**
  26782. * Gets the active target at specified index. An active target is a target with an influence > 0
  26783. * @param index defines the index to check
  26784. * @returns the requested target
  26785. */
  26786. getActiveTarget(index: number): MorphTarget;
  26787. /**
  26788. * Gets the target at specified index
  26789. * @param index defines the index to check
  26790. * @returns the requested target
  26791. */
  26792. getTarget(index: number): MorphTarget;
  26793. /**
  26794. * Add a new target to this manager
  26795. * @param target defines the target to add
  26796. */
  26797. addTarget(target: MorphTarget): void;
  26798. /**
  26799. * Removes a target from the manager
  26800. * @param target defines the target to remove
  26801. */
  26802. removeTarget(target: MorphTarget): void;
  26803. /**
  26804. * Clone the current manager
  26805. * @returns a new MorphTargetManager
  26806. */
  26807. clone(): MorphTargetManager;
  26808. /**
  26809. * Serializes the current manager into a Serialization object
  26810. * @returns the serialized object
  26811. */
  26812. serialize(): any;
  26813. private _syncActiveTargets;
  26814. /**
  26815. * Syncrhonize the targets with all the meshes using this morph target manager
  26816. */
  26817. synchronize(): void;
  26818. /**
  26819. * Creates a new MorphTargetManager from serialized data
  26820. * @param serializationObject defines the serialized data
  26821. * @param scene defines the hosting scene
  26822. * @returns the new MorphTargetManager
  26823. */
  26824. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26825. }
  26826. }
  26827. declare module BABYLON {
  26828. /**
  26829. * Class used to represent a specific level of detail of a mesh
  26830. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26831. */
  26832. export class MeshLODLevel {
  26833. /** Defines the distance where this level should start being displayed */
  26834. distance: number;
  26835. /** Defines the mesh to use to render this level */
  26836. mesh: Nullable<Mesh>;
  26837. /**
  26838. * Creates a new LOD level
  26839. * @param distance defines the distance where this level should star being displayed
  26840. * @param mesh defines the mesh to use to render this level
  26841. */
  26842. constructor(
  26843. /** Defines the distance where this level should start being displayed */
  26844. distance: number,
  26845. /** Defines the mesh to use to render this level */
  26846. mesh: Nullable<Mesh>);
  26847. }
  26848. }
  26849. declare module BABYLON {
  26850. /**
  26851. * Helper class used to generate a canvas to manipulate images
  26852. */
  26853. export class CanvasGenerator {
  26854. /**
  26855. * Create a new canvas (or offscreen canvas depending on the context)
  26856. * @param width defines the expected width
  26857. * @param height defines the expected height
  26858. * @return a new canvas or offscreen canvas
  26859. */
  26860. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26861. }
  26862. }
  26863. declare module BABYLON {
  26864. /**
  26865. * Mesh representing the gorund
  26866. */
  26867. export class GroundMesh extends Mesh {
  26868. /** If octree should be generated */
  26869. generateOctree: boolean;
  26870. private _heightQuads;
  26871. /** @hidden */
  26872. _subdivisionsX: number;
  26873. /** @hidden */
  26874. _subdivisionsY: number;
  26875. /** @hidden */
  26876. _width: number;
  26877. /** @hidden */
  26878. _height: number;
  26879. /** @hidden */
  26880. _minX: number;
  26881. /** @hidden */
  26882. _maxX: number;
  26883. /** @hidden */
  26884. _minZ: number;
  26885. /** @hidden */
  26886. _maxZ: number;
  26887. constructor(name: string, scene: Scene);
  26888. /**
  26889. * "GroundMesh"
  26890. * @returns "GroundMesh"
  26891. */
  26892. getClassName(): string;
  26893. /**
  26894. * The minimum of x and y subdivisions
  26895. */
  26896. get subdivisions(): number;
  26897. /**
  26898. * X subdivisions
  26899. */
  26900. get subdivisionsX(): number;
  26901. /**
  26902. * Y subdivisions
  26903. */
  26904. get subdivisionsY(): number;
  26905. /**
  26906. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26907. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26908. * @param chunksCount the number of subdivisions for x and y
  26909. * @param octreeBlocksSize (Default: 32)
  26910. */
  26911. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26912. /**
  26913. * Returns a height (y) value in the Worl system :
  26914. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26915. * @param x x coordinate
  26916. * @param z z coordinate
  26917. * @returns the ground y position if (x, z) are outside the ground surface.
  26918. */
  26919. getHeightAtCoordinates(x: number, z: number): number;
  26920. /**
  26921. * Returns a normalized vector (Vector3) orthogonal to the ground
  26922. * at the ground coordinates (x, z) expressed in the World system.
  26923. * @param x x coordinate
  26924. * @param z z coordinate
  26925. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26926. */
  26927. getNormalAtCoordinates(x: number, z: number): Vector3;
  26928. /**
  26929. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26930. * at the ground coordinates (x, z) expressed in the World system.
  26931. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26932. * @param x x coordinate
  26933. * @param z z coordinate
  26934. * @param ref vector to store the result
  26935. * @returns the GroundMesh.
  26936. */
  26937. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26938. /**
  26939. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26940. * if the ground has been updated.
  26941. * This can be used in the render loop.
  26942. * @returns the GroundMesh.
  26943. */
  26944. updateCoordinateHeights(): GroundMesh;
  26945. private _getFacetAt;
  26946. private _initHeightQuads;
  26947. private _computeHeightQuads;
  26948. /**
  26949. * Serializes this ground mesh
  26950. * @param serializationObject object to write serialization to
  26951. */
  26952. serialize(serializationObject: any): void;
  26953. /**
  26954. * Parses a serialized ground mesh
  26955. * @param parsedMesh the serialized mesh
  26956. * @param scene the scene to create the ground mesh in
  26957. * @returns the created ground mesh
  26958. */
  26959. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26960. }
  26961. }
  26962. declare module BABYLON {
  26963. /**
  26964. * Interface for Physics-Joint data
  26965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26966. */
  26967. export interface PhysicsJointData {
  26968. /**
  26969. * The main pivot of the joint
  26970. */
  26971. mainPivot?: Vector3;
  26972. /**
  26973. * The connected pivot of the joint
  26974. */
  26975. connectedPivot?: Vector3;
  26976. /**
  26977. * The main axis of the joint
  26978. */
  26979. mainAxis?: Vector3;
  26980. /**
  26981. * The connected axis of the joint
  26982. */
  26983. connectedAxis?: Vector3;
  26984. /**
  26985. * The collision of the joint
  26986. */
  26987. collision?: boolean;
  26988. /**
  26989. * Native Oimo/Cannon/Energy data
  26990. */
  26991. nativeParams?: any;
  26992. }
  26993. /**
  26994. * This is a holder class for the physics joint created by the physics plugin
  26995. * It holds a set of functions to control the underlying joint
  26996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26997. */
  26998. export class PhysicsJoint {
  26999. /**
  27000. * The type of the physics joint
  27001. */
  27002. type: number;
  27003. /**
  27004. * The data for the physics joint
  27005. */
  27006. jointData: PhysicsJointData;
  27007. private _physicsJoint;
  27008. protected _physicsPlugin: IPhysicsEnginePlugin;
  27009. /**
  27010. * Initializes the physics joint
  27011. * @param type The type of the physics joint
  27012. * @param jointData The data for the physics joint
  27013. */
  27014. constructor(
  27015. /**
  27016. * The type of the physics joint
  27017. */
  27018. type: number,
  27019. /**
  27020. * The data for the physics joint
  27021. */
  27022. jointData: PhysicsJointData);
  27023. /**
  27024. * Gets the physics joint
  27025. */
  27026. get physicsJoint(): any;
  27027. /**
  27028. * Sets the physics joint
  27029. */
  27030. set physicsJoint(newJoint: any);
  27031. /**
  27032. * Sets the physics plugin
  27033. */
  27034. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27035. /**
  27036. * Execute a function that is physics-plugin specific.
  27037. * @param {Function} func the function that will be executed.
  27038. * It accepts two parameters: the physics world and the physics joint
  27039. */
  27040. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27041. /**
  27042. * Distance-Joint type
  27043. */
  27044. static DistanceJoint: number;
  27045. /**
  27046. * Hinge-Joint type
  27047. */
  27048. static HingeJoint: number;
  27049. /**
  27050. * Ball-and-Socket joint type
  27051. */
  27052. static BallAndSocketJoint: number;
  27053. /**
  27054. * Wheel-Joint type
  27055. */
  27056. static WheelJoint: number;
  27057. /**
  27058. * Slider-Joint type
  27059. */
  27060. static SliderJoint: number;
  27061. /**
  27062. * Prismatic-Joint type
  27063. */
  27064. static PrismaticJoint: number;
  27065. /**
  27066. * Universal-Joint type
  27067. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27068. */
  27069. static UniversalJoint: number;
  27070. /**
  27071. * Hinge-Joint 2 type
  27072. */
  27073. static Hinge2Joint: number;
  27074. /**
  27075. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27076. */
  27077. static PointToPointJoint: number;
  27078. /**
  27079. * Spring-Joint type
  27080. */
  27081. static SpringJoint: number;
  27082. /**
  27083. * Lock-Joint type
  27084. */
  27085. static LockJoint: number;
  27086. }
  27087. /**
  27088. * A class representing a physics distance joint
  27089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27090. */
  27091. export class DistanceJoint extends PhysicsJoint {
  27092. /**
  27093. *
  27094. * @param jointData The data for the Distance-Joint
  27095. */
  27096. constructor(jointData: DistanceJointData);
  27097. /**
  27098. * Update the predefined distance.
  27099. * @param maxDistance The maximum preferred distance
  27100. * @param minDistance The minimum preferred distance
  27101. */
  27102. updateDistance(maxDistance: number, minDistance?: number): void;
  27103. }
  27104. /**
  27105. * Represents a Motor-Enabled Joint
  27106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27107. */
  27108. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27109. /**
  27110. * Initializes the Motor-Enabled Joint
  27111. * @param type The type of the joint
  27112. * @param jointData The physica joint data for the joint
  27113. */
  27114. constructor(type: number, jointData: PhysicsJointData);
  27115. /**
  27116. * Set the motor values.
  27117. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27118. * @param force the force to apply
  27119. * @param maxForce max force for this motor.
  27120. */
  27121. setMotor(force?: number, maxForce?: number): void;
  27122. /**
  27123. * Set the motor's limits.
  27124. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27125. * @param upperLimit The upper limit of the motor
  27126. * @param lowerLimit The lower limit of the motor
  27127. */
  27128. setLimit(upperLimit: number, lowerLimit?: number): void;
  27129. }
  27130. /**
  27131. * This class represents a single physics Hinge-Joint
  27132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27133. */
  27134. export class HingeJoint extends MotorEnabledJoint {
  27135. /**
  27136. * Initializes the Hinge-Joint
  27137. * @param jointData The joint data for the Hinge-Joint
  27138. */
  27139. constructor(jointData: PhysicsJointData);
  27140. /**
  27141. * Set the motor values.
  27142. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27143. * @param {number} force the force to apply
  27144. * @param {number} maxForce max force for this motor.
  27145. */
  27146. setMotor(force?: number, maxForce?: number): void;
  27147. /**
  27148. * Set the motor's limits.
  27149. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27150. * @param upperLimit The upper limit of the motor
  27151. * @param lowerLimit The lower limit of the motor
  27152. */
  27153. setLimit(upperLimit: number, lowerLimit?: number): void;
  27154. }
  27155. /**
  27156. * This class represents a dual hinge physics joint (same as wheel joint)
  27157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27158. */
  27159. export class Hinge2Joint extends MotorEnabledJoint {
  27160. /**
  27161. * Initializes the Hinge2-Joint
  27162. * @param jointData The joint data for the Hinge2-Joint
  27163. */
  27164. constructor(jointData: PhysicsJointData);
  27165. /**
  27166. * Set the motor values.
  27167. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27168. * @param {number} targetSpeed the speed the motor is to reach
  27169. * @param {number} maxForce max force for this motor.
  27170. * @param {motorIndex} the motor's index, 0 or 1.
  27171. */
  27172. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27173. /**
  27174. * Set the motor limits.
  27175. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27176. * @param {number} upperLimit the upper limit
  27177. * @param {number} lowerLimit lower limit
  27178. * @param {motorIndex} the motor's index, 0 or 1.
  27179. */
  27180. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27181. }
  27182. /**
  27183. * Interface for a motor enabled joint
  27184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27185. */
  27186. export interface IMotorEnabledJoint {
  27187. /**
  27188. * Physics joint
  27189. */
  27190. physicsJoint: any;
  27191. /**
  27192. * Sets the motor of the motor-enabled joint
  27193. * @param force The force of the motor
  27194. * @param maxForce The maximum force of the motor
  27195. * @param motorIndex The index of the motor
  27196. */
  27197. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27198. /**
  27199. * Sets the limit of the motor
  27200. * @param upperLimit The upper limit of the motor
  27201. * @param lowerLimit The lower limit of the motor
  27202. * @param motorIndex The index of the motor
  27203. */
  27204. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27205. }
  27206. /**
  27207. * Joint data for a Distance-Joint
  27208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27209. */
  27210. export interface DistanceJointData extends PhysicsJointData {
  27211. /**
  27212. * Max distance the 2 joint objects can be apart
  27213. */
  27214. maxDistance: number;
  27215. }
  27216. /**
  27217. * Joint data from a spring joint
  27218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27219. */
  27220. export interface SpringJointData extends PhysicsJointData {
  27221. /**
  27222. * Length of the spring
  27223. */
  27224. length: number;
  27225. /**
  27226. * Stiffness of the spring
  27227. */
  27228. stiffness: number;
  27229. /**
  27230. * Damping of the spring
  27231. */
  27232. damping: number;
  27233. /** this callback will be called when applying the force to the impostors. */
  27234. forceApplicationCallback: () => void;
  27235. }
  27236. }
  27237. declare module BABYLON {
  27238. /**
  27239. * Holds the data for the raycast result
  27240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27241. */
  27242. export class PhysicsRaycastResult {
  27243. private _hasHit;
  27244. private _hitDistance;
  27245. private _hitNormalWorld;
  27246. private _hitPointWorld;
  27247. private _rayFromWorld;
  27248. private _rayToWorld;
  27249. /**
  27250. * Gets if there was a hit
  27251. */
  27252. get hasHit(): boolean;
  27253. /**
  27254. * Gets the distance from the hit
  27255. */
  27256. get hitDistance(): number;
  27257. /**
  27258. * Gets the hit normal/direction in the world
  27259. */
  27260. get hitNormalWorld(): Vector3;
  27261. /**
  27262. * Gets the hit point in the world
  27263. */
  27264. get hitPointWorld(): Vector3;
  27265. /**
  27266. * Gets the ray "start point" of the ray in the world
  27267. */
  27268. get rayFromWorld(): Vector3;
  27269. /**
  27270. * Gets the ray "end point" of the ray in the world
  27271. */
  27272. get rayToWorld(): Vector3;
  27273. /**
  27274. * Sets the hit data (normal & point in world space)
  27275. * @param hitNormalWorld defines the normal in world space
  27276. * @param hitPointWorld defines the point in world space
  27277. */
  27278. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27279. /**
  27280. * Sets the distance from the start point to the hit point
  27281. * @param distance
  27282. */
  27283. setHitDistance(distance: number): void;
  27284. /**
  27285. * Calculates the distance manually
  27286. */
  27287. calculateHitDistance(): void;
  27288. /**
  27289. * Resets all the values to default
  27290. * @param from The from point on world space
  27291. * @param to The to point on world space
  27292. */
  27293. reset(from?: Vector3, to?: Vector3): void;
  27294. }
  27295. /**
  27296. * Interface for the size containing width and height
  27297. */
  27298. interface IXYZ {
  27299. /**
  27300. * X
  27301. */
  27302. x: number;
  27303. /**
  27304. * Y
  27305. */
  27306. y: number;
  27307. /**
  27308. * Z
  27309. */
  27310. z: number;
  27311. }
  27312. }
  27313. declare module BABYLON {
  27314. /**
  27315. * Interface used to describe a physics joint
  27316. */
  27317. export interface PhysicsImpostorJoint {
  27318. /** Defines the main impostor to which the joint is linked */
  27319. mainImpostor: PhysicsImpostor;
  27320. /** Defines the impostor that is connected to the main impostor using this joint */
  27321. connectedImpostor: PhysicsImpostor;
  27322. /** Defines the joint itself */
  27323. joint: PhysicsJoint;
  27324. }
  27325. /** @hidden */
  27326. export interface IPhysicsEnginePlugin {
  27327. world: any;
  27328. name: string;
  27329. setGravity(gravity: Vector3): void;
  27330. setTimeStep(timeStep: number): void;
  27331. getTimeStep(): number;
  27332. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27333. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27334. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27335. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27336. removePhysicsBody(impostor: PhysicsImpostor): void;
  27337. generateJoint(joint: PhysicsImpostorJoint): void;
  27338. removeJoint(joint: PhysicsImpostorJoint): void;
  27339. isSupported(): boolean;
  27340. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27341. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27342. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27343. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27344. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27345. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27346. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27347. getBodyMass(impostor: PhysicsImpostor): number;
  27348. getBodyFriction(impostor: PhysicsImpostor): number;
  27349. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27350. getBodyRestitution(impostor: PhysicsImpostor): number;
  27351. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27352. getBodyPressure?(impostor: PhysicsImpostor): number;
  27353. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27354. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27355. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27356. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27357. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27358. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27359. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27360. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27361. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27362. sleepBody(impostor: PhysicsImpostor): void;
  27363. wakeUpBody(impostor: PhysicsImpostor): void;
  27364. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27365. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27366. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27367. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27368. getRadius(impostor: PhysicsImpostor): number;
  27369. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27370. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27371. dispose(): void;
  27372. }
  27373. /**
  27374. * Interface used to define a physics engine
  27375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27376. */
  27377. export interface IPhysicsEngine {
  27378. /**
  27379. * Gets the gravity vector used by the simulation
  27380. */
  27381. gravity: Vector3;
  27382. /**
  27383. * Sets the gravity vector used by the simulation
  27384. * @param gravity defines the gravity vector to use
  27385. */
  27386. setGravity(gravity: Vector3): void;
  27387. /**
  27388. * Set the time step of the physics engine.
  27389. * Default is 1/60.
  27390. * To slow it down, enter 1/600 for example.
  27391. * To speed it up, 1/30
  27392. * @param newTimeStep the new timestep to apply to this world.
  27393. */
  27394. setTimeStep(newTimeStep: number): void;
  27395. /**
  27396. * Get the time step of the physics engine.
  27397. * @returns the current time step
  27398. */
  27399. getTimeStep(): number;
  27400. /**
  27401. * Set the sub time step of the physics engine.
  27402. * Default is 0 meaning there is no sub steps
  27403. * To increase physics resolution precision, set a small value (like 1 ms)
  27404. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27405. */
  27406. setSubTimeStep(subTimeStep: number): void;
  27407. /**
  27408. * Get the sub time step of the physics engine.
  27409. * @returns the current sub time step
  27410. */
  27411. getSubTimeStep(): number;
  27412. /**
  27413. * Release all resources
  27414. */
  27415. dispose(): void;
  27416. /**
  27417. * Gets the name of the current physics plugin
  27418. * @returns the name of the plugin
  27419. */
  27420. getPhysicsPluginName(): string;
  27421. /**
  27422. * Adding a new impostor for the impostor tracking.
  27423. * This will be done by the impostor itself.
  27424. * @param impostor the impostor to add
  27425. */
  27426. addImpostor(impostor: PhysicsImpostor): void;
  27427. /**
  27428. * Remove an impostor from the engine.
  27429. * This impostor and its mesh will not longer be updated by the physics engine.
  27430. * @param impostor the impostor to remove
  27431. */
  27432. removeImpostor(impostor: PhysicsImpostor): void;
  27433. /**
  27434. * Add a joint to the physics engine
  27435. * @param mainImpostor defines the main impostor to which the joint is added.
  27436. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27437. * @param joint defines the joint that will connect both impostors.
  27438. */
  27439. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27440. /**
  27441. * Removes a joint from the simulation
  27442. * @param mainImpostor defines the impostor used with the joint
  27443. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27444. * @param joint defines the joint to remove
  27445. */
  27446. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27447. /**
  27448. * Gets the current plugin used to run the simulation
  27449. * @returns current plugin
  27450. */
  27451. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27452. /**
  27453. * Gets the list of physic impostors
  27454. * @returns an array of PhysicsImpostor
  27455. */
  27456. getImpostors(): Array<PhysicsImpostor>;
  27457. /**
  27458. * Gets the impostor for a physics enabled object
  27459. * @param object defines the object impersonated by the impostor
  27460. * @returns the PhysicsImpostor or null if not found
  27461. */
  27462. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27463. /**
  27464. * Gets the impostor for a physics body object
  27465. * @param body defines physics body used by the impostor
  27466. * @returns the PhysicsImpostor or null if not found
  27467. */
  27468. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27469. /**
  27470. * Does a raycast in the physics world
  27471. * @param from when should the ray start?
  27472. * @param to when should the ray end?
  27473. * @returns PhysicsRaycastResult
  27474. */
  27475. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27476. /**
  27477. * Called by the scene. No need to call it.
  27478. * @param delta defines the timespam between frames
  27479. */
  27480. _step(delta: number): void;
  27481. }
  27482. }
  27483. declare module BABYLON {
  27484. /**
  27485. * The interface for the physics imposter parameters
  27486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27487. */
  27488. export interface PhysicsImpostorParameters {
  27489. /**
  27490. * The mass of the physics imposter
  27491. */
  27492. mass: number;
  27493. /**
  27494. * The friction of the physics imposter
  27495. */
  27496. friction?: number;
  27497. /**
  27498. * The coefficient of restitution of the physics imposter
  27499. */
  27500. restitution?: number;
  27501. /**
  27502. * The native options of the physics imposter
  27503. */
  27504. nativeOptions?: any;
  27505. /**
  27506. * Specifies if the parent should be ignored
  27507. */
  27508. ignoreParent?: boolean;
  27509. /**
  27510. * Specifies if bi-directional transformations should be disabled
  27511. */
  27512. disableBidirectionalTransformation?: boolean;
  27513. /**
  27514. * The pressure inside the physics imposter, soft object only
  27515. */
  27516. pressure?: number;
  27517. /**
  27518. * The stiffness the physics imposter, soft object only
  27519. */
  27520. stiffness?: number;
  27521. /**
  27522. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27523. */
  27524. velocityIterations?: number;
  27525. /**
  27526. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27527. */
  27528. positionIterations?: number;
  27529. /**
  27530. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27531. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27532. * Add to fix multiple points
  27533. */
  27534. fixedPoints?: number;
  27535. /**
  27536. * The collision margin around a soft object
  27537. */
  27538. margin?: number;
  27539. /**
  27540. * The collision margin around a soft object
  27541. */
  27542. damping?: number;
  27543. /**
  27544. * The path for a rope based on an extrusion
  27545. */
  27546. path?: any;
  27547. /**
  27548. * The shape of an extrusion used for a rope based on an extrusion
  27549. */
  27550. shape?: any;
  27551. }
  27552. /**
  27553. * Interface for a physics-enabled object
  27554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27555. */
  27556. export interface IPhysicsEnabledObject {
  27557. /**
  27558. * The position of the physics-enabled object
  27559. */
  27560. position: Vector3;
  27561. /**
  27562. * The rotation of the physics-enabled object
  27563. */
  27564. rotationQuaternion: Nullable<Quaternion>;
  27565. /**
  27566. * The scale of the physics-enabled object
  27567. */
  27568. scaling: Vector3;
  27569. /**
  27570. * The rotation of the physics-enabled object
  27571. */
  27572. rotation?: Vector3;
  27573. /**
  27574. * The parent of the physics-enabled object
  27575. */
  27576. parent?: any;
  27577. /**
  27578. * The bounding info of the physics-enabled object
  27579. * @returns The bounding info of the physics-enabled object
  27580. */
  27581. getBoundingInfo(): BoundingInfo;
  27582. /**
  27583. * Computes the world matrix
  27584. * @param force Specifies if the world matrix should be computed by force
  27585. * @returns A world matrix
  27586. */
  27587. computeWorldMatrix(force: boolean): Matrix;
  27588. /**
  27589. * Gets the world matrix
  27590. * @returns A world matrix
  27591. */
  27592. getWorldMatrix?(): Matrix;
  27593. /**
  27594. * Gets the child meshes
  27595. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27596. * @returns An array of abstract meshes
  27597. */
  27598. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27599. /**
  27600. * Gets the vertex data
  27601. * @param kind The type of vertex data
  27602. * @returns A nullable array of numbers, or a float32 array
  27603. */
  27604. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27605. /**
  27606. * Gets the indices from the mesh
  27607. * @returns A nullable array of index arrays
  27608. */
  27609. getIndices?(): Nullable<IndicesArray>;
  27610. /**
  27611. * Gets the scene from the mesh
  27612. * @returns the indices array or null
  27613. */
  27614. getScene?(): Scene;
  27615. /**
  27616. * Gets the absolute position from the mesh
  27617. * @returns the absolute position
  27618. */
  27619. getAbsolutePosition(): Vector3;
  27620. /**
  27621. * Gets the absolute pivot point from the mesh
  27622. * @returns the absolute pivot point
  27623. */
  27624. getAbsolutePivotPoint(): Vector3;
  27625. /**
  27626. * Rotates the mesh
  27627. * @param axis The axis of rotation
  27628. * @param amount The amount of rotation
  27629. * @param space The space of the rotation
  27630. * @returns The rotation transform node
  27631. */
  27632. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27633. /**
  27634. * Translates the mesh
  27635. * @param axis The axis of translation
  27636. * @param distance The distance of translation
  27637. * @param space The space of the translation
  27638. * @returns The transform node
  27639. */
  27640. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27641. /**
  27642. * Sets the absolute position of the mesh
  27643. * @param absolutePosition The absolute position of the mesh
  27644. * @returns The transform node
  27645. */
  27646. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27647. /**
  27648. * Gets the class name of the mesh
  27649. * @returns The class name
  27650. */
  27651. getClassName(): string;
  27652. }
  27653. /**
  27654. * Represents a physics imposter
  27655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27656. */
  27657. export class PhysicsImpostor {
  27658. /**
  27659. * The physics-enabled object used as the physics imposter
  27660. */
  27661. object: IPhysicsEnabledObject;
  27662. /**
  27663. * The type of the physics imposter
  27664. */
  27665. type: number;
  27666. private _options;
  27667. private _scene?;
  27668. /**
  27669. * The default object size of the imposter
  27670. */
  27671. static DEFAULT_OBJECT_SIZE: Vector3;
  27672. /**
  27673. * The identity quaternion of the imposter
  27674. */
  27675. static IDENTITY_QUATERNION: Quaternion;
  27676. /** @hidden */
  27677. _pluginData: any;
  27678. private _physicsEngine;
  27679. private _physicsBody;
  27680. private _bodyUpdateRequired;
  27681. private _onBeforePhysicsStepCallbacks;
  27682. private _onAfterPhysicsStepCallbacks;
  27683. /** @hidden */
  27684. _onPhysicsCollideCallbacks: Array<{
  27685. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27686. otherImpostors: Array<PhysicsImpostor>;
  27687. }>;
  27688. private _deltaPosition;
  27689. private _deltaRotation;
  27690. private _deltaRotationConjugated;
  27691. /** @hidden */
  27692. _isFromLine: boolean;
  27693. private _parent;
  27694. private _isDisposed;
  27695. private static _tmpVecs;
  27696. private static _tmpQuat;
  27697. /**
  27698. * Specifies if the physics imposter is disposed
  27699. */
  27700. get isDisposed(): boolean;
  27701. /**
  27702. * Gets the mass of the physics imposter
  27703. */
  27704. get mass(): number;
  27705. set mass(value: number);
  27706. /**
  27707. * Gets the coefficient of friction
  27708. */
  27709. get friction(): number;
  27710. /**
  27711. * Sets the coefficient of friction
  27712. */
  27713. set friction(value: number);
  27714. /**
  27715. * Gets the coefficient of restitution
  27716. */
  27717. get restitution(): number;
  27718. /**
  27719. * Sets the coefficient of restitution
  27720. */
  27721. set restitution(value: number);
  27722. /**
  27723. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27724. */
  27725. get pressure(): number;
  27726. /**
  27727. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27728. */
  27729. set pressure(value: number);
  27730. /**
  27731. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27732. */
  27733. get stiffness(): number;
  27734. /**
  27735. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27736. */
  27737. set stiffness(value: number);
  27738. /**
  27739. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27740. */
  27741. get velocityIterations(): number;
  27742. /**
  27743. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27744. */
  27745. set velocityIterations(value: number);
  27746. /**
  27747. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27748. */
  27749. get positionIterations(): number;
  27750. /**
  27751. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27752. */
  27753. set positionIterations(value: number);
  27754. /**
  27755. * The unique id of the physics imposter
  27756. * set by the physics engine when adding this impostor to the array
  27757. */
  27758. uniqueId: number;
  27759. /**
  27760. * @hidden
  27761. */
  27762. soft: boolean;
  27763. /**
  27764. * @hidden
  27765. */
  27766. segments: number;
  27767. private _joints;
  27768. /**
  27769. * Initializes the physics imposter
  27770. * @param object The physics-enabled object used as the physics imposter
  27771. * @param type The type of the physics imposter
  27772. * @param _options The options for the physics imposter
  27773. * @param _scene The Babylon scene
  27774. */
  27775. constructor(
  27776. /**
  27777. * The physics-enabled object used as the physics imposter
  27778. */
  27779. object: IPhysicsEnabledObject,
  27780. /**
  27781. * The type of the physics imposter
  27782. */
  27783. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27784. /**
  27785. * This function will completly initialize this impostor.
  27786. * It will create a new body - but only if this mesh has no parent.
  27787. * If it has, this impostor will not be used other than to define the impostor
  27788. * of the child mesh.
  27789. * @hidden
  27790. */
  27791. _init(): void;
  27792. private _getPhysicsParent;
  27793. /**
  27794. * Should a new body be generated.
  27795. * @returns boolean specifying if body initialization is required
  27796. */
  27797. isBodyInitRequired(): boolean;
  27798. /**
  27799. * Sets the updated scaling
  27800. * @param updated Specifies if the scaling is updated
  27801. */
  27802. setScalingUpdated(): void;
  27803. /**
  27804. * Force a regeneration of this or the parent's impostor's body.
  27805. * Use under cautious - This will remove all joints already implemented.
  27806. */
  27807. forceUpdate(): void;
  27808. /**
  27809. * Gets the body that holds this impostor. Either its own, or its parent.
  27810. */
  27811. get physicsBody(): any;
  27812. /**
  27813. * Get the parent of the physics imposter
  27814. * @returns Physics imposter or null
  27815. */
  27816. get parent(): Nullable<PhysicsImpostor>;
  27817. /**
  27818. * Sets the parent of the physics imposter
  27819. */
  27820. set parent(value: Nullable<PhysicsImpostor>);
  27821. /**
  27822. * Set the physics body. Used mainly by the physics engine/plugin
  27823. */
  27824. set physicsBody(physicsBody: any);
  27825. /**
  27826. * Resets the update flags
  27827. */
  27828. resetUpdateFlags(): void;
  27829. /**
  27830. * Gets the object extend size
  27831. * @returns the object extend size
  27832. */
  27833. getObjectExtendSize(): Vector3;
  27834. /**
  27835. * Gets the object center
  27836. * @returns The object center
  27837. */
  27838. getObjectCenter(): Vector3;
  27839. /**
  27840. * Get a specific parameter from the options parameters
  27841. * @param paramName The object parameter name
  27842. * @returns The object parameter
  27843. */
  27844. getParam(paramName: string): any;
  27845. /**
  27846. * Sets a specific parameter in the options given to the physics plugin
  27847. * @param paramName The parameter name
  27848. * @param value The value of the parameter
  27849. */
  27850. setParam(paramName: string, value: number): void;
  27851. /**
  27852. * Specifically change the body's mass option. Won't recreate the physics body object
  27853. * @param mass The mass of the physics imposter
  27854. */
  27855. setMass(mass: number): void;
  27856. /**
  27857. * Gets the linear velocity
  27858. * @returns linear velocity or null
  27859. */
  27860. getLinearVelocity(): Nullable<Vector3>;
  27861. /**
  27862. * Sets the linear velocity
  27863. * @param velocity linear velocity or null
  27864. */
  27865. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27866. /**
  27867. * Gets the angular velocity
  27868. * @returns angular velocity or null
  27869. */
  27870. getAngularVelocity(): Nullable<Vector3>;
  27871. /**
  27872. * Sets the angular velocity
  27873. * @param velocity The velocity or null
  27874. */
  27875. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27876. /**
  27877. * Execute a function with the physics plugin native code
  27878. * Provide a function the will have two variables - the world object and the physics body object
  27879. * @param func The function to execute with the physics plugin native code
  27880. */
  27881. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27882. /**
  27883. * Register a function that will be executed before the physics world is stepping forward
  27884. * @param func The function to execute before the physics world is stepped forward
  27885. */
  27886. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27887. /**
  27888. * Unregister a function that will be executed before the physics world is stepping forward
  27889. * @param func The function to execute before the physics world is stepped forward
  27890. */
  27891. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27892. /**
  27893. * Register a function that will be executed after the physics step
  27894. * @param func The function to execute after physics step
  27895. */
  27896. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27897. /**
  27898. * Unregisters a function that will be executed after the physics step
  27899. * @param func The function to execute after physics step
  27900. */
  27901. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27902. /**
  27903. * register a function that will be executed when this impostor collides against a different body
  27904. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27905. * @param func Callback that is executed on collision
  27906. */
  27907. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27908. /**
  27909. * Unregisters the physics imposter on contact
  27910. * @param collideAgainst The physics object to collide against
  27911. * @param func Callback to execute on collision
  27912. */
  27913. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27914. private _tmpQuat;
  27915. private _tmpQuat2;
  27916. /**
  27917. * Get the parent rotation
  27918. * @returns The parent rotation
  27919. */
  27920. getParentsRotation(): Quaternion;
  27921. /**
  27922. * this function is executed by the physics engine.
  27923. */
  27924. beforeStep: () => void;
  27925. /**
  27926. * this function is executed by the physics engine
  27927. */
  27928. afterStep: () => void;
  27929. /**
  27930. * Legacy collision detection event support
  27931. */
  27932. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27933. /**
  27934. * event and body object due to cannon's event-based architecture.
  27935. */
  27936. onCollide: (e: {
  27937. body: any;
  27938. }) => void;
  27939. /**
  27940. * Apply a force
  27941. * @param force The force to apply
  27942. * @param contactPoint The contact point for the force
  27943. * @returns The physics imposter
  27944. */
  27945. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27946. /**
  27947. * Apply an impulse
  27948. * @param force The impulse force
  27949. * @param contactPoint The contact point for the impulse force
  27950. * @returns The physics imposter
  27951. */
  27952. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27953. /**
  27954. * A help function to create a joint
  27955. * @param otherImpostor A physics imposter used to create a joint
  27956. * @param jointType The type of joint
  27957. * @param jointData The data for the joint
  27958. * @returns The physics imposter
  27959. */
  27960. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27961. /**
  27962. * Add a joint to this impostor with a different impostor
  27963. * @param otherImpostor A physics imposter used to add a joint
  27964. * @param joint The joint to add
  27965. * @returns The physics imposter
  27966. */
  27967. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27968. /**
  27969. * Add an anchor to a cloth impostor
  27970. * @param otherImpostor rigid impostor to anchor to
  27971. * @param width ratio across width from 0 to 1
  27972. * @param height ratio up height from 0 to 1
  27973. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27974. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27975. * @returns impostor the soft imposter
  27976. */
  27977. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27978. /**
  27979. * Add a hook to a rope impostor
  27980. * @param otherImpostor rigid impostor to anchor to
  27981. * @param length ratio across rope from 0 to 1
  27982. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27983. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27984. * @returns impostor the rope imposter
  27985. */
  27986. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27987. /**
  27988. * Will keep this body still, in a sleep mode.
  27989. * @returns the physics imposter
  27990. */
  27991. sleep(): PhysicsImpostor;
  27992. /**
  27993. * Wake the body up.
  27994. * @returns The physics imposter
  27995. */
  27996. wakeUp(): PhysicsImpostor;
  27997. /**
  27998. * Clones the physics imposter
  27999. * @param newObject The physics imposter clones to this physics-enabled object
  28000. * @returns A nullable physics imposter
  28001. */
  28002. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28003. /**
  28004. * Disposes the physics imposter
  28005. */
  28006. dispose(): void;
  28007. /**
  28008. * Sets the delta position
  28009. * @param position The delta position amount
  28010. */
  28011. setDeltaPosition(position: Vector3): void;
  28012. /**
  28013. * Sets the delta rotation
  28014. * @param rotation The delta rotation amount
  28015. */
  28016. setDeltaRotation(rotation: Quaternion): void;
  28017. /**
  28018. * Gets the box size of the physics imposter and stores the result in the input parameter
  28019. * @param result Stores the box size
  28020. * @returns The physics imposter
  28021. */
  28022. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28023. /**
  28024. * Gets the radius of the physics imposter
  28025. * @returns Radius of the physics imposter
  28026. */
  28027. getRadius(): number;
  28028. /**
  28029. * Sync a bone with this impostor
  28030. * @param bone The bone to sync to the impostor.
  28031. * @param boneMesh The mesh that the bone is influencing.
  28032. * @param jointPivot The pivot of the joint / bone in local space.
  28033. * @param distToJoint Optional distance from the impostor to the joint.
  28034. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28035. */
  28036. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28037. /**
  28038. * Sync impostor to a bone
  28039. * @param bone The bone that the impostor will be synced to.
  28040. * @param boneMesh The mesh that the bone is influencing.
  28041. * @param jointPivot The pivot of the joint / bone in local space.
  28042. * @param distToJoint Optional distance from the impostor to the joint.
  28043. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28044. * @param boneAxis Optional vector3 axis the bone is aligned with
  28045. */
  28046. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28047. /**
  28048. * No-Imposter type
  28049. */
  28050. static NoImpostor: number;
  28051. /**
  28052. * Sphere-Imposter type
  28053. */
  28054. static SphereImpostor: number;
  28055. /**
  28056. * Box-Imposter type
  28057. */
  28058. static BoxImpostor: number;
  28059. /**
  28060. * Plane-Imposter type
  28061. */
  28062. static PlaneImpostor: number;
  28063. /**
  28064. * Mesh-imposter type
  28065. */
  28066. static MeshImpostor: number;
  28067. /**
  28068. * Capsule-Impostor type (Ammo.js plugin only)
  28069. */
  28070. static CapsuleImpostor: number;
  28071. /**
  28072. * Cylinder-Imposter type
  28073. */
  28074. static CylinderImpostor: number;
  28075. /**
  28076. * Particle-Imposter type
  28077. */
  28078. static ParticleImpostor: number;
  28079. /**
  28080. * Heightmap-Imposter type
  28081. */
  28082. static HeightmapImpostor: number;
  28083. /**
  28084. * ConvexHull-Impostor type (Ammo.js plugin only)
  28085. */
  28086. static ConvexHullImpostor: number;
  28087. /**
  28088. * Custom-Imposter type (Ammo.js plugin only)
  28089. */
  28090. static CustomImpostor: number;
  28091. /**
  28092. * Rope-Imposter type
  28093. */
  28094. static RopeImpostor: number;
  28095. /**
  28096. * Cloth-Imposter type
  28097. */
  28098. static ClothImpostor: number;
  28099. /**
  28100. * Softbody-Imposter type
  28101. */
  28102. static SoftbodyImpostor: number;
  28103. }
  28104. }
  28105. declare module BABYLON {
  28106. /**
  28107. * @hidden
  28108. **/
  28109. export class _CreationDataStorage {
  28110. closePath?: boolean;
  28111. closeArray?: boolean;
  28112. idx: number[];
  28113. dashSize: number;
  28114. gapSize: number;
  28115. path3D: Path3D;
  28116. pathArray: Vector3[][];
  28117. arc: number;
  28118. radius: number;
  28119. cap: number;
  28120. tessellation: number;
  28121. }
  28122. /**
  28123. * @hidden
  28124. **/
  28125. class _InstanceDataStorage {
  28126. visibleInstances: any;
  28127. batchCache: _InstancesBatch;
  28128. instancesBufferSize: number;
  28129. instancesBuffer: Nullable<Buffer>;
  28130. instancesData: Float32Array;
  28131. overridenInstanceCount: number;
  28132. isFrozen: boolean;
  28133. previousBatch: Nullable<_InstancesBatch>;
  28134. hardwareInstancedRendering: boolean;
  28135. sideOrientation: number;
  28136. manualUpdate: boolean;
  28137. previousRenderId: number;
  28138. }
  28139. /**
  28140. * @hidden
  28141. **/
  28142. export class _InstancesBatch {
  28143. mustReturn: boolean;
  28144. visibleInstances: Nullable<InstancedMesh[]>[];
  28145. renderSelf: boolean[];
  28146. hardwareInstancedRendering: boolean[];
  28147. }
  28148. /**
  28149. * @hidden
  28150. **/
  28151. class _ThinInstanceDataStorage {
  28152. instancesCount: number;
  28153. matrixBuffer: Nullable<Buffer>;
  28154. matrixBufferSize: number;
  28155. matrixData: Nullable<Float32Array>;
  28156. boundingVectors: Array<Vector3>;
  28157. worldMatrices: Nullable<Matrix[]>;
  28158. }
  28159. /**
  28160. * Class used to represent renderable models
  28161. */
  28162. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28163. /**
  28164. * Mesh side orientation : usually the external or front surface
  28165. */
  28166. static readonly FRONTSIDE: number;
  28167. /**
  28168. * Mesh side orientation : usually the internal or back surface
  28169. */
  28170. static readonly BACKSIDE: number;
  28171. /**
  28172. * Mesh side orientation : both internal and external or front and back surfaces
  28173. */
  28174. static readonly DOUBLESIDE: number;
  28175. /**
  28176. * Mesh side orientation : by default, `FRONTSIDE`
  28177. */
  28178. static readonly DEFAULTSIDE: number;
  28179. /**
  28180. * Mesh cap setting : no cap
  28181. */
  28182. static readonly NO_CAP: number;
  28183. /**
  28184. * Mesh cap setting : one cap at the beginning of the mesh
  28185. */
  28186. static readonly CAP_START: number;
  28187. /**
  28188. * Mesh cap setting : one cap at the end of the mesh
  28189. */
  28190. static readonly CAP_END: number;
  28191. /**
  28192. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28193. */
  28194. static readonly CAP_ALL: number;
  28195. /**
  28196. * Mesh pattern setting : no flip or rotate
  28197. */
  28198. static readonly NO_FLIP: number;
  28199. /**
  28200. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28201. */
  28202. static readonly FLIP_TILE: number;
  28203. /**
  28204. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28205. */
  28206. static readonly ROTATE_TILE: number;
  28207. /**
  28208. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28209. */
  28210. static readonly FLIP_ROW: number;
  28211. /**
  28212. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28213. */
  28214. static readonly ROTATE_ROW: number;
  28215. /**
  28216. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28217. */
  28218. static readonly FLIP_N_ROTATE_TILE: number;
  28219. /**
  28220. * Mesh pattern setting : rotate pattern and rotate
  28221. */
  28222. static readonly FLIP_N_ROTATE_ROW: number;
  28223. /**
  28224. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28225. */
  28226. static readonly CENTER: number;
  28227. /**
  28228. * Mesh tile positioning : part tiles on left
  28229. */
  28230. static readonly LEFT: number;
  28231. /**
  28232. * Mesh tile positioning : part tiles on right
  28233. */
  28234. static readonly RIGHT: number;
  28235. /**
  28236. * Mesh tile positioning : part tiles on top
  28237. */
  28238. static readonly TOP: number;
  28239. /**
  28240. * Mesh tile positioning : part tiles on bottom
  28241. */
  28242. static readonly BOTTOM: number;
  28243. /**
  28244. * Gets the default side orientation.
  28245. * @param orientation the orientation to value to attempt to get
  28246. * @returns the default orientation
  28247. * @hidden
  28248. */
  28249. static _GetDefaultSideOrientation(orientation?: number): number;
  28250. private _internalMeshDataInfo;
  28251. get computeBonesUsingShaders(): boolean;
  28252. set computeBonesUsingShaders(value: boolean);
  28253. /**
  28254. * An event triggered before rendering the mesh
  28255. */
  28256. get onBeforeRenderObservable(): Observable<Mesh>;
  28257. /**
  28258. * An event triggered before binding the mesh
  28259. */
  28260. get onBeforeBindObservable(): Observable<Mesh>;
  28261. /**
  28262. * An event triggered after rendering the mesh
  28263. */
  28264. get onAfterRenderObservable(): Observable<Mesh>;
  28265. /**
  28266. * An event triggered before drawing the mesh
  28267. */
  28268. get onBeforeDrawObservable(): Observable<Mesh>;
  28269. private _onBeforeDrawObserver;
  28270. /**
  28271. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28272. */
  28273. set onBeforeDraw(callback: () => void);
  28274. get hasInstances(): boolean;
  28275. get hasThinInstances(): boolean;
  28276. /**
  28277. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28278. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28279. */
  28280. delayLoadState: number;
  28281. /**
  28282. * Gets the list of instances created from this mesh
  28283. * it is not supposed to be modified manually.
  28284. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28285. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28286. */
  28287. instances: InstancedMesh[];
  28288. /**
  28289. * Gets the file containing delay loading data for this mesh
  28290. */
  28291. delayLoadingFile: string;
  28292. /** @hidden */
  28293. _binaryInfo: any;
  28294. /**
  28295. * User defined function used to change how LOD level selection is done
  28296. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28297. */
  28298. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28299. /**
  28300. * Gets or sets the morph target manager
  28301. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28302. */
  28303. get morphTargetManager(): Nullable<MorphTargetManager>;
  28304. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28305. /** @hidden */
  28306. _creationDataStorage: Nullable<_CreationDataStorage>;
  28307. /** @hidden */
  28308. _geometry: Nullable<Geometry>;
  28309. /** @hidden */
  28310. _delayInfo: Array<string>;
  28311. /** @hidden */
  28312. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28313. /** @hidden */
  28314. _instanceDataStorage: _InstanceDataStorage;
  28315. /** @hidden */
  28316. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28317. private _effectiveMaterial;
  28318. /** @hidden */
  28319. _shouldGenerateFlatShading: boolean;
  28320. /** @hidden */
  28321. _originalBuilderSideOrientation: number;
  28322. /**
  28323. * Use this property to change the original side orientation defined at construction time
  28324. */
  28325. overrideMaterialSideOrientation: Nullable<number>;
  28326. /**
  28327. * Gets the source mesh (the one used to clone this one from)
  28328. */
  28329. get source(): Nullable<Mesh>;
  28330. /**
  28331. * Gets the list of clones of this mesh
  28332. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28333. * Note that useClonedMeshMap=true is the default setting
  28334. */
  28335. get cloneMeshMap(): Nullable<{
  28336. [id: string]: Mesh | undefined;
  28337. }>;
  28338. /**
  28339. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28340. */
  28341. get isUnIndexed(): boolean;
  28342. set isUnIndexed(value: boolean);
  28343. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28344. get worldMatrixInstancedBuffer(): Float32Array;
  28345. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28346. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28347. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28348. /**
  28349. * @constructor
  28350. * @param name The value used by scene.getMeshByName() to do a lookup.
  28351. * @param scene The scene to add this mesh to.
  28352. * @param parent The parent of this mesh, if it has one
  28353. * @param source An optional Mesh from which geometry is shared, cloned.
  28354. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28355. * When false, achieved by calling a clone(), also passing False.
  28356. * This will make creation of children, recursive.
  28357. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28358. */
  28359. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28360. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28361. doNotInstantiate: boolean;
  28362. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28363. /**
  28364. * Gets the class name
  28365. * @returns the string "Mesh".
  28366. */
  28367. getClassName(): string;
  28368. /** @hidden */
  28369. get _isMesh(): boolean;
  28370. /**
  28371. * Returns a description of this mesh
  28372. * @param fullDetails define if full details about this mesh must be used
  28373. * @returns a descriptive string representing this mesh
  28374. */
  28375. toString(fullDetails?: boolean): string;
  28376. /** @hidden */
  28377. _unBindEffect(): void;
  28378. /**
  28379. * Gets a boolean indicating if this mesh has LOD
  28380. */
  28381. get hasLODLevels(): boolean;
  28382. /**
  28383. * Gets the list of MeshLODLevel associated with the current mesh
  28384. * @returns an array of MeshLODLevel
  28385. */
  28386. getLODLevels(): MeshLODLevel[];
  28387. private _sortLODLevels;
  28388. /**
  28389. * Add a mesh as LOD level triggered at the given distance.
  28390. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28391. * @param distance The distance from the center of the object to show this level
  28392. * @param mesh The mesh to be added as LOD level (can be null)
  28393. * @return This mesh (for chaining)
  28394. */
  28395. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28396. /**
  28397. * Returns the LOD level mesh at the passed distance or null if not found.
  28398. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28399. * @param distance The distance from the center of the object to show this level
  28400. * @returns a Mesh or `null`
  28401. */
  28402. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28403. /**
  28404. * Remove a mesh from the LOD array
  28405. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28406. * @param mesh defines the mesh to be removed
  28407. * @return This mesh (for chaining)
  28408. */
  28409. removeLODLevel(mesh: Mesh): Mesh;
  28410. /**
  28411. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28412. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28413. * @param camera defines the camera to use to compute distance
  28414. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28415. * @return This mesh (for chaining)
  28416. */
  28417. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28418. /**
  28419. * Gets the mesh internal Geometry object
  28420. */
  28421. get geometry(): Nullable<Geometry>;
  28422. /**
  28423. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28424. * @returns the total number of vertices
  28425. */
  28426. getTotalVertices(): number;
  28427. /**
  28428. * Returns the content of an associated vertex buffer
  28429. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28430. * - VertexBuffer.PositionKind
  28431. * - VertexBuffer.UVKind
  28432. * - VertexBuffer.UV2Kind
  28433. * - VertexBuffer.UV3Kind
  28434. * - VertexBuffer.UV4Kind
  28435. * - VertexBuffer.UV5Kind
  28436. * - VertexBuffer.UV6Kind
  28437. * - VertexBuffer.ColorKind
  28438. * - VertexBuffer.MatricesIndicesKind
  28439. * - VertexBuffer.MatricesIndicesExtraKind
  28440. * - VertexBuffer.MatricesWeightsKind
  28441. * - VertexBuffer.MatricesWeightsExtraKind
  28442. * @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
  28443. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28444. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28445. */
  28446. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28447. /**
  28448. * Returns the mesh VertexBuffer object from the requested `kind`
  28449. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28450. * - VertexBuffer.PositionKind
  28451. * - VertexBuffer.NormalKind
  28452. * - VertexBuffer.UVKind
  28453. * - VertexBuffer.UV2Kind
  28454. * - VertexBuffer.UV3Kind
  28455. * - VertexBuffer.UV4Kind
  28456. * - VertexBuffer.UV5Kind
  28457. * - VertexBuffer.UV6Kind
  28458. * - VertexBuffer.ColorKind
  28459. * - VertexBuffer.MatricesIndicesKind
  28460. * - VertexBuffer.MatricesIndicesExtraKind
  28461. * - VertexBuffer.MatricesWeightsKind
  28462. * - VertexBuffer.MatricesWeightsExtraKind
  28463. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28464. */
  28465. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28466. /**
  28467. * Tests if a specific vertex buffer is associated with this mesh
  28468. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28469. * - VertexBuffer.PositionKind
  28470. * - VertexBuffer.NormalKind
  28471. * - VertexBuffer.UVKind
  28472. * - VertexBuffer.UV2Kind
  28473. * - VertexBuffer.UV3Kind
  28474. * - VertexBuffer.UV4Kind
  28475. * - VertexBuffer.UV5Kind
  28476. * - VertexBuffer.UV6Kind
  28477. * - VertexBuffer.ColorKind
  28478. * - VertexBuffer.MatricesIndicesKind
  28479. * - VertexBuffer.MatricesIndicesExtraKind
  28480. * - VertexBuffer.MatricesWeightsKind
  28481. * - VertexBuffer.MatricesWeightsExtraKind
  28482. * @returns a boolean
  28483. */
  28484. isVerticesDataPresent(kind: string): boolean;
  28485. /**
  28486. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28487. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28488. * - VertexBuffer.PositionKind
  28489. * - VertexBuffer.UVKind
  28490. * - VertexBuffer.UV2Kind
  28491. * - VertexBuffer.UV3Kind
  28492. * - VertexBuffer.UV4Kind
  28493. * - VertexBuffer.UV5Kind
  28494. * - VertexBuffer.UV6Kind
  28495. * - VertexBuffer.ColorKind
  28496. * - VertexBuffer.MatricesIndicesKind
  28497. * - VertexBuffer.MatricesIndicesExtraKind
  28498. * - VertexBuffer.MatricesWeightsKind
  28499. * - VertexBuffer.MatricesWeightsExtraKind
  28500. * @returns a boolean
  28501. */
  28502. isVertexBufferUpdatable(kind: string): boolean;
  28503. /**
  28504. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28505. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28506. * - VertexBuffer.PositionKind
  28507. * - VertexBuffer.NormalKind
  28508. * - VertexBuffer.UVKind
  28509. * - VertexBuffer.UV2Kind
  28510. * - VertexBuffer.UV3Kind
  28511. * - VertexBuffer.UV4Kind
  28512. * - VertexBuffer.UV5Kind
  28513. * - VertexBuffer.UV6Kind
  28514. * - VertexBuffer.ColorKind
  28515. * - VertexBuffer.MatricesIndicesKind
  28516. * - VertexBuffer.MatricesIndicesExtraKind
  28517. * - VertexBuffer.MatricesWeightsKind
  28518. * - VertexBuffer.MatricesWeightsExtraKind
  28519. * @returns an array of strings
  28520. */
  28521. getVerticesDataKinds(): string[];
  28522. /**
  28523. * Returns a positive integer : the total number of indices in this mesh geometry.
  28524. * @returns the numner of indices or zero if the mesh has no geometry.
  28525. */
  28526. getTotalIndices(): number;
  28527. /**
  28528. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28529. * @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.
  28530. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28531. * @returns the indices array or an empty array if the mesh has no geometry
  28532. */
  28533. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28534. get isBlocked(): boolean;
  28535. /**
  28536. * Determine if the current mesh is ready to be rendered
  28537. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28538. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28539. * @returns true if all associated assets are ready (material, textures, shaders)
  28540. */
  28541. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28542. /**
  28543. * 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.
  28544. */
  28545. get areNormalsFrozen(): boolean;
  28546. /**
  28547. * 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.
  28548. * @returns the current mesh
  28549. */
  28550. freezeNormals(): Mesh;
  28551. /**
  28552. * 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
  28553. * @returns the current mesh
  28554. */
  28555. unfreezeNormals(): Mesh;
  28556. /**
  28557. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28558. */
  28559. set overridenInstanceCount(count: number);
  28560. /** @hidden */
  28561. _preActivate(): Mesh;
  28562. /** @hidden */
  28563. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28564. /** @hidden */
  28565. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28566. protected _afterComputeWorldMatrix(): void;
  28567. /** @hidden */
  28568. _postActivate(): void;
  28569. /**
  28570. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28571. * This means the mesh underlying bounding box and sphere are recomputed.
  28572. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28573. * @returns the current mesh
  28574. */
  28575. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28576. /** @hidden */
  28577. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28578. /**
  28579. * This function will subdivide the mesh into multiple submeshes
  28580. * @param count defines the expected number of submeshes
  28581. */
  28582. subdivide(count: number): void;
  28583. /**
  28584. * Copy a FloatArray into a specific associated vertex buffer
  28585. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28586. * - VertexBuffer.PositionKind
  28587. * - VertexBuffer.UVKind
  28588. * - VertexBuffer.UV2Kind
  28589. * - VertexBuffer.UV3Kind
  28590. * - VertexBuffer.UV4Kind
  28591. * - VertexBuffer.UV5Kind
  28592. * - VertexBuffer.UV6Kind
  28593. * - VertexBuffer.ColorKind
  28594. * - VertexBuffer.MatricesIndicesKind
  28595. * - VertexBuffer.MatricesIndicesExtraKind
  28596. * - VertexBuffer.MatricesWeightsKind
  28597. * - VertexBuffer.MatricesWeightsExtraKind
  28598. * @param data defines the data source
  28599. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28600. * @param stride defines the data stride size (can be null)
  28601. * @returns the current mesh
  28602. */
  28603. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28604. /**
  28605. * Delete a vertex buffer associated with this mesh
  28606. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28607. * - VertexBuffer.PositionKind
  28608. * - VertexBuffer.UVKind
  28609. * - VertexBuffer.UV2Kind
  28610. * - VertexBuffer.UV3Kind
  28611. * - VertexBuffer.UV4Kind
  28612. * - VertexBuffer.UV5Kind
  28613. * - VertexBuffer.UV6Kind
  28614. * - VertexBuffer.ColorKind
  28615. * - VertexBuffer.MatricesIndicesKind
  28616. * - VertexBuffer.MatricesIndicesExtraKind
  28617. * - VertexBuffer.MatricesWeightsKind
  28618. * - VertexBuffer.MatricesWeightsExtraKind
  28619. */
  28620. removeVerticesData(kind: string): void;
  28621. /**
  28622. * Flags an associated vertex buffer as updatable
  28623. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28624. * - VertexBuffer.PositionKind
  28625. * - VertexBuffer.UVKind
  28626. * - VertexBuffer.UV2Kind
  28627. * - VertexBuffer.UV3Kind
  28628. * - VertexBuffer.UV4Kind
  28629. * - VertexBuffer.UV5Kind
  28630. * - VertexBuffer.UV6Kind
  28631. * - VertexBuffer.ColorKind
  28632. * - VertexBuffer.MatricesIndicesKind
  28633. * - VertexBuffer.MatricesIndicesExtraKind
  28634. * - VertexBuffer.MatricesWeightsKind
  28635. * - VertexBuffer.MatricesWeightsExtraKind
  28636. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28637. */
  28638. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28639. /**
  28640. * Sets the mesh global Vertex Buffer
  28641. * @param buffer defines the buffer to use
  28642. * @returns the current mesh
  28643. */
  28644. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28645. /**
  28646. * Update a specific associated vertex buffer
  28647. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28648. * - VertexBuffer.PositionKind
  28649. * - VertexBuffer.UVKind
  28650. * - VertexBuffer.UV2Kind
  28651. * - VertexBuffer.UV3Kind
  28652. * - VertexBuffer.UV4Kind
  28653. * - VertexBuffer.UV5Kind
  28654. * - VertexBuffer.UV6Kind
  28655. * - VertexBuffer.ColorKind
  28656. * - VertexBuffer.MatricesIndicesKind
  28657. * - VertexBuffer.MatricesIndicesExtraKind
  28658. * - VertexBuffer.MatricesWeightsKind
  28659. * - VertexBuffer.MatricesWeightsExtraKind
  28660. * @param data defines the data source
  28661. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28662. * @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)
  28663. * @returns the current mesh
  28664. */
  28665. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28666. /**
  28667. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28668. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28669. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28670. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28671. * @returns the current mesh
  28672. */
  28673. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28674. /**
  28675. * Creates a un-shared specific occurence of the geometry for the mesh.
  28676. * @returns the current mesh
  28677. */
  28678. makeGeometryUnique(): Mesh;
  28679. /**
  28680. * Set the index buffer of this mesh
  28681. * @param indices defines the source data
  28682. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28683. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28684. * @returns the current mesh
  28685. */
  28686. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28687. /**
  28688. * Update the current index buffer
  28689. * @param indices defines the source data
  28690. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28691. * @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)
  28692. * @returns the current mesh
  28693. */
  28694. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28695. /**
  28696. * Invert the geometry to move from a right handed system to a left handed one.
  28697. * @returns the current mesh
  28698. */
  28699. toLeftHanded(): Mesh;
  28700. /** @hidden */
  28701. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28702. /** @hidden */
  28703. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28704. /**
  28705. * Registers for this mesh a javascript function called just before the rendering process
  28706. * @param func defines the function to call before rendering this mesh
  28707. * @returns the current mesh
  28708. */
  28709. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28710. /**
  28711. * Disposes a previously registered javascript function called before the rendering
  28712. * @param func defines the function to remove
  28713. * @returns the current mesh
  28714. */
  28715. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28716. /**
  28717. * Registers for this mesh a javascript function called just after the rendering is complete
  28718. * @param func defines the function to call after rendering this mesh
  28719. * @returns the current mesh
  28720. */
  28721. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28722. /**
  28723. * Disposes a previously registered javascript function called after the rendering.
  28724. * @param func defines the function to remove
  28725. * @returns the current mesh
  28726. */
  28727. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28728. /** @hidden */
  28729. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28730. /** @hidden */
  28731. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28732. /** @hidden */
  28733. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28734. /** @hidden */
  28735. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28736. /** @hidden */
  28737. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28738. /** @hidden */
  28739. _rebuild(): void;
  28740. /** @hidden */
  28741. _freeze(): void;
  28742. /** @hidden */
  28743. _unFreeze(): void;
  28744. /**
  28745. * 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
  28746. * @param subMesh defines the subMesh to render
  28747. * @param enableAlphaMode defines if alpha mode can be changed
  28748. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28749. * @returns the current mesh
  28750. */
  28751. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28752. private _onBeforeDraw;
  28753. /**
  28754. * Renormalize the mesh and patch it up if there are no weights
  28755. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28756. * However in the case of zero weights then we set just a single influence to 1.
  28757. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28758. */
  28759. cleanMatrixWeights(): void;
  28760. private normalizeSkinFourWeights;
  28761. private normalizeSkinWeightsAndExtra;
  28762. /**
  28763. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28764. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28765. * the user know there was an issue with importing the mesh
  28766. * @returns a validation object with skinned, valid and report string
  28767. */
  28768. validateSkinning(): {
  28769. skinned: boolean;
  28770. valid: boolean;
  28771. report: string;
  28772. };
  28773. /** @hidden */
  28774. _checkDelayState(): Mesh;
  28775. private _queueLoad;
  28776. /**
  28777. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28778. * A mesh is in the frustum if its bounding box intersects the frustum
  28779. * @param frustumPlanes defines the frustum to test
  28780. * @returns true if the mesh is in the frustum planes
  28781. */
  28782. isInFrustum(frustumPlanes: Plane[]): boolean;
  28783. /**
  28784. * Sets the mesh material by the material or multiMaterial `id` property
  28785. * @param id is a string identifying the material or the multiMaterial
  28786. * @returns the current mesh
  28787. */
  28788. setMaterialByID(id: string): Mesh;
  28789. /**
  28790. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28791. * @returns an array of IAnimatable
  28792. */
  28793. getAnimatables(): IAnimatable[];
  28794. /**
  28795. * Modifies the mesh geometry according to the passed transformation matrix.
  28796. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28797. * The mesh normals are modified using the same transformation.
  28798. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28799. * @param transform defines the transform matrix to use
  28800. * @see https://doc.babylonjs.com/resources/baking_transformations
  28801. * @returns the current mesh
  28802. */
  28803. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28804. /**
  28805. * Modifies the mesh geometry according to its own current World Matrix.
  28806. * The mesh World Matrix is then reset.
  28807. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28808. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28809. * @see https://doc.babylonjs.com/resources/baking_transformations
  28810. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28811. * @returns the current mesh
  28812. */
  28813. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28814. /** @hidden */
  28815. get _positions(): Nullable<Vector3[]>;
  28816. /** @hidden */
  28817. _resetPointsArrayCache(): Mesh;
  28818. /** @hidden */
  28819. _generatePointsArray(): boolean;
  28820. /**
  28821. * Returns a new Mesh object generated from the current mesh properties.
  28822. * This method must not get confused with createInstance()
  28823. * @param name is a string, the name given to the new mesh
  28824. * @param newParent can be any Node object (default `null`)
  28825. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28826. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28827. * @returns a new mesh
  28828. */
  28829. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28830. /**
  28831. * Releases resources associated with this mesh.
  28832. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28833. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28834. */
  28835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28836. /** @hidden */
  28837. _disposeInstanceSpecificData(): void;
  28838. /** @hidden */
  28839. _disposeThinInstanceSpecificData(): void;
  28840. /**
  28841. * Modifies the mesh geometry according to a displacement map.
  28842. * 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.
  28843. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28844. * @param url is a string, the URL from the image file is to be downloaded.
  28845. * @param minHeight is the lower limit of the displacement.
  28846. * @param maxHeight is the upper limit of the displacement.
  28847. * @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.
  28848. * @param uvOffset is an optional vector2 used to offset UV.
  28849. * @param uvScale is an optional vector2 used to scale UV.
  28850. * @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.
  28851. * @returns the Mesh.
  28852. */
  28853. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28854. /**
  28855. * Modifies the mesh geometry according to a displacementMap buffer.
  28856. * 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.
  28857. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28858. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28859. * @param heightMapWidth is the width of the buffer image.
  28860. * @param heightMapHeight is the height of the buffer image.
  28861. * @param minHeight is the lower limit of the displacement.
  28862. * @param maxHeight is the upper limit of the displacement.
  28863. * @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.
  28864. * @param uvOffset is an optional vector2 used to offset UV.
  28865. * @param uvScale is an optional vector2 used to scale UV.
  28866. * @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.
  28867. * @returns the Mesh.
  28868. */
  28869. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28870. /**
  28871. * Modify the mesh to get a flat shading rendering.
  28872. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28873. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28874. * @returns current mesh
  28875. */
  28876. convertToFlatShadedMesh(): Mesh;
  28877. /**
  28878. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28879. * In other words, more vertices, no more indices and a single bigger VBO.
  28880. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28881. * @returns current mesh
  28882. */
  28883. convertToUnIndexedMesh(): Mesh;
  28884. /**
  28885. * Inverses facet orientations.
  28886. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28887. * @param flipNormals will also inverts the normals
  28888. * @returns current mesh
  28889. */
  28890. flipFaces(flipNormals?: boolean): Mesh;
  28891. /**
  28892. * Increase the number of facets and hence vertices in a mesh
  28893. * Vertex normals are interpolated from existing vertex normals
  28894. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28895. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28896. */
  28897. increaseVertices(numberPerEdge: number): void;
  28898. /**
  28899. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28900. * This will undo any application of covertToFlatShadedMesh
  28901. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28902. */
  28903. forceSharedVertices(): void;
  28904. /** @hidden */
  28905. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28906. /** @hidden */
  28907. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28908. /**
  28909. * Creates a new InstancedMesh object from the mesh model.
  28910. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28911. * @param name defines the name of the new instance
  28912. * @returns a new InstancedMesh
  28913. */
  28914. createInstance(name: string): InstancedMesh;
  28915. /**
  28916. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28917. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28918. * @returns the current mesh
  28919. */
  28920. synchronizeInstances(): Mesh;
  28921. /**
  28922. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28923. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28924. * This should be used together with the simplification to avoid disappearing triangles.
  28925. * @param successCallback an optional success callback to be called after the optimization finished.
  28926. * @returns the current mesh
  28927. */
  28928. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28929. /**
  28930. * Serialize current mesh
  28931. * @param serializationObject defines the object which will receive the serialization data
  28932. */
  28933. serialize(serializationObject: any): void;
  28934. /** @hidden */
  28935. _syncGeometryWithMorphTargetManager(): void;
  28936. /** @hidden */
  28937. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28938. /**
  28939. * Returns a new Mesh object parsed from the source provided.
  28940. * @param parsedMesh is the source
  28941. * @param scene defines the hosting scene
  28942. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28943. * @returns a new Mesh
  28944. */
  28945. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28946. /**
  28947. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28948. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28949. * @param name defines the name of the mesh to create
  28950. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28951. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28952. * @param closePath creates a seam between the first and the last points of each path of the path array
  28953. * @param offset is taken in account only if the `pathArray` is containing a single path
  28954. * @param scene defines the hosting scene
  28955. * @param updatable defines if the mesh must be flagged as updatable
  28956. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28957. * @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)
  28958. * @returns a new Mesh
  28959. */
  28960. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28961. /**
  28962. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28963. * @param name defines the name of the mesh to create
  28964. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28965. * @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
  28966. * @param scene defines the hosting scene
  28967. * @param updatable defines if the mesh must be flagged as updatable
  28968. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28969. * @returns a new Mesh
  28970. */
  28971. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28972. /**
  28973. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28974. * @param name defines the name of the mesh to create
  28975. * @param size sets the size (float) of each box side (default 1)
  28976. * @param scene defines the hosting scene
  28977. * @param updatable defines if the mesh must be flagged as updatable
  28978. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28979. * @returns a new Mesh
  28980. */
  28981. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28982. /**
  28983. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28984. * @param name defines the name of the mesh to create
  28985. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28986. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28987. * @param scene defines the hosting scene
  28988. * @param updatable defines if the mesh must be flagged as updatable
  28989. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28990. * @returns a new Mesh
  28991. */
  28992. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28993. /**
  28994. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28995. * @param name defines the name of the mesh to create
  28996. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28997. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28998. * @param scene defines the hosting scene
  28999. * @returns a new Mesh
  29000. */
  29001. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29002. /**
  29003. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29004. * @param name defines the name of the mesh to create
  29005. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29006. * @param diameterTop set the top cap diameter (floats, default 1)
  29007. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29008. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29009. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29010. * @param scene defines the hosting scene
  29011. * @param updatable defines if the mesh must be flagged as updatable
  29012. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29013. * @returns a new Mesh
  29014. */
  29015. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29016. /**
  29017. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29018. * @param name defines the name of the mesh to create
  29019. * @param diameter sets the diameter size (float) of the torus (default 1)
  29020. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29021. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29022. * @param scene defines the hosting scene
  29023. * @param updatable defines if the mesh must be flagged as updatable
  29024. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29025. * @returns a new Mesh
  29026. */
  29027. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29028. /**
  29029. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29030. * @param name defines the name of the mesh to create
  29031. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29032. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29033. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29034. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29035. * @param p the number of windings on X axis (positive integers, default 2)
  29036. * @param q the number of windings on Y axis (positive integers, default 3)
  29037. * @param scene defines the hosting scene
  29038. * @param updatable defines if the mesh must be flagged as updatable
  29039. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29040. * @returns a new Mesh
  29041. */
  29042. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29043. /**
  29044. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29045. * @param name defines the name of the mesh to create
  29046. * @param points is an array successive Vector3
  29047. * @param scene defines the hosting scene
  29048. * @param updatable defines if the mesh must be flagged as updatable
  29049. * @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).
  29050. * @returns a new Mesh
  29051. */
  29052. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29053. /**
  29054. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29055. * @param name defines the name of the mesh to create
  29056. * @param points is an array successive Vector3
  29057. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29058. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29059. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29060. * @param scene defines the hosting scene
  29061. * @param updatable defines if the mesh must be flagged as updatable
  29062. * @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)
  29063. * @returns a new Mesh
  29064. */
  29065. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29066. /**
  29067. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29068. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29069. * 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.
  29070. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29071. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29072. * Remember you can only change the shape positions, not their number when updating a polygon.
  29073. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29074. * @param name defines the name of the mesh to create
  29075. * @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
  29076. * @param scene defines the hosting scene
  29077. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29078. * @param updatable defines if the mesh must be flagged as updatable
  29079. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29080. * @param earcutInjection can be used to inject your own earcut reference
  29081. * @returns a new Mesh
  29082. */
  29083. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29084. /**
  29085. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29087. * @param name defines the name of the mesh to create
  29088. * @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
  29089. * @param depth defines the height of extrusion
  29090. * @param scene defines the hosting scene
  29091. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29092. * @param updatable defines if the mesh must be flagged as updatable
  29093. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29094. * @param earcutInjection can be used to inject your own earcut reference
  29095. * @returns a new Mesh
  29096. */
  29097. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29098. /**
  29099. * Creates an extruded shape mesh.
  29100. * 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
  29101. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29103. * @param name defines the name of the mesh to create
  29104. * @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
  29105. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29106. * @param scale is the value to scale the shape
  29107. * @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
  29108. * @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
  29109. * @param scene defines the hosting scene
  29110. * @param updatable defines if the mesh must be flagged as updatable
  29111. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29112. * @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)
  29113. * @returns a new Mesh
  29114. */
  29115. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29116. /**
  29117. * Creates an custom extruded shape mesh.
  29118. * The custom extrusion is a parametric shape.
  29119. * It has no predefined shape. Its final shape will depend on the input parameters.
  29120. * Please consider using the same method from the MeshBuilder class instead
  29121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29122. * @param name defines the name of the mesh to create
  29123. * @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
  29124. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29125. * @param scaleFunction is a custom Javascript function called on each path point
  29126. * @param rotationFunction is a custom Javascript function called on each path point
  29127. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29128. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29129. * @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
  29130. * @param scene defines the hosting scene
  29131. * @param updatable defines if the mesh must be flagged as updatable
  29132. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29133. * @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)
  29134. * @returns a new Mesh
  29135. */
  29136. 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;
  29137. /**
  29138. * Creates lathe mesh.
  29139. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29140. * Please consider using the same method from the MeshBuilder class instead
  29141. * @param name defines the name of the mesh to create
  29142. * @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
  29143. * @param radius is the radius value of the lathe
  29144. * @param tessellation is the side number of the lathe.
  29145. * @param scene defines the hosting scene
  29146. * @param updatable defines if the mesh must be flagged as updatable
  29147. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29148. * @returns a new Mesh
  29149. */
  29150. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29151. /**
  29152. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29153. * @param name defines the name of the mesh to create
  29154. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29155. * @param scene defines the hosting scene
  29156. * @param updatable defines if the mesh must be flagged as updatable
  29157. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29158. * @returns a new Mesh
  29159. */
  29160. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29161. /**
  29162. * Creates a ground mesh.
  29163. * Please consider using the same method from the MeshBuilder class instead
  29164. * @param name defines the name of the mesh to create
  29165. * @param width set the width of the ground
  29166. * @param height set the height of the ground
  29167. * @param subdivisions sets the number of subdivisions per side
  29168. * @param scene defines the hosting scene
  29169. * @param updatable defines if the mesh must be flagged as updatable
  29170. * @returns a new Mesh
  29171. */
  29172. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29173. /**
  29174. * Creates a tiled ground mesh.
  29175. * Please consider using the same method from the MeshBuilder class instead
  29176. * @param name defines the name of the mesh to create
  29177. * @param xmin set the ground minimum X coordinate
  29178. * @param zmin set the ground minimum Y coordinate
  29179. * @param xmax set the ground maximum X coordinate
  29180. * @param zmax set the ground maximum Z coordinate
  29181. * @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
  29182. * @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
  29183. * @param scene defines the hosting scene
  29184. * @param updatable defines if the mesh must be flagged as updatable
  29185. * @returns a new Mesh
  29186. */
  29187. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29188. w: number;
  29189. h: number;
  29190. }, precision: {
  29191. w: number;
  29192. h: number;
  29193. }, scene: Scene, updatable?: boolean): Mesh;
  29194. /**
  29195. * Creates a ground mesh from a height map.
  29196. * Please consider using the same method from the MeshBuilder class instead
  29197. * @see https://doc.babylonjs.com/babylon101/height_map
  29198. * @param name defines the name of the mesh to create
  29199. * @param url sets the URL of the height map image resource
  29200. * @param width set the ground width size
  29201. * @param height set the ground height size
  29202. * @param subdivisions sets the number of subdivision per side
  29203. * @param minHeight is the minimum altitude on the ground
  29204. * @param maxHeight is the maximum altitude on the ground
  29205. * @param scene defines the hosting scene
  29206. * @param updatable defines if the mesh must be flagged as updatable
  29207. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29208. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29209. * @returns a new Mesh
  29210. */
  29211. 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;
  29212. /**
  29213. * Creates a tube mesh.
  29214. * The tube is a parametric shape.
  29215. * It has no predefined shape. Its final shape will depend on the input parameters.
  29216. * Please consider using the same method from the MeshBuilder class instead
  29217. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29218. * @param name defines the name of the mesh to create
  29219. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29220. * @param radius sets the tube radius size
  29221. * @param tessellation is the number of sides on the tubular surface
  29222. * @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
  29223. * @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
  29224. * @param scene defines the hosting scene
  29225. * @param updatable defines if the mesh must be flagged as updatable
  29226. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29227. * @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)
  29228. * @returns a new Mesh
  29229. */
  29230. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29231. (i: number, distance: number): number;
  29232. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29233. /**
  29234. * Creates a polyhedron mesh.
  29235. * Please consider using the same method from the MeshBuilder class instead.
  29236. * * 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
  29237. * * The parameter `size` (positive float, default 1) sets the polygon size
  29238. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29239. * * 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`
  29240. * * 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
  29241. * * 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)`)
  29242. * * 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
  29243. * * 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
  29244. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29245. * * 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
  29246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29247. * @param name defines the name of the mesh to create
  29248. * @param options defines the options used to create the mesh
  29249. * @param scene defines the hosting scene
  29250. * @returns a new Mesh
  29251. */
  29252. static CreatePolyhedron(name: string, options: {
  29253. type?: number;
  29254. size?: number;
  29255. sizeX?: number;
  29256. sizeY?: number;
  29257. sizeZ?: number;
  29258. custom?: any;
  29259. faceUV?: Vector4[];
  29260. faceColors?: Color4[];
  29261. updatable?: boolean;
  29262. sideOrientation?: number;
  29263. }, scene: Scene): Mesh;
  29264. /**
  29265. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29266. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29267. * * 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`)
  29268. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29269. * * 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
  29270. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29271. * * 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
  29272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29273. * @param name defines the name of the mesh
  29274. * @param options defines the options used to create the mesh
  29275. * @param scene defines the hosting scene
  29276. * @returns a new Mesh
  29277. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29278. */
  29279. static CreateIcoSphere(name: string, options: {
  29280. radius?: number;
  29281. flat?: boolean;
  29282. subdivisions?: number;
  29283. sideOrientation?: number;
  29284. updatable?: boolean;
  29285. }, scene: Scene): Mesh;
  29286. /**
  29287. * Creates a decal mesh.
  29288. * Please consider using the same method from the MeshBuilder class instead.
  29289. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29290. * @param name defines the name of the mesh
  29291. * @param sourceMesh defines the mesh receiving the decal
  29292. * @param position sets the position of the decal in world coordinates
  29293. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29294. * @param size sets the decal scaling
  29295. * @param angle sets the angle to rotate the decal
  29296. * @returns a new Mesh
  29297. */
  29298. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29299. /** Creates a Capsule Mesh
  29300. * @param name defines the name of the mesh.
  29301. * @param options the constructors options used to shape the mesh.
  29302. * @param scene defines the scene the mesh is scoped to.
  29303. * @returns the capsule mesh
  29304. * @see https://doc.babylonjs.com/how_to/capsule_shape
  29305. */
  29306. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  29307. /**
  29308. * Prepare internal position array for software CPU skinning
  29309. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29310. */
  29311. setPositionsForCPUSkinning(): Float32Array;
  29312. /**
  29313. * Prepare internal normal array for software CPU skinning
  29314. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29315. */
  29316. setNormalsForCPUSkinning(): Float32Array;
  29317. /**
  29318. * Updates the vertex buffer by applying transformation from the bones
  29319. * @param skeleton defines the skeleton to apply to current mesh
  29320. * @returns the current mesh
  29321. */
  29322. applySkeleton(skeleton: Skeleton): Mesh;
  29323. /**
  29324. * 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
  29325. * @param meshes defines the list of meshes to scan
  29326. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29327. */
  29328. static MinMax(meshes: AbstractMesh[]): {
  29329. min: Vector3;
  29330. max: Vector3;
  29331. };
  29332. /**
  29333. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29334. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29335. * @returns a vector3
  29336. */
  29337. static Center(meshesOrMinMaxVector: {
  29338. min: Vector3;
  29339. max: Vector3;
  29340. } | AbstractMesh[]): Vector3;
  29341. /**
  29342. * Merge the array of meshes into a single mesh for performance reasons.
  29343. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29344. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29345. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29346. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29347. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29348. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29349. * @returns a new mesh
  29350. */
  29351. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29352. /** @hidden */
  29353. addInstance(instance: InstancedMesh): void;
  29354. /** @hidden */
  29355. removeInstance(instance: InstancedMesh): void;
  29356. }
  29357. }
  29358. declare module BABYLON {
  29359. /**
  29360. * This is the base class of all the camera used in the application.
  29361. * @see https://doc.babylonjs.com/features/cameras
  29362. */
  29363. export class Camera extends Node {
  29364. /** @hidden */
  29365. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29366. /**
  29367. * This is the default projection mode used by the cameras.
  29368. * It helps recreating a feeling of perspective and better appreciate depth.
  29369. * This is the best way to simulate real life cameras.
  29370. */
  29371. static readonly PERSPECTIVE_CAMERA: number;
  29372. /**
  29373. * This helps creating camera with an orthographic mode.
  29374. * 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.
  29375. */
  29376. static readonly ORTHOGRAPHIC_CAMERA: number;
  29377. /**
  29378. * This is the default FOV mode for perspective cameras.
  29379. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29380. */
  29381. static readonly FOVMODE_VERTICAL_FIXED: number;
  29382. /**
  29383. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29384. */
  29385. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29386. /**
  29387. * This specifies ther is no need for a camera rig.
  29388. * Basically only one eye is rendered corresponding to the camera.
  29389. */
  29390. static readonly RIG_MODE_NONE: number;
  29391. /**
  29392. * Simulates a camera Rig with one blue eye and one red eye.
  29393. * This can be use with 3d blue and red glasses.
  29394. */
  29395. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29396. /**
  29397. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29398. */
  29399. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29400. /**
  29401. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29402. */
  29403. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29404. /**
  29405. * Defines that both eyes of the camera will be rendered over under each other.
  29406. */
  29407. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29408. /**
  29409. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29410. */
  29411. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29412. /**
  29413. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29414. */
  29415. static readonly RIG_MODE_VR: number;
  29416. /**
  29417. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29418. */
  29419. static readonly RIG_MODE_WEBVR: number;
  29420. /**
  29421. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29422. */
  29423. static readonly RIG_MODE_CUSTOM: number;
  29424. /**
  29425. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29426. */
  29427. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29428. /**
  29429. * Define the input manager associated with the camera.
  29430. */
  29431. inputs: CameraInputsManager<Camera>;
  29432. /** @hidden */
  29433. _position: Vector3;
  29434. /**
  29435. * Define the current local position of the camera in the scene
  29436. */
  29437. get position(): Vector3;
  29438. set position(newPosition: Vector3);
  29439. protected _upVector: Vector3;
  29440. /**
  29441. * The vector the camera should consider as up.
  29442. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29443. */
  29444. set upVector(vec: Vector3);
  29445. get upVector(): Vector3;
  29446. /**
  29447. * Define the current limit on the left side for an orthographic camera
  29448. * In scene unit
  29449. */
  29450. orthoLeft: Nullable<number>;
  29451. /**
  29452. * Define the current limit on the right side for an orthographic camera
  29453. * In scene unit
  29454. */
  29455. orthoRight: Nullable<number>;
  29456. /**
  29457. * Define the current limit on the bottom side for an orthographic camera
  29458. * In scene unit
  29459. */
  29460. orthoBottom: Nullable<number>;
  29461. /**
  29462. * Define the current limit on the top side for an orthographic camera
  29463. * In scene unit
  29464. */
  29465. orthoTop: Nullable<number>;
  29466. /**
  29467. * Field Of View is set in Radians. (default is 0.8)
  29468. */
  29469. fov: number;
  29470. /**
  29471. * Define the minimum distance the camera can see from.
  29472. * This is important to note that the depth buffer are not infinite and the closer it starts
  29473. * the more your scene might encounter depth fighting issue.
  29474. */
  29475. minZ: number;
  29476. /**
  29477. * Define the maximum distance the camera can see to.
  29478. * This is important to note that the depth buffer are not infinite and the further it end
  29479. * the more your scene might encounter depth fighting issue.
  29480. */
  29481. maxZ: number;
  29482. /**
  29483. * Define the default inertia of the camera.
  29484. * This helps giving a smooth feeling to the camera movement.
  29485. */
  29486. inertia: number;
  29487. /**
  29488. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29489. */
  29490. mode: number;
  29491. /**
  29492. * Define whether the camera is intermediate.
  29493. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29494. */
  29495. isIntermediate: boolean;
  29496. /**
  29497. * Define the viewport of the camera.
  29498. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29499. */
  29500. viewport: Viewport;
  29501. /**
  29502. * Restricts the camera to viewing objects with the same layerMask.
  29503. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29504. */
  29505. layerMask: number;
  29506. /**
  29507. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29508. */
  29509. fovMode: number;
  29510. /**
  29511. * Rig mode of the camera.
  29512. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29513. * This is normally controlled byt the camera themselves as internal use.
  29514. */
  29515. cameraRigMode: number;
  29516. /**
  29517. * Defines the distance between both "eyes" in case of a RIG
  29518. */
  29519. interaxialDistance: number;
  29520. /**
  29521. * Defines if stereoscopic rendering is done side by side or over under.
  29522. */
  29523. isStereoscopicSideBySide: boolean;
  29524. /**
  29525. * 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
  29526. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29527. * else in the scene. (Eg. security camera)
  29528. *
  29529. * 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)
  29530. */
  29531. customRenderTargets: RenderTargetTexture[];
  29532. /**
  29533. * When set, the camera will render to this render target instead of the default canvas
  29534. *
  29535. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29536. */
  29537. outputRenderTarget: Nullable<RenderTargetTexture>;
  29538. /**
  29539. * Observable triggered when the camera view matrix has changed.
  29540. */
  29541. onViewMatrixChangedObservable: Observable<Camera>;
  29542. /**
  29543. * Observable triggered when the camera Projection matrix has changed.
  29544. */
  29545. onProjectionMatrixChangedObservable: Observable<Camera>;
  29546. /**
  29547. * Observable triggered when the inputs have been processed.
  29548. */
  29549. onAfterCheckInputsObservable: Observable<Camera>;
  29550. /**
  29551. * Observable triggered when reset has been called and applied to the camera.
  29552. */
  29553. onRestoreStateObservable: Observable<Camera>;
  29554. /**
  29555. * Is this camera a part of a rig system?
  29556. */
  29557. isRigCamera: boolean;
  29558. /**
  29559. * If isRigCamera set to true this will be set with the parent camera.
  29560. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29561. */
  29562. rigParent?: Camera;
  29563. /** @hidden */
  29564. _cameraRigParams: any;
  29565. /** @hidden */
  29566. _rigCameras: Camera[];
  29567. /** @hidden */
  29568. _rigPostProcess: Nullable<PostProcess>;
  29569. protected _webvrViewMatrix: Matrix;
  29570. /** @hidden */
  29571. _skipRendering: boolean;
  29572. /** @hidden */
  29573. _projectionMatrix: Matrix;
  29574. /** @hidden */
  29575. _postProcesses: Nullable<PostProcess>[];
  29576. /** @hidden */
  29577. _activeMeshes: SmartArray<AbstractMesh>;
  29578. protected _globalPosition: Vector3;
  29579. /** @hidden */
  29580. _computedViewMatrix: Matrix;
  29581. private _doNotComputeProjectionMatrix;
  29582. private _transformMatrix;
  29583. private _frustumPlanes;
  29584. private _refreshFrustumPlanes;
  29585. private _storedFov;
  29586. private _stateStored;
  29587. /**
  29588. * Instantiates a new camera object.
  29589. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29590. * @see https://doc.babylonjs.com/features/cameras
  29591. * @param name Defines the name of the camera in the scene
  29592. * @param position Defines the position of the camera
  29593. * @param scene Defines the scene the camera belongs too
  29594. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29595. */
  29596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29597. /**
  29598. * Store current camera state (fov, position, etc..)
  29599. * @returns the camera
  29600. */
  29601. storeState(): Camera;
  29602. /**
  29603. * Restores the camera state values if it has been stored. You must call storeState() first
  29604. */
  29605. protected _restoreStateValues(): boolean;
  29606. /**
  29607. * Restored camera state. You must call storeState() first.
  29608. * @returns true if restored and false otherwise
  29609. */
  29610. restoreState(): boolean;
  29611. /**
  29612. * Gets the class name of the camera.
  29613. * @returns the class name
  29614. */
  29615. getClassName(): string;
  29616. /** @hidden */
  29617. readonly _isCamera: boolean;
  29618. /**
  29619. * Gets a string representation of the camera useful for debug purpose.
  29620. * @param fullDetails Defines that a more verboe level of logging is required
  29621. * @returns the string representation
  29622. */
  29623. toString(fullDetails?: boolean): string;
  29624. /**
  29625. * Gets the current world space position of the camera.
  29626. */
  29627. get globalPosition(): Vector3;
  29628. /**
  29629. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29630. * @returns the active meshe list
  29631. */
  29632. getActiveMeshes(): SmartArray<AbstractMesh>;
  29633. /**
  29634. * Check whether a mesh is part of the current active mesh list of the camera
  29635. * @param mesh Defines the mesh to check
  29636. * @returns true if active, false otherwise
  29637. */
  29638. isActiveMesh(mesh: Mesh): boolean;
  29639. /**
  29640. * Is this camera ready to be used/rendered
  29641. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29642. * @return true if the camera is ready
  29643. */
  29644. isReady(completeCheck?: boolean): boolean;
  29645. /** @hidden */
  29646. _initCache(): void;
  29647. /** @hidden */
  29648. _updateCache(ignoreParentClass?: boolean): void;
  29649. /** @hidden */
  29650. _isSynchronized(): boolean;
  29651. /** @hidden */
  29652. _isSynchronizedViewMatrix(): boolean;
  29653. /** @hidden */
  29654. _isSynchronizedProjectionMatrix(): boolean;
  29655. /**
  29656. * Attach the input controls to a specific dom element to get the input from.
  29657. * @param element Defines the element the controls should be listened from
  29658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29659. */
  29660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29661. /**
  29662. * Detach the current controls from the specified dom element.
  29663. * @param element Defines the element to stop listening the inputs from
  29664. */
  29665. detachControl(element: HTMLElement): void;
  29666. /**
  29667. * Update the camera state according to the different inputs gathered during the frame.
  29668. */
  29669. update(): void;
  29670. /** @hidden */
  29671. _checkInputs(): void;
  29672. /** @hidden */
  29673. get rigCameras(): Camera[];
  29674. /**
  29675. * Gets the post process used by the rig cameras
  29676. */
  29677. get rigPostProcess(): Nullable<PostProcess>;
  29678. /**
  29679. * Internal, gets the first post proces.
  29680. * @returns the first post process to be run on this camera.
  29681. */
  29682. _getFirstPostProcess(): Nullable<PostProcess>;
  29683. private _cascadePostProcessesToRigCams;
  29684. /**
  29685. * Attach a post process to the camera.
  29686. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29687. * @param postProcess The post process to attach to the camera
  29688. * @param insertAt The position of the post process in case several of them are in use in the scene
  29689. * @returns the position the post process has been inserted at
  29690. */
  29691. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29692. /**
  29693. * Detach a post process to the camera.
  29694. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29695. * @param postProcess The post process to detach from the camera
  29696. */
  29697. detachPostProcess(postProcess: PostProcess): void;
  29698. /**
  29699. * Gets the current world matrix of the camera
  29700. */
  29701. getWorldMatrix(): Matrix;
  29702. /** @hidden */
  29703. _getViewMatrix(): Matrix;
  29704. /**
  29705. * Gets the current view matrix of the camera.
  29706. * @param force forces the camera to recompute the matrix without looking at the cached state
  29707. * @returns the view matrix
  29708. */
  29709. getViewMatrix(force?: boolean): Matrix;
  29710. /**
  29711. * Freeze the projection matrix.
  29712. * It will prevent the cache check of the camera projection compute and can speed up perf
  29713. * if no parameter of the camera are meant to change
  29714. * @param projection Defines manually a projection if necessary
  29715. */
  29716. freezeProjectionMatrix(projection?: Matrix): void;
  29717. /**
  29718. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29719. */
  29720. unfreezeProjectionMatrix(): void;
  29721. /**
  29722. * Gets the current projection matrix of the camera.
  29723. * @param force forces the camera to recompute the matrix without looking at the cached state
  29724. * @returns the projection matrix
  29725. */
  29726. getProjectionMatrix(force?: boolean): Matrix;
  29727. /**
  29728. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29729. * @returns a Matrix
  29730. */
  29731. getTransformationMatrix(): Matrix;
  29732. private _updateFrustumPlanes;
  29733. /**
  29734. * Checks if a cullable object (mesh...) is in the camera frustum
  29735. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29736. * @param target The object to check
  29737. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29738. * @returns true if the object is in frustum otherwise false
  29739. */
  29740. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29741. /**
  29742. * Checks if a cullable object (mesh...) is in the camera frustum
  29743. * Unlike isInFrustum this cheks the full bounding box
  29744. * @param target The object to check
  29745. * @returns true if the object is in frustum otherwise false
  29746. */
  29747. isCompletelyInFrustum(target: ICullable): boolean;
  29748. /**
  29749. * Gets a ray in the forward direction from the camera.
  29750. * @param length Defines the length of the ray to create
  29751. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29752. * @param origin Defines the start point of the ray which defaults to the camera position
  29753. * @returns the forward ray
  29754. */
  29755. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29756. /**
  29757. * Gets a ray in the forward direction from the camera.
  29758. * @param refRay the ray to (re)use when setting the values
  29759. * @param length Defines the length of the ray to create
  29760. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29761. * @param origin Defines the start point of the ray which defaults to the camera position
  29762. * @returns the forward ray
  29763. */
  29764. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29765. /**
  29766. * Releases resources associated with this node.
  29767. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29768. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29769. */
  29770. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29771. /** @hidden */
  29772. _isLeftCamera: boolean;
  29773. /**
  29774. * Gets the left camera of a rig setup in case of Rigged Camera
  29775. */
  29776. get isLeftCamera(): boolean;
  29777. /** @hidden */
  29778. _isRightCamera: boolean;
  29779. /**
  29780. * Gets the right camera of a rig setup in case of Rigged Camera
  29781. */
  29782. get isRightCamera(): boolean;
  29783. /**
  29784. * Gets the left camera of a rig setup in case of Rigged Camera
  29785. */
  29786. get leftCamera(): Nullable<FreeCamera>;
  29787. /**
  29788. * Gets the right camera of a rig setup in case of Rigged Camera
  29789. */
  29790. get rightCamera(): Nullable<FreeCamera>;
  29791. /**
  29792. * Gets the left camera target of a rig setup in case of Rigged Camera
  29793. * @returns the target position
  29794. */
  29795. getLeftTarget(): Nullable<Vector3>;
  29796. /**
  29797. * Gets the right camera target of a rig setup in case of Rigged Camera
  29798. * @returns the target position
  29799. */
  29800. getRightTarget(): Nullable<Vector3>;
  29801. /**
  29802. * @hidden
  29803. */
  29804. setCameraRigMode(mode: number, rigParams: any): void;
  29805. /** @hidden */
  29806. static _setStereoscopicRigMode(camera: Camera): void;
  29807. /** @hidden */
  29808. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29809. /** @hidden */
  29810. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29811. /** @hidden */
  29812. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29813. /** @hidden */
  29814. _getVRProjectionMatrix(): Matrix;
  29815. protected _updateCameraRotationMatrix(): void;
  29816. protected _updateWebVRCameraRotationMatrix(): void;
  29817. /**
  29818. * This function MUST be overwritten by the different WebVR cameras available.
  29819. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29820. * @hidden
  29821. */
  29822. _getWebVRProjectionMatrix(): Matrix;
  29823. /**
  29824. * This function MUST be overwritten by the different WebVR cameras available.
  29825. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29826. * @hidden
  29827. */
  29828. _getWebVRViewMatrix(): Matrix;
  29829. /** @hidden */
  29830. setCameraRigParameter(name: string, value: any): void;
  29831. /**
  29832. * needs to be overridden by children so sub has required properties to be copied
  29833. * @hidden
  29834. */
  29835. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29836. /**
  29837. * May need to be overridden by children
  29838. * @hidden
  29839. */
  29840. _updateRigCameras(): void;
  29841. /** @hidden */
  29842. _setupInputs(): void;
  29843. /**
  29844. * Serialiaze the camera setup to a json represention
  29845. * @returns the JSON representation
  29846. */
  29847. serialize(): any;
  29848. /**
  29849. * Clones the current camera.
  29850. * @param name The cloned camera name
  29851. * @returns the cloned camera
  29852. */
  29853. clone(name: string): Camera;
  29854. /**
  29855. * Gets the direction of the camera relative to a given local axis.
  29856. * @param localAxis Defines the reference axis to provide a relative direction.
  29857. * @return the direction
  29858. */
  29859. getDirection(localAxis: Vector3): Vector3;
  29860. /**
  29861. * Returns the current camera absolute rotation
  29862. */
  29863. get absoluteRotation(): Quaternion;
  29864. /**
  29865. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29866. * @param localAxis Defines the reference axis to provide a relative direction.
  29867. * @param result Defines the vector to store the result in
  29868. */
  29869. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29870. /**
  29871. * Gets a camera constructor for a given camera type
  29872. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29873. * @param name The name of the camera the result will be able to instantiate
  29874. * @param scene The scene the result will construct the camera in
  29875. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29876. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29877. * @returns a factory method to construc the camera
  29878. */
  29879. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29880. /**
  29881. * Compute the world matrix of the camera.
  29882. * @returns the camera world matrix
  29883. */
  29884. computeWorldMatrix(): Matrix;
  29885. /**
  29886. * Parse a JSON and creates the camera from the parsed information
  29887. * @param parsedCamera The JSON to parse
  29888. * @param scene The scene to instantiate the camera in
  29889. * @returns the newly constructed camera
  29890. */
  29891. static Parse(parsedCamera: any, scene: Scene): Camera;
  29892. }
  29893. }
  29894. declare module BABYLON {
  29895. /**
  29896. * Class containing static functions to help procedurally build meshes
  29897. */
  29898. export class DiscBuilder {
  29899. /**
  29900. * Creates a plane polygonal mesh. By default, this is a disc
  29901. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29902. * * 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
  29903. * * 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
  29904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29905. * * 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
  29906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29907. * @param name defines the name of the mesh
  29908. * @param options defines the options used to create the mesh
  29909. * @param scene defines the hosting scene
  29910. * @returns the plane polygonal mesh
  29911. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29912. */
  29913. static CreateDisc(name: string, options: {
  29914. radius?: number;
  29915. tessellation?: number;
  29916. arc?: number;
  29917. updatable?: boolean;
  29918. sideOrientation?: number;
  29919. frontUVs?: Vector4;
  29920. backUVs?: Vector4;
  29921. }, scene?: Nullable<Scene>): Mesh;
  29922. }
  29923. }
  29924. declare module BABYLON {
  29925. /**
  29926. * Options to be used when creating a FresnelParameters.
  29927. */
  29928. export type IFresnelParametersCreationOptions = {
  29929. /**
  29930. * Define the color used on edges (grazing angle)
  29931. */
  29932. leftColor?: Color3;
  29933. /**
  29934. * Define the color used on center
  29935. */
  29936. rightColor?: Color3;
  29937. /**
  29938. * Define bias applied to computed fresnel term
  29939. */
  29940. bias?: number;
  29941. /**
  29942. * Defined the power exponent applied to fresnel term
  29943. */
  29944. power?: number;
  29945. /**
  29946. * Define if the fresnel effect is enable or not.
  29947. */
  29948. isEnabled?: boolean;
  29949. };
  29950. /**
  29951. * Serialized format for FresnelParameters.
  29952. */
  29953. export type IFresnelParametersSerialized = {
  29954. /**
  29955. * Define the color used on edges (grazing angle) [as an array]
  29956. */
  29957. leftColor: number[];
  29958. /**
  29959. * Define the color used on center [as an array]
  29960. */
  29961. rightColor: number[];
  29962. /**
  29963. * Define bias applied to computed fresnel term
  29964. */
  29965. bias: number;
  29966. /**
  29967. * Defined the power exponent applied to fresnel term
  29968. */
  29969. power?: number;
  29970. /**
  29971. * Define if the fresnel effect is enable or not.
  29972. */
  29973. isEnabled: boolean;
  29974. };
  29975. /**
  29976. * This represents all the required information to add a fresnel effect on a material:
  29977. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29978. */
  29979. export class FresnelParameters {
  29980. private _isEnabled;
  29981. /**
  29982. * Define if the fresnel effect is enable or not.
  29983. */
  29984. get isEnabled(): boolean;
  29985. set isEnabled(value: boolean);
  29986. /**
  29987. * Define the color used on edges (grazing angle)
  29988. */
  29989. leftColor: Color3;
  29990. /**
  29991. * Define the color used on center
  29992. */
  29993. rightColor: Color3;
  29994. /**
  29995. * Define bias applied to computed fresnel term
  29996. */
  29997. bias: number;
  29998. /**
  29999. * Defined the power exponent applied to fresnel term
  30000. */
  30001. power: number;
  30002. /**
  30003. * Creates a new FresnelParameters object.
  30004. *
  30005. * @param options provide your own settings to optionally to override defaults
  30006. */
  30007. constructor(options?: IFresnelParametersCreationOptions);
  30008. /**
  30009. * Clones the current fresnel and its valuues
  30010. * @returns a clone fresnel configuration
  30011. */
  30012. clone(): FresnelParameters;
  30013. /**
  30014. * Determines equality between FresnelParameters objects
  30015. * @param otherFresnelParameters defines the second operand
  30016. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30017. */
  30018. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30019. /**
  30020. * Serializes the current fresnel parameters to a JSON representation.
  30021. * @return the JSON serialization
  30022. */
  30023. serialize(): IFresnelParametersSerialized;
  30024. /**
  30025. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30026. * @param parsedFresnelParameters Define the JSON representation
  30027. * @returns the parsed parameters
  30028. */
  30029. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30030. }
  30031. }
  30032. declare module BABYLON {
  30033. /**
  30034. * This groups all the flags used to control the materials channel.
  30035. */
  30036. export class MaterialFlags {
  30037. private static _DiffuseTextureEnabled;
  30038. /**
  30039. * Are diffuse textures enabled in the application.
  30040. */
  30041. static get DiffuseTextureEnabled(): boolean;
  30042. static set DiffuseTextureEnabled(value: boolean);
  30043. private static _DetailTextureEnabled;
  30044. /**
  30045. * Are detail textures enabled in the application.
  30046. */
  30047. static get DetailTextureEnabled(): boolean;
  30048. static set DetailTextureEnabled(value: boolean);
  30049. private static _AmbientTextureEnabled;
  30050. /**
  30051. * Are ambient textures enabled in the application.
  30052. */
  30053. static get AmbientTextureEnabled(): boolean;
  30054. static set AmbientTextureEnabled(value: boolean);
  30055. private static _OpacityTextureEnabled;
  30056. /**
  30057. * Are opacity textures enabled in the application.
  30058. */
  30059. static get OpacityTextureEnabled(): boolean;
  30060. static set OpacityTextureEnabled(value: boolean);
  30061. private static _ReflectionTextureEnabled;
  30062. /**
  30063. * Are reflection textures enabled in the application.
  30064. */
  30065. static get ReflectionTextureEnabled(): boolean;
  30066. static set ReflectionTextureEnabled(value: boolean);
  30067. private static _EmissiveTextureEnabled;
  30068. /**
  30069. * Are emissive textures enabled in the application.
  30070. */
  30071. static get EmissiveTextureEnabled(): boolean;
  30072. static set EmissiveTextureEnabled(value: boolean);
  30073. private static _SpecularTextureEnabled;
  30074. /**
  30075. * Are specular textures enabled in the application.
  30076. */
  30077. static get SpecularTextureEnabled(): boolean;
  30078. static set SpecularTextureEnabled(value: boolean);
  30079. private static _BumpTextureEnabled;
  30080. /**
  30081. * Are bump textures enabled in the application.
  30082. */
  30083. static get BumpTextureEnabled(): boolean;
  30084. static set BumpTextureEnabled(value: boolean);
  30085. private static _LightmapTextureEnabled;
  30086. /**
  30087. * Are lightmap textures enabled in the application.
  30088. */
  30089. static get LightmapTextureEnabled(): boolean;
  30090. static set LightmapTextureEnabled(value: boolean);
  30091. private static _RefractionTextureEnabled;
  30092. /**
  30093. * Are refraction textures enabled in the application.
  30094. */
  30095. static get RefractionTextureEnabled(): boolean;
  30096. static set RefractionTextureEnabled(value: boolean);
  30097. private static _ColorGradingTextureEnabled;
  30098. /**
  30099. * Are color grading textures enabled in the application.
  30100. */
  30101. static get ColorGradingTextureEnabled(): boolean;
  30102. static set ColorGradingTextureEnabled(value: boolean);
  30103. private static _FresnelEnabled;
  30104. /**
  30105. * Are fresnels enabled in the application.
  30106. */
  30107. static get FresnelEnabled(): boolean;
  30108. static set FresnelEnabled(value: boolean);
  30109. private static _ClearCoatTextureEnabled;
  30110. /**
  30111. * Are clear coat textures enabled in the application.
  30112. */
  30113. static get ClearCoatTextureEnabled(): boolean;
  30114. static set ClearCoatTextureEnabled(value: boolean);
  30115. private static _ClearCoatBumpTextureEnabled;
  30116. /**
  30117. * Are clear coat bump textures enabled in the application.
  30118. */
  30119. static get ClearCoatBumpTextureEnabled(): boolean;
  30120. static set ClearCoatBumpTextureEnabled(value: boolean);
  30121. private static _ClearCoatTintTextureEnabled;
  30122. /**
  30123. * Are clear coat tint textures enabled in the application.
  30124. */
  30125. static get ClearCoatTintTextureEnabled(): boolean;
  30126. static set ClearCoatTintTextureEnabled(value: boolean);
  30127. private static _SheenTextureEnabled;
  30128. /**
  30129. * Are sheen textures enabled in the application.
  30130. */
  30131. static get SheenTextureEnabled(): boolean;
  30132. static set SheenTextureEnabled(value: boolean);
  30133. private static _AnisotropicTextureEnabled;
  30134. /**
  30135. * Are anisotropic textures enabled in the application.
  30136. */
  30137. static get AnisotropicTextureEnabled(): boolean;
  30138. static set AnisotropicTextureEnabled(value: boolean);
  30139. private static _ThicknessTextureEnabled;
  30140. /**
  30141. * Are thickness textures enabled in the application.
  30142. */
  30143. static get ThicknessTextureEnabled(): boolean;
  30144. static set ThicknessTextureEnabled(value: boolean);
  30145. }
  30146. }
  30147. declare module BABYLON {
  30148. /** @hidden */
  30149. export var defaultFragmentDeclaration: {
  30150. name: string;
  30151. shader: string;
  30152. };
  30153. }
  30154. declare module BABYLON {
  30155. /** @hidden */
  30156. export var defaultUboDeclaration: {
  30157. name: string;
  30158. shader: string;
  30159. };
  30160. }
  30161. declare module BABYLON {
  30162. /** @hidden */
  30163. export var prePassDeclaration: {
  30164. name: string;
  30165. shader: string;
  30166. };
  30167. }
  30168. declare module BABYLON {
  30169. /** @hidden */
  30170. export var lightFragmentDeclaration: {
  30171. name: string;
  30172. shader: string;
  30173. };
  30174. }
  30175. declare module BABYLON {
  30176. /** @hidden */
  30177. export var lightUboDeclaration: {
  30178. name: string;
  30179. shader: string;
  30180. };
  30181. }
  30182. declare module BABYLON {
  30183. /** @hidden */
  30184. export var lightsFragmentFunctions: {
  30185. name: string;
  30186. shader: string;
  30187. };
  30188. }
  30189. declare module BABYLON {
  30190. /** @hidden */
  30191. export var shadowsFragmentFunctions: {
  30192. name: string;
  30193. shader: string;
  30194. };
  30195. }
  30196. declare module BABYLON {
  30197. /** @hidden */
  30198. export var fresnelFunction: {
  30199. name: string;
  30200. shader: string;
  30201. };
  30202. }
  30203. declare module BABYLON {
  30204. /** @hidden */
  30205. export var bumpFragmentMainFunctions: {
  30206. name: string;
  30207. shader: string;
  30208. };
  30209. }
  30210. declare module BABYLON {
  30211. /** @hidden */
  30212. export var bumpFragmentFunctions: {
  30213. name: string;
  30214. shader: string;
  30215. };
  30216. }
  30217. declare module BABYLON {
  30218. /** @hidden */
  30219. export var logDepthDeclaration: {
  30220. name: string;
  30221. shader: string;
  30222. };
  30223. }
  30224. declare module BABYLON {
  30225. /** @hidden */
  30226. export var bumpFragment: {
  30227. name: string;
  30228. shader: string;
  30229. };
  30230. }
  30231. declare module BABYLON {
  30232. /** @hidden */
  30233. export var depthPrePass: {
  30234. name: string;
  30235. shader: string;
  30236. };
  30237. }
  30238. declare module BABYLON {
  30239. /** @hidden */
  30240. export var lightFragment: {
  30241. name: string;
  30242. shader: string;
  30243. };
  30244. }
  30245. declare module BABYLON {
  30246. /** @hidden */
  30247. export var logDepthFragment: {
  30248. name: string;
  30249. shader: string;
  30250. };
  30251. }
  30252. declare module BABYLON {
  30253. /** @hidden */
  30254. export var defaultPixelShader: {
  30255. name: string;
  30256. shader: string;
  30257. };
  30258. }
  30259. declare module BABYLON {
  30260. /** @hidden */
  30261. export var defaultVertexDeclaration: {
  30262. name: string;
  30263. shader: string;
  30264. };
  30265. }
  30266. declare module BABYLON {
  30267. /** @hidden */
  30268. export var bumpVertexDeclaration: {
  30269. name: string;
  30270. shader: string;
  30271. };
  30272. }
  30273. declare module BABYLON {
  30274. /** @hidden */
  30275. export var bumpVertex: {
  30276. name: string;
  30277. shader: string;
  30278. };
  30279. }
  30280. declare module BABYLON {
  30281. /** @hidden */
  30282. export var fogVertex: {
  30283. name: string;
  30284. shader: string;
  30285. };
  30286. }
  30287. declare module BABYLON {
  30288. /** @hidden */
  30289. export var shadowsVertex: {
  30290. name: string;
  30291. shader: string;
  30292. };
  30293. }
  30294. declare module BABYLON {
  30295. /** @hidden */
  30296. export var pointCloudVertex: {
  30297. name: string;
  30298. shader: string;
  30299. };
  30300. }
  30301. declare module BABYLON {
  30302. /** @hidden */
  30303. export var logDepthVertex: {
  30304. name: string;
  30305. shader: string;
  30306. };
  30307. }
  30308. declare module BABYLON {
  30309. /** @hidden */
  30310. export var defaultVertexShader: {
  30311. name: string;
  30312. shader: string;
  30313. };
  30314. }
  30315. declare module BABYLON {
  30316. /**
  30317. * @hidden
  30318. */
  30319. export interface IMaterialDetailMapDefines {
  30320. DETAIL: boolean;
  30321. DETAILDIRECTUV: number;
  30322. DETAIL_NORMALBLENDMETHOD: number;
  30323. /** @hidden */
  30324. _areTexturesDirty: boolean;
  30325. }
  30326. /**
  30327. * Define the code related to the detail map parameters of a material
  30328. *
  30329. * Inspired from:
  30330. * 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
  30331. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30332. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30333. */
  30334. export class DetailMapConfiguration {
  30335. private _texture;
  30336. /**
  30337. * The detail texture of the material.
  30338. */
  30339. texture: Nullable<BaseTexture>;
  30340. /**
  30341. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30342. * Bigger values mean stronger blending
  30343. */
  30344. diffuseBlendLevel: number;
  30345. /**
  30346. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30347. * Bigger values mean stronger blending. Only used with PBR materials
  30348. */
  30349. roughnessBlendLevel: number;
  30350. /**
  30351. * Defines how strong the bump effect from the detail map is
  30352. * Bigger values mean stronger effect
  30353. */
  30354. bumpLevel: number;
  30355. private _normalBlendMethod;
  30356. /**
  30357. * The method used to blend the bump and detail normals together
  30358. */
  30359. normalBlendMethod: number;
  30360. private _isEnabled;
  30361. /**
  30362. * Enable or disable the detail map on this material
  30363. */
  30364. isEnabled: boolean;
  30365. /** @hidden */
  30366. private _internalMarkAllSubMeshesAsTexturesDirty;
  30367. /** @hidden */
  30368. _markAllSubMeshesAsTexturesDirty(): void;
  30369. /**
  30370. * Instantiate a new detail map
  30371. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30372. */
  30373. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30374. /**
  30375. * Gets whether the submesh is ready to be used or not.
  30376. * @param defines the list of "defines" to update.
  30377. * @param scene defines the scene the material belongs to.
  30378. * @returns - boolean indicating that the submesh is ready or not.
  30379. */
  30380. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30381. /**
  30382. * Update the defines for detail map usage
  30383. * @param defines the list of "defines" to update.
  30384. * @param scene defines the scene the material belongs to.
  30385. */
  30386. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30387. /**
  30388. * Binds the material data.
  30389. * @param uniformBuffer defines the Uniform buffer to fill in.
  30390. * @param scene defines the scene the material belongs to.
  30391. * @param isFrozen defines whether the material is frozen or not.
  30392. */
  30393. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30394. /**
  30395. * Checks to see if a texture is used in the material.
  30396. * @param texture - Base texture to use.
  30397. * @returns - Boolean specifying if a texture is used in the material.
  30398. */
  30399. hasTexture(texture: BaseTexture): boolean;
  30400. /**
  30401. * Returns an array of the actively used textures.
  30402. * @param activeTextures Array of BaseTextures
  30403. */
  30404. getActiveTextures(activeTextures: BaseTexture[]): void;
  30405. /**
  30406. * Returns the animatable textures.
  30407. * @param animatables Array of animatable textures.
  30408. */
  30409. getAnimatables(animatables: IAnimatable[]): void;
  30410. /**
  30411. * Disposes the resources of the material.
  30412. * @param forceDisposeTextures - Forces the disposal of all textures.
  30413. */
  30414. dispose(forceDisposeTextures?: boolean): void;
  30415. /**
  30416. * Get the current class name useful for serialization or dynamic coding.
  30417. * @returns "DetailMap"
  30418. */
  30419. getClassName(): string;
  30420. /**
  30421. * Add the required uniforms to the current list.
  30422. * @param uniforms defines the current uniform list.
  30423. */
  30424. static AddUniforms(uniforms: string[]): void;
  30425. /**
  30426. * Add the required samplers to the current list.
  30427. * @param samplers defines the current sampler list.
  30428. */
  30429. static AddSamplers(samplers: string[]): void;
  30430. /**
  30431. * Add the required uniforms to the current buffer.
  30432. * @param uniformBuffer defines the current uniform buffer.
  30433. */
  30434. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30435. /**
  30436. * Makes a duplicate of the current instance into another one.
  30437. * @param detailMap define the instance where to copy the info
  30438. */
  30439. copyTo(detailMap: DetailMapConfiguration): void;
  30440. /**
  30441. * Serializes this detail map instance
  30442. * @returns - An object with the serialized instance.
  30443. */
  30444. serialize(): any;
  30445. /**
  30446. * Parses a detail map setting from a serialized object.
  30447. * @param source - Serialized object.
  30448. * @param scene Defines the scene we are parsing for
  30449. * @param rootUrl Defines the rootUrl to load from
  30450. */
  30451. parse(source: any, scene: Scene, rootUrl: string): void;
  30452. }
  30453. }
  30454. declare module BABYLON {
  30455. /** @hidden */
  30456. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30457. MAINUV1: boolean;
  30458. MAINUV2: boolean;
  30459. DIFFUSE: boolean;
  30460. DIFFUSEDIRECTUV: number;
  30461. DETAIL: boolean;
  30462. DETAILDIRECTUV: number;
  30463. DETAIL_NORMALBLENDMETHOD: number;
  30464. AMBIENT: boolean;
  30465. AMBIENTDIRECTUV: number;
  30466. OPACITY: boolean;
  30467. OPACITYDIRECTUV: number;
  30468. OPACITYRGB: boolean;
  30469. REFLECTION: boolean;
  30470. EMISSIVE: boolean;
  30471. EMISSIVEDIRECTUV: number;
  30472. SPECULAR: boolean;
  30473. SPECULARDIRECTUV: number;
  30474. BUMP: boolean;
  30475. BUMPDIRECTUV: number;
  30476. PARALLAX: boolean;
  30477. PARALLAXOCCLUSION: boolean;
  30478. SPECULAROVERALPHA: boolean;
  30479. CLIPPLANE: boolean;
  30480. CLIPPLANE2: boolean;
  30481. CLIPPLANE3: boolean;
  30482. CLIPPLANE4: boolean;
  30483. CLIPPLANE5: boolean;
  30484. CLIPPLANE6: boolean;
  30485. ALPHATEST: boolean;
  30486. DEPTHPREPASS: boolean;
  30487. ALPHAFROMDIFFUSE: boolean;
  30488. POINTSIZE: boolean;
  30489. FOG: boolean;
  30490. SPECULARTERM: boolean;
  30491. DIFFUSEFRESNEL: boolean;
  30492. OPACITYFRESNEL: boolean;
  30493. REFLECTIONFRESNEL: boolean;
  30494. REFRACTIONFRESNEL: boolean;
  30495. EMISSIVEFRESNEL: boolean;
  30496. FRESNEL: boolean;
  30497. NORMAL: boolean;
  30498. UV1: boolean;
  30499. UV2: boolean;
  30500. VERTEXCOLOR: boolean;
  30501. VERTEXALPHA: boolean;
  30502. NUM_BONE_INFLUENCERS: number;
  30503. BonesPerMesh: number;
  30504. BONETEXTURE: boolean;
  30505. INSTANCES: boolean;
  30506. THIN_INSTANCES: boolean;
  30507. GLOSSINESS: boolean;
  30508. ROUGHNESS: boolean;
  30509. EMISSIVEASILLUMINATION: boolean;
  30510. LINKEMISSIVEWITHDIFFUSE: boolean;
  30511. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30512. LIGHTMAP: boolean;
  30513. LIGHTMAPDIRECTUV: number;
  30514. OBJECTSPACE_NORMALMAP: boolean;
  30515. USELIGHTMAPASSHADOWMAP: boolean;
  30516. REFLECTIONMAP_3D: boolean;
  30517. REFLECTIONMAP_SPHERICAL: boolean;
  30518. REFLECTIONMAP_PLANAR: boolean;
  30519. REFLECTIONMAP_CUBIC: boolean;
  30520. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30521. REFLECTIONMAP_PROJECTION: boolean;
  30522. REFLECTIONMAP_SKYBOX: boolean;
  30523. REFLECTIONMAP_EXPLICIT: boolean;
  30524. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30525. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30526. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30527. INVERTCUBICMAP: boolean;
  30528. LOGARITHMICDEPTH: boolean;
  30529. REFRACTION: boolean;
  30530. REFRACTIONMAP_3D: boolean;
  30531. REFLECTIONOVERALPHA: boolean;
  30532. TWOSIDEDLIGHTING: boolean;
  30533. SHADOWFLOAT: boolean;
  30534. MORPHTARGETS: boolean;
  30535. MORPHTARGETS_NORMAL: boolean;
  30536. MORPHTARGETS_TANGENT: boolean;
  30537. MORPHTARGETS_UV: boolean;
  30538. NUM_MORPH_INFLUENCERS: number;
  30539. NONUNIFORMSCALING: boolean;
  30540. PREMULTIPLYALPHA: boolean;
  30541. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30542. ALPHABLEND: boolean;
  30543. PREPASS: boolean;
  30544. SCENE_MRT_COUNT: number;
  30545. RGBDLIGHTMAP: boolean;
  30546. RGBDREFLECTION: boolean;
  30547. RGBDREFRACTION: boolean;
  30548. IMAGEPROCESSING: boolean;
  30549. VIGNETTE: boolean;
  30550. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30551. VIGNETTEBLENDMODEOPAQUE: boolean;
  30552. TONEMAPPING: boolean;
  30553. TONEMAPPING_ACES: boolean;
  30554. CONTRAST: boolean;
  30555. COLORCURVES: boolean;
  30556. COLORGRADING: boolean;
  30557. COLORGRADING3D: boolean;
  30558. SAMPLER3DGREENDEPTH: boolean;
  30559. SAMPLER3DBGRMAP: boolean;
  30560. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30561. MULTIVIEW: boolean;
  30562. /**
  30563. * If the reflection texture on this material is in linear color space
  30564. * @hidden
  30565. */
  30566. IS_REFLECTION_LINEAR: boolean;
  30567. /**
  30568. * If the refraction texture on this material is in linear color space
  30569. * @hidden
  30570. */
  30571. IS_REFRACTION_LINEAR: boolean;
  30572. EXPOSURE: boolean;
  30573. constructor();
  30574. setReflectionMode(modeToEnable: string): void;
  30575. }
  30576. /**
  30577. * This is the default material used in Babylon. It is the best trade off between quality
  30578. * and performances.
  30579. * @see https://doc.babylonjs.com/babylon101/materials
  30580. */
  30581. export class StandardMaterial extends PushMaterial {
  30582. private _diffuseTexture;
  30583. /**
  30584. * The basic texture of the material as viewed under a light.
  30585. */
  30586. diffuseTexture: Nullable<BaseTexture>;
  30587. private _ambientTexture;
  30588. /**
  30589. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30590. */
  30591. ambientTexture: Nullable<BaseTexture>;
  30592. private _opacityTexture;
  30593. /**
  30594. * Define the transparency of the material from a texture.
  30595. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30596. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30597. */
  30598. opacityTexture: Nullable<BaseTexture>;
  30599. private _reflectionTexture;
  30600. /**
  30601. * Define the texture used to display the reflection.
  30602. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30603. */
  30604. reflectionTexture: Nullable<BaseTexture>;
  30605. private _emissiveTexture;
  30606. /**
  30607. * Define texture of the material as if self lit.
  30608. * This will be mixed in the final result even in the absence of light.
  30609. */
  30610. emissiveTexture: Nullable<BaseTexture>;
  30611. private _specularTexture;
  30612. /**
  30613. * Define how the color and intensity of the highlight given by the light in the material.
  30614. */
  30615. specularTexture: Nullable<BaseTexture>;
  30616. private _bumpTexture;
  30617. /**
  30618. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30619. * 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.
  30620. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30621. */
  30622. bumpTexture: Nullable<BaseTexture>;
  30623. private _lightmapTexture;
  30624. /**
  30625. * Complex lighting can be computationally expensive to compute at runtime.
  30626. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30627. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30628. */
  30629. lightmapTexture: Nullable<BaseTexture>;
  30630. private _refractionTexture;
  30631. /**
  30632. * Define the texture used to display the refraction.
  30633. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30634. */
  30635. refractionTexture: Nullable<BaseTexture>;
  30636. /**
  30637. * The color of the material lit by the environmental background lighting.
  30638. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30639. */
  30640. ambientColor: Color3;
  30641. /**
  30642. * The basic color of the material as viewed under a light.
  30643. */
  30644. diffuseColor: Color3;
  30645. /**
  30646. * Define how the color and intensity of the highlight given by the light in the material.
  30647. */
  30648. specularColor: Color3;
  30649. /**
  30650. * Define the color of the material as if self lit.
  30651. * This will be mixed in the final result even in the absence of light.
  30652. */
  30653. emissiveColor: Color3;
  30654. /**
  30655. * Defines how sharp are the highlights in the material.
  30656. * The bigger the value the sharper giving a more glossy feeling to the result.
  30657. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30658. */
  30659. specularPower: number;
  30660. private _useAlphaFromDiffuseTexture;
  30661. /**
  30662. * Does the transparency come from the diffuse texture alpha channel.
  30663. */
  30664. useAlphaFromDiffuseTexture: boolean;
  30665. private _useEmissiveAsIllumination;
  30666. /**
  30667. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30668. */
  30669. useEmissiveAsIllumination: boolean;
  30670. private _linkEmissiveWithDiffuse;
  30671. /**
  30672. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30673. * the emissive level when the final color is close to one.
  30674. */
  30675. linkEmissiveWithDiffuse: boolean;
  30676. private _useSpecularOverAlpha;
  30677. /**
  30678. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30679. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30680. */
  30681. useSpecularOverAlpha: boolean;
  30682. private _useReflectionOverAlpha;
  30683. /**
  30684. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30685. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30686. */
  30687. useReflectionOverAlpha: boolean;
  30688. private _disableLighting;
  30689. /**
  30690. * Does lights from the scene impacts this material.
  30691. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30692. */
  30693. disableLighting: boolean;
  30694. private _useObjectSpaceNormalMap;
  30695. /**
  30696. * Allows using an object space normal map (instead of tangent space).
  30697. */
  30698. useObjectSpaceNormalMap: boolean;
  30699. private _useParallax;
  30700. /**
  30701. * Is parallax enabled or not.
  30702. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30703. */
  30704. useParallax: boolean;
  30705. private _useParallaxOcclusion;
  30706. /**
  30707. * Is parallax occlusion enabled or not.
  30708. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30709. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30710. */
  30711. useParallaxOcclusion: boolean;
  30712. /**
  30713. * 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.
  30714. */
  30715. parallaxScaleBias: number;
  30716. private _roughness;
  30717. /**
  30718. * Helps to define how blurry the reflections should appears in the material.
  30719. */
  30720. roughness: number;
  30721. /**
  30722. * In case of refraction, define the value of the index of refraction.
  30723. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30724. */
  30725. indexOfRefraction: number;
  30726. /**
  30727. * Invert the refraction texture alongside the y axis.
  30728. * It can be useful with procedural textures or probe for instance.
  30729. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30730. */
  30731. invertRefractionY: boolean;
  30732. /**
  30733. * Defines the alpha limits in alpha test mode.
  30734. */
  30735. alphaCutOff: number;
  30736. private _useLightmapAsShadowmap;
  30737. /**
  30738. * In case of light mapping, define whether the map contains light or shadow informations.
  30739. */
  30740. useLightmapAsShadowmap: boolean;
  30741. private _diffuseFresnelParameters;
  30742. /**
  30743. * Define the diffuse fresnel parameters of the material.
  30744. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30745. */
  30746. diffuseFresnelParameters: FresnelParameters;
  30747. private _opacityFresnelParameters;
  30748. /**
  30749. * Define the opacity fresnel parameters of the material.
  30750. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30751. */
  30752. opacityFresnelParameters: FresnelParameters;
  30753. private _reflectionFresnelParameters;
  30754. /**
  30755. * Define the reflection fresnel parameters of the material.
  30756. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30757. */
  30758. reflectionFresnelParameters: FresnelParameters;
  30759. private _refractionFresnelParameters;
  30760. /**
  30761. * Define the refraction fresnel parameters of the material.
  30762. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30763. */
  30764. refractionFresnelParameters: FresnelParameters;
  30765. private _emissiveFresnelParameters;
  30766. /**
  30767. * Define the emissive fresnel parameters of the material.
  30768. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30769. */
  30770. emissiveFresnelParameters: FresnelParameters;
  30771. private _useReflectionFresnelFromSpecular;
  30772. /**
  30773. * If true automatically deducts the fresnels values from the material specularity.
  30774. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30775. */
  30776. useReflectionFresnelFromSpecular: boolean;
  30777. private _useGlossinessFromSpecularMapAlpha;
  30778. /**
  30779. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30780. */
  30781. useGlossinessFromSpecularMapAlpha: boolean;
  30782. private _maxSimultaneousLights;
  30783. /**
  30784. * Defines the maximum number of lights that can be used in the material
  30785. */
  30786. maxSimultaneousLights: number;
  30787. private _invertNormalMapX;
  30788. /**
  30789. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30790. */
  30791. invertNormalMapX: boolean;
  30792. private _invertNormalMapY;
  30793. /**
  30794. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30795. */
  30796. invertNormalMapY: boolean;
  30797. private _twoSidedLighting;
  30798. /**
  30799. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30800. */
  30801. twoSidedLighting: boolean;
  30802. /**
  30803. * Default configuration related to image processing available in the standard Material.
  30804. */
  30805. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30806. /**
  30807. * Gets the image processing configuration used either in this material.
  30808. */
  30809. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30810. /**
  30811. * Sets the Default image processing configuration used either in the this material.
  30812. *
  30813. * If sets to null, the scene one is in use.
  30814. */
  30815. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30816. /**
  30817. * Keep track of the image processing observer to allow dispose and replace.
  30818. */
  30819. private _imageProcessingObserver;
  30820. /**
  30821. * Attaches a new image processing configuration to the Standard Material.
  30822. * @param configuration
  30823. */
  30824. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30825. /**
  30826. * Gets wether the color curves effect is enabled.
  30827. */
  30828. get cameraColorCurvesEnabled(): boolean;
  30829. /**
  30830. * Sets wether the color curves effect is enabled.
  30831. */
  30832. set cameraColorCurvesEnabled(value: boolean);
  30833. /**
  30834. * Gets wether the color grading effect is enabled.
  30835. */
  30836. get cameraColorGradingEnabled(): boolean;
  30837. /**
  30838. * Gets wether the color grading effect is enabled.
  30839. */
  30840. set cameraColorGradingEnabled(value: boolean);
  30841. /**
  30842. * Gets wether tonemapping is enabled or not.
  30843. */
  30844. get cameraToneMappingEnabled(): boolean;
  30845. /**
  30846. * Sets wether tonemapping is enabled or not
  30847. */
  30848. set cameraToneMappingEnabled(value: boolean);
  30849. /**
  30850. * The camera exposure used on this material.
  30851. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30852. * This corresponds to a photographic exposure.
  30853. */
  30854. get cameraExposure(): number;
  30855. /**
  30856. * The camera exposure used on this material.
  30857. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30858. * This corresponds to a photographic exposure.
  30859. */
  30860. set cameraExposure(value: number);
  30861. /**
  30862. * Gets The camera contrast used on this material.
  30863. */
  30864. get cameraContrast(): number;
  30865. /**
  30866. * Sets The camera contrast used on this material.
  30867. */
  30868. set cameraContrast(value: number);
  30869. /**
  30870. * Gets the Color Grading 2D Lookup Texture.
  30871. */
  30872. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30873. /**
  30874. * Sets the Color Grading 2D Lookup Texture.
  30875. */
  30876. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30877. /**
  30878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30880. * 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;
  30881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30882. */
  30883. get cameraColorCurves(): Nullable<ColorCurves>;
  30884. /**
  30885. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30886. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30887. * 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;
  30888. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30889. */
  30890. set cameraColorCurves(value: Nullable<ColorCurves>);
  30891. /**
  30892. * Can this material render to several textures at once
  30893. */
  30894. get canRenderToMRT(): boolean;
  30895. /**
  30896. * Defines the detail map parameters for the material.
  30897. */
  30898. readonly detailMap: DetailMapConfiguration;
  30899. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30900. protected _worldViewProjectionMatrix: Matrix;
  30901. protected _globalAmbientColor: Color3;
  30902. protected _useLogarithmicDepth: boolean;
  30903. protected _rebuildInParallel: boolean;
  30904. /**
  30905. * Instantiates a new standard material.
  30906. * This is the default material used in Babylon. It is the best trade off between quality
  30907. * and performances.
  30908. * @see https://doc.babylonjs.com/babylon101/materials
  30909. * @param name Define the name of the material in the scene
  30910. * @param scene Define the scene the material belong to
  30911. */
  30912. constructor(name: string, scene: Scene);
  30913. /**
  30914. * Gets a boolean indicating that current material needs to register RTT
  30915. */
  30916. get hasRenderTargetTextures(): boolean;
  30917. /**
  30918. * Gets the current class name of the material e.g. "StandardMaterial"
  30919. * Mainly use in serialization.
  30920. * @returns the class name
  30921. */
  30922. getClassName(): string;
  30923. /**
  30924. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30925. * You can try switching to logarithmic depth.
  30926. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30927. */
  30928. get useLogarithmicDepth(): boolean;
  30929. set useLogarithmicDepth(value: boolean);
  30930. /**
  30931. * Specifies if the material will require alpha blending
  30932. * @returns a boolean specifying if alpha blending is needed
  30933. */
  30934. needAlphaBlending(): boolean;
  30935. /**
  30936. * Specifies if this material should be rendered in alpha test mode
  30937. * @returns a boolean specifying if an alpha test is needed.
  30938. */
  30939. needAlphaTesting(): boolean;
  30940. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30941. /**
  30942. * Get the texture used for alpha test purpose.
  30943. * @returns the diffuse texture in case of the standard material.
  30944. */
  30945. getAlphaTestTexture(): Nullable<BaseTexture>;
  30946. /**
  30947. * Get if the submesh is ready to be used and all its information available.
  30948. * Child classes can use it to update shaders
  30949. * @param mesh defines the mesh to check
  30950. * @param subMesh defines which submesh to check
  30951. * @param useInstances specifies that instances should be used
  30952. * @returns a boolean indicating that the submesh is ready or not
  30953. */
  30954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30955. /**
  30956. * Builds the material UBO layouts.
  30957. * Used internally during the effect preparation.
  30958. */
  30959. buildUniformLayout(): void;
  30960. /**
  30961. * Unbinds the material from the mesh
  30962. */
  30963. unbind(): void;
  30964. /**
  30965. * Binds the submesh to this material by preparing the effect and shader to draw
  30966. * @param world defines the world transformation matrix
  30967. * @param mesh defines the mesh containing the submesh
  30968. * @param subMesh defines the submesh to bind the material to
  30969. */
  30970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30971. /**
  30972. * Get the list of animatables in the material.
  30973. * @returns the list of animatables object used in the material
  30974. */
  30975. getAnimatables(): IAnimatable[];
  30976. /**
  30977. * Gets the active textures from the material
  30978. * @returns an array of textures
  30979. */
  30980. getActiveTextures(): BaseTexture[];
  30981. /**
  30982. * Specifies if the material uses a texture
  30983. * @param texture defines the texture to check against the material
  30984. * @returns a boolean specifying if the material uses the texture
  30985. */
  30986. hasTexture(texture: BaseTexture): boolean;
  30987. /**
  30988. * Disposes the material
  30989. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30990. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30991. */
  30992. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30993. /**
  30994. * Makes a duplicate of the material, and gives it a new name
  30995. * @param name defines the new name for the duplicated material
  30996. * @returns the cloned material
  30997. */
  30998. clone(name: string): StandardMaterial;
  30999. /**
  31000. * Serializes this material in a JSON representation
  31001. * @returns the serialized material object
  31002. */
  31003. serialize(): any;
  31004. /**
  31005. * Creates a standard material from parsed material data
  31006. * @param source defines the JSON representation of the material
  31007. * @param scene defines the hosting scene
  31008. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31009. * @returns a new standard material
  31010. */
  31011. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31012. /**
  31013. * Are diffuse textures enabled in the application.
  31014. */
  31015. static get DiffuseTextureEnabled(): boolean;
  31016. static set DiffuseTextureEnabled(value: boolean);
  31017. /**
  31018. * Are detail textures enabled in the application.
  31019. */
  31020. static get DetailTextureEnabled(): boolean;
  31021. static set DetailTextureEnabled(value: boolean);
  31022. /**
  31023. * Are ambient textures enabled in the application.
  31024. */
  31025. static get AmbientTextureEnabled(): boolean;
  31026. static set AmbientTextureEnabled(value: boolean);
  31027. /**
  31028. * Are opacity textures enabled in the application.
  31029. */
  31030. static get OpacityTextureEnabled(): boolean;
  31031. static set OpacityTextureEnabled(value: boolean);
  31032. /**
  31033. * Are reflection textures enabled in the application.
  31034. */
  31035. static get ReflectionTextureEnabled(): boolean;
  31036. static set ReflectionTextureEnabled(value: boolean);
  31037. /**
  31038. * Are emissive textures enabled in the application.
  31039. */
  31040. static get EmissiveTextureEnabled(): boolean;
  31041. static set EmissiveTextureEnabled(value: boolean);
  31042. /**
  31043. * Are specular textures enabled in the application.
  31044. */
  31045. static get SpecularTextureEnabled(): boolean;
  31046. static set SpecularTextureEnabled(value: boolean);
  31047. /**
  31048. * Are bump textures enabled in the application.
  31049. */
  31050. static get BumpTextureEnabled(): boolean;
  31051. static set BumpTextureEnabled(value: boolean);
  31052. /**
  31053. * Are lightmap textures enabled in the application.
  31054. */
  31055. static get LightmapTextureEnabled(): boolean;
  31056. static set LightmapTextureEnabled(value: boolean);
  31057. /**
  31058. * Are refraction textures enabled in the application.
  31059. */
  31060. static get RefractionTextureEnabled(): boolean;
  31061. static set RefractionTextureEnabled(value: boolean);
  31062. /**
  31063. * Are color grading textures enabled in the application.
  31064. */
  31065. static get ColorGradingTextureEnabled(): boolean;
  31066. static set ColorGradingTextureEnabled(value: boolean);
  31067. /**
  31068. * Are fresnels enabled in the application.
  31069. */
  31070. static get FresnelEnabled(): boolean;
  31071. static set FresnelEnabled(value: boolean);
  31072. }
  31073. }
  31074. declare module BABYLON {
  31075. /**
  31076. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31077. *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.
  31078. * The SPS is also a particle system. It provides some methods to manage the particles.
  31079. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31080. *
  31081. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31082. */
  31083. export class SolidParticleSystem implements IDisposable {
  31084. /**
  31085. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31086. * Example : var p = SPS.particles[i];
  31087. */
  31088. particles: SolidParticle[];
  31089. /**
  31090. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31091. */
  31092. nbParticles: number;
  31093. /**
  31094. * If the particles must ever face the camera (default false). Useful for planar particles.
  31095. */
  31096. billboard: boolean;
  31097. /**
  31098. * Recompute normals when adding a shape
  31099. */
  31100. recomputeNormals: boolean;
  31101. /**
  31102. * This a counter ofr your own usage. It's not set by any SPS functions.
  31103. */
  31104. counter: number;
  31105. /**
  31106. * The SPS name. This name is also given to the underlying mesh.
  31107. */
  31108. name: string;
  31109. /**
  31110. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31111. */
  31112. mesh: Mesh;
  31113. /**
  31114. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31115. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31116. */
  31117. vars: any;
  31118. /**
  31119. * This array is populated when the SPS is set as 'pickable'.
  31120. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31121. * Each element of this array is an object `{idx: int, faceId: int}`.
  31122. * `idx` is the picked particle index in the `SPS.particles` array
  31123. * `faceId` is the picked face index counted within this particle.
  31124. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31125. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31126. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31127. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31128. */
  31129. pickedParticles: {
  31130. idx: number;
  31131. faceId: number;
  31132. }[];
  31133. /**
  31134. * This array is populated when the SPS is set as 'pickable'
  31135. * Each key of this array is a submesh index.
  31136. * Each element of this array is a second array defined like this :
  31137. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31138. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31139. * `idx` is the picked particle index in the `SPS.particles` array
  31140. * `faceId` is the picked face index counted within this particle.
  31141. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31142. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31143. */
  31144. pickedBySubMesh: {
  31145. idx: number;
  31146. faceId: number;
  31147. }[][];
  31148. /**
  31149. * This array is populated when `enableDepthSort` is set to true.
  31150. * Each element of this array is an instance of the class DepthSortedParticle.
  31151. */
  31152. depthSortedParticles: DepthSortedParticle[];
  31153. /**
  31154. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31155. * @hidden
  31156. */
  31157. _bSphereOnly: boolean;
  31158. /**
  31159. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31160. * @hidden
  31161. */
  31162. _bSphereRadiusFactor: number;
  31163. private _scene;
  31164. private _positions;
  31165. private _indices;
  31166. private _normals;
  31167. private _colors;
  31168. private _uvs;
  31169. private _indices32;
  31170. private _positions32;
  31171. private _normals32;
  31172. private _fixedNormal32;
  31173. private _colors32;
  31174. private _uvs32;
  31175. private _index;
  31176. private _updatable;
  31177. private _pickable;
  31178. private _isVisibilityBoxLocked;
  31179. private _alwaysVisible;
  31180. private _depthSort;
  31181. private _expandable;
  31182. private _shapeCounter;
  31183. private _copy;
  31184. private _color;
  31185. private _computeParticleColor;
  31186. private _computeParticleTexture;
  31187. private _computeParticleRotation;
  31188. private _computeParticleVertex;
  31189. private _computeBoundingBox;
  31190. private _depthSortParticles;
  31191. private _camera;
  31192. private _mustUnrotateFixedNormals;
  31193. private _particlesIntersect;
  31194. private _needs32Bits;
  31195. private _isNotBuilt;
  31196. private _lastParticleId;
  31197. private _idxOfId;
  31198. private _multimaterialEnabled;
  31199. private _useModelMaterial;
  31200. private _indicesByMaterial;
  31201. private _materialIndexes;
  31202. private _depthSortFunction;
  31203. private _materialSortFunction;
  31204. private _materials;
  31205. private _multimaterial;
  31206. private _materialIndexesById;
  31207. private _defaultMaterial;
  31208. private _autoUpdateSubMeshes;
  31209. private _tmpVertex;
  31210. /**
  31211. * Creates a SPS (Solid Particle System) object.
  31212. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31213. * @param scene (Scene) is the scene in which the SPS is added.
  31214. * @param options defines the options of the sps e.g.
  31215. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31216. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31217. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31218. * * 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.
  31219. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31220. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31221. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31222. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31223. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31224. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31225. */
  31226. constructor(name: string, scene: Scene, options?: {
  31227. updatable?: boolean;
  31228. isPickable?: boolean;
  31229. enableDepthSort?: boolean;
  31230. particleIntersection?: boolean;
  31231. boundingSphereOnly?: boolean;
  31232. bSphereRadiusFactor?: number;
  31233. expandable?: boolean;
  31234. useModelMaterial?: boolean;
  31235. enableMultiMaterial?: boolean;
  31236. });
  31237. /**
  31238. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31239. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31240. * @returns the created mesh
  31241. */
  31242. buildMesh(): Mesh;
  31243. /**
  31244. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31245. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31246. * Thus the particles generated from `digest()` have their property `position` set yet.
  31247. * @param mesh ( Mesh ) is the mesh to be digested
  31248. * @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
  31249. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31250. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31251. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31252. * @returns the current SPS
  31253. */
  31254. digest(mesh: Mesh, options?: {
  31255. facetNb?: number;
  31256. number?: number;
  31257. delta?: number;
  31258. storage?: [];
  31259. }): SolidParticleSystem;
  31260. /**
  31261. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31262. * @hidden
  31263. */
  31264. private _unrotateFixedNormals;
  31265. /**
  31266. * Resets the temporary working copy particle
  31267. * @hidden
  31268. */
  31269. private _resetCopy;
  31270. /**
  31271. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31272. * @param p the current index in the positions array to be updated
  31273. * @param ind the current index in the indices array
  31274. * @param shape a Vector3 array, the shape geometry
  31275. * @param positions the positions array to be updated
  31276. * @param meshInd the shape indices array
  31277. * @param indices the indices array to be updated
  31278. * @param meshUV the shape uv array
  31279. * @param uvs the uv array to be updated
  31280. * @param meshCol the shape color array
  31281. * @param colors the color array to be updated
  31282. * @param meshNor the shape normals array
  31283. * @param normals the normals array to be updated
  31284. * @param idx the particle index
  31285. * @param idxInShape the particle index in its shape
  31286. * @param options the addShape() method passed options
  31287. * @model the particle model
  31288. * @hidden
  31289. */
  31290. private _meshBuilder;
  31291. /**
  31292. * Returns a shape Vector3 array from positions float array
  31293. * @param positions float array
  31294. * @returns a vector3 array
  31295. * @hidden
  31296. */
  31297. private _posToShape;
  31298. /**
  31299. * Returns a shapeUV array from a float uvs (array deep copy)
  31300. * @param uvs as a float array
  31301. * @returns a shapeUV array
  31302. * @hidden
  31303. */
  31304. private _uvsToShapeUV;
  31305. /**
  31306. * Adds a new particle object in the particles array
  31307. * @param idx particle index in particles array
  31308. * @param id particle id
  31309. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31310. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31311. * @param model particle ModelShape object
  31312. * @param shapeId model shape identifier
  31313. * @param idxInShape index of the particle in the current model
  31314. * @param bInfo model bounding info object
  31315. * @param storage target storage array, if any
  31316. * @hidden
  31317. */
  31318. private _addParticle;
  31319. /**
  31320. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31321. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31322. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31323. * @param nb (positive integer) the number of particles to be created from this model
  31324. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31325. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31326. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31327. * @returns the number of shapes in the system
  31328. */
  31329. addShape(mesh: Mesh, nb: number, options?: {
  31330. positionFunction?: any;
  31331. vertexFunction?: any;
  31332. storage?: [];
  31333. }): number;
  31334. /**
  31335. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31336. * @hidden
  31337. */
  31338. private _rebuildParticle;
  31339. /**
  31340. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31341. * @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.
  31342. * @returns the SPS.
  31343. */
  31344. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31345. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31346. * Returns an array with the removed particles.
  31347. * 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.
  31348. * The SPS can't be empty so at least one particle needs to remain in place.
  31349. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31350. * @param start index of the first particle to remove
  31351. * @param end index of the last particle to remove (included)
  31352. * @returns an array populated with the removed particles
  31353. */
  31354. removeParticles(start: number, end: number): SolidParticle[];
  31355. /**
  31356. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31357. * @param solidParticleArray an array populated with Solid Particles objects
  31358. * @returns the SPS
  31359. */
  31360. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31361. /**
  31362. * Creates a new particle and modifies the SPS mesh geometry :
  31363. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31364. * - calls _addParticle() to populate the particle array
  31365. * factorized code from addShape() and insertParticlesFromArray()
  31366. * @param idx particle index in the particles array
  31367. * @param i particle index in its shape
  31368. * @param modelShape particle ModelShape object
  31369. * @param shape shape vertex array
  31370. * @param meshInd shape indices array
  31371. * @param meshUV shape uv array
  31372. * @param meshCol shape color array
  31373. * @param meshNor shape normals array
  31374. * @param bbInfo shape bounding info
  31375. * @param storage target particle storage
  31376. * @options addShape() passed options
  31377. * @hidden
  31378. */
  31379. private _insertNewParticle;
  31380. /**
  31381. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31382. * This method calls `updateParticle()` for each particle of the SPS.
  31383. * For an animated SPS, it is usually called within the render loop.
  31384. * 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.
  31385. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31386. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31387. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31388. * @returns the SPS.
  31389. */
  31390. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31391. /**
  31392. * Disposes the SPS.
  31393. */
  31394. dispose(): void;
  31395. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31396. * idx is the particle index in the SPS
  31397. * faceId is the picked face index counted within this particle.
  31398. * Returns null if the pickInfo can't identify a picked particle.
  31399. * @param pickingInfo (PickingInfo object)
  31400. * @returns {idx: number, faceId: number} or null
  31401. */
  31402. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31403. idx: number;
  31404. faceId: number;
  31405. }>;
  31406. /**
  31407. * Returns a SolidParticle object from its identifier : particle.id
  31408. * @param id (integer) the particle Id
  31409. * @returns the searched particle or null if not found in the SPS.
  31410. */
  31411. getParticleById(id: number): Nullable<SolidParticle>;
  31412. /**
  31413. * Returns a new array populated with the particles having the passed shapeId.
  31414. * @param shapeId (integer) the shape identifier
  31415. * @returns a new solid particle array
  31416. */
  31417. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31418. /**
  31419. * Populates the passed array "ref" with the particles having the passed shapeId.
  31420. * @param shapeId the shape identifier
  31421. * @returns the SPS
  31422. * @param ref
  31423. */
  31424. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31425. /**
  31426. * Computes the required SubMeshes according the materials assigned to the particles.
  31427. * @returns the solid particle system.
  31428. * Does nothing if called before the SPS mesh is built.
  31429. */
  31430. computeSubMeshes(): SolidParticleSystem;
  31431. /**
  31432. * Sorts the solid particles by material when MultiMaterial is enabled.
  31433. * Updates the indices32 array.
  31434. * Updates the indicesByMaterial array.
  31435. * Updates the mesh indices array.
  31436. * @returns the SPS
  31437. * @hidden
  31438. */
  31439. private _sortParticlesByMaterial;
  31440. /**
  31441. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31442. * @hidden
  31443. */
  31444. private _setMaterialIndexesById;
  31445. /**
  31446. * Returns an array with unique values of Materials from the passed array
  31447. * @param array the material array to be checked and filtered
  31448. * @hidden
  31449. */
  31450. private _filterUniqueMaterialId;
  31451. /**
  31452. * Sets a new Standard Material as _defaultMaterial if not already set.
  31453. * @hidden
  31454. */
  31455. private _setDefaultMaterial;
  31456. /**
  31457. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31458. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31459. * @returns the SPS.
  31460. */
  31461. refreshVisibleSize(): SolidParticleSystem;
  31462. /**
  31463. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31464. * @param size the size (float) of the visibility box
  31465. * note : this doesn't lock the SPS mesh bounding box.
  31466. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31467. */
  31468. setVisibilityBox(size: number): void;
  31469. /**
  31470. * Gets whether the SPS as always visible or not
  31471. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31472. */
  31473. get isAlwaysVisible(): boolean;
  31474. /**
  31475. * Sets the SPS as always visible or not
  31476. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31477. */
  31478. set isAlwaysVisible(val: boolean);
  31479. /**
  31480. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31481. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31482. */
  31483. set isVisibilityBoxLocked(val: boolean);
  31484. /**
  31485. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31486. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31487. */
  31488. get isVisibilityBoxLocked(): boolean;
  31489. /**
  31490. * Tells to `setParticles()` to compute the particle rotations or not.
  31491. * Default value : true. The SPS is faster when it's set to false.
  31492. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31493. */
  31494. set computeParticleRotation(val: boolean);
  31495. /**
  31496. * Tells to `setParticles()` to compute the particle colors or not.
  31497. * Default value : true. The SPS is faster when it's set to false.
  31498. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31499. */
  31500. set computeParticleColor(val: boolean);
  31501. set computeParticleTexture(val: boolean);
  31502. /**
  31503. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31504. * Default value : false. The SPS is faster when it's set to false.
  31505. * Note : the particle custom vertex positions aren't stored values.
  31506. */
  31507. set computeParticleVertex(val: boolean);
  31508. /**
  31509. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31510. */
  31511. set computeBoundingBox(val: boolean);
  31512. /**
  31513. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31514. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31515. * Default : `true`
  31516. */
  31517. set depthSortParticles(val: boolean);
  31518. /**
  31519. * Gets if `setParticles()` computes the particle rotations or not.
  31520. * Default value : true. The SPS is faster when it's set to false.
  31521. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31522. */
  31523. get computeParticleRotation(): boolean;
  31524. /**
  31525. * Gets if `setParticles()` computes the particle colors or not.
  31526. * Default value : true. The SPS is faster when it's set to false.
  31527. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31528. */
  31529. get computeParticleColor(): boolean;
  31530. /**
  31531. * Gets if `setParticles()` computes the particle textures or not.
  31532. * Default value : true. The SPS is faster when it's set to false.
  31533. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31534. */
  31535. get computeParticleTexture(): boolean;
  31536. /**
  31537. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31538. * Default value : false. The SPS is faster when it's set to false.
  31539. * Note : the particle custom vertex positions aren't stored values.
  31540. */
  31541. get computeParticleVertex(): boolean;
  31542. /**
  31543. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31544. */
  31545. get computeBoundingBox(): boolean;
  31546. /**
  31547. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31548. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31549. * Default : `true`
  31550. */
  31551. get depthSortParticles(): boolean;
  31552. /**
  31553. * Gets if the SPS is created as expandable at construction time.
  31554. * Default : `false`
  31555. */
  31556. get expandable(): boolean;
  31557. /**
  31558. * Gets if the SPS supports the Multi Materials
  31559. */
  31560. get multimaterialEnabled(): boolean;
  31561. /**
  31562. * Gets if the SPS uses the model materials for its own multimaterial.
  31563. */
  31564. get useModelMaterial(): boolean;
  31565. /**
  31566. * The SPS used material array.
  31567. */
  31568. get materials(): Material[];
  31569. /**
  31570. * Sets the SPS MultiMaterial from the passed materials.
  31571. * Note : the passed array is internally copied and not used then by reference.
  31572. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31573. */
  31574. setMultiMaterial(materials: Material[]): void;
  31575. /**
  31576. * The SPS computed multimaterial object
  31577. */
  31578. get multimaterial(): MultiMaterial;
  31579. set multimaterial(mm: MultiMaterial);
  31580. /**
  31581. * If the subMeshes must be updated on the next call to setParticles()
  31582. */
  31583. get autoUpdateSubMeshes(): boolean;
  31584. set autoUpdateSubMeshes(val: boolean);
  31585. /**
  31586. * This function does nothing. It may be overwritten to set all the particle first values.
  31587. * The SPS doesn't call this function, you may have to call it by your own.
  31588. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31589. */
  31590. initParticles(): void;
  31591. /**
  31592. * This function does nothing. It may be overwritten to recycle a particle.
  31593. * The SPS doesn't call this function, you may have to call it by your own.
  31594. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31595. * @param particle The particle to recycle
  31596. * @returns the recycled particle
  31597. */
  31598. recycleParticle(particle: SolidParticle): SolidParticle;
  31599. /**
  31600. * Updates a particle : this function should be overwritten by the user.
  31601. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31602. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31603. * @example : just set a particle position or velocity and recycle conditions
  31604. * @param particle The particle to update
  31605. * @returns the updated particle
  31606. */
  31607. updateParticle(particle: SolidParticle): SolidParticle;
  31608. /**
  31609. * Updates a vertex of a particle : it can be overwritten by the user.
  31610. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31611. * @param particle the current particle
  31612. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31613. * @param pt the index of the current vertex in the particle shape
  31614. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31615. * @example : just set a vertex particle position or color
  31616. * @returns the sps
  31617. */
  31618. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31619. /**
  31620. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31621. * This does nothing and may be overwritten by the user.
  31622. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31623. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31624. * @param update the boolean update value actually passed to setParticles()
  31625. */
  31626. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31627. /**
  31628. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31629. * This will be passed three parameters.
  31630. * This does nothing and may be overwritten by the user.
  31631. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31632. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31633. * @param update the boolean update value actually passed to setParticles()
  31634. */
  31635. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31636. }
  31637. }
  31638. declare module BABYLON {
  31639. /**
  31640. * Represents one particle of a solid particle system.
  31641. */
  31642. export class SolidParticle {
  31643. /**
  31644. * particle global index
  31645. */
  31646. idx: number;
  31647. /**
  31648. * particle identifier
  31649. */
  31650. id: number;
  31651. /**
  31652. * The color of the particle
  31653. */
  31654. color: Nullable<Color4>;
  31655. /**
  31656. * The world space position of the particle.
  31657. */
  31658. position: Vector3;
  31659. /**
  31660. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31661. */
  31662. rotation: Vector3;
  31663. /**
  31664. * The world space rotation quaternion of the particle.
  31665. */
  31666. rotationQuaternion: Nullable<Quaternion>;
  31667. /**
  31668. * The scaling of the particle.
  31669. */
  31670. scaling: Vector3;
  31671. /**
  31672. * The uvs of the particle.
  31673. */
  31674. uvs: Vector4;
  31675. /**
  31676. * The current speed of the particle.
  31677. */
  31678. velocity: Vector3;
  31679. /**
  31680. * The pivot point in the particle local space.
  31681. */
  31682. pivot: Vector3;
  31683. /**
  31684. * Must the particle be translated from its pivot point in its local space ?
  31685. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31686. * Default : false
  31687. */
  31688. translateFromPivot: boolean;
  31689. /**
  31690. * Is the particle active or not ?
  31691. */
  31692. alive: boolean;
  31693. /**
  31694. * Is the particle visible or not ?
  31695. */
  31696. isVisible: boolean;
  31697. /**
  31698. * Index of this particle in the global "positions" array (Internal use)
  31699. * @hidden
  31700. */
  31701. _pos: number;
  31702. /**
  31703. * @hidden Index of this particle in the global "indices" array (Internal use)
  31704. */
  31705. _ind: number;
  31706. /**
  31707. * @hidden ModelShape of this particle (Internal use)
  31708. */
  31709. _model: ModelShape;
  31710. /**
  31711. * ModelShape id of this particle
  31712. */
  31713. shapeId: number;
  31714. /**
  31715. * Index of the particle in its shape id
  31716. */
  31717. idxInShape: number;
  31718. /**
  31719. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31720. */
  31721. _modelBoundingInfo: BoundingInfo;
  31722. /**
  31723. * @hidden Particle BoundingInfo object (Internal use)
  31724. */
  31725. _boundingInfo: BoundingInfo;
  31726. /**
  31727. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31728. */
  31729. _sps: SolidParticleSystem;
  31730. /**
  31731. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31732. */
  31733. _stillInvisible: boolean;
  31734. /**
  31735. * @hidden Last computed particle rotation matrix
  31736. */
  31737. _rotationMatrix: number[];
  31738. /**
  31739. * Parent particle Id, if any.
  31740. * Default null.
  31741. */
  31742. parentId: Nullable<number>;
  31743. /**
  31744. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31745. */
  31746. materialIndex: Nullable<number>;
  31747. /**
  31748. * Custom object or properties.
  31749. */
  31750. props: Nullable<any>;
  31751. /**
  31752. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31753. * The possible values are :
  31754. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31755. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31756. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31757. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31758. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31759. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31760. * */
  31761. cullingStrategy: number;
  31762. /**
  31763. * @hidden Internal global position in the SPS.
  31764. */
  31765. _globalPosition: Vector3;
  31766. /**
  31767. * Creates a Solid Particle object.
  31768. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31769. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31770. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31771. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31772. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31773. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31774. * @param shapeId (integer) is the model shape identifier in the SPS.
  31775. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31776. * @param sps defines the sps it is associated to
  31777. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31778. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31779. */
  31780. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31781. /**
  31782. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31783. * @param target the particle target
  31784. * @returns the current particle
  31785. */
  31786. copyToRef(target: SolidParticle): SolidParticle;
  31787. /**
  31788. * Legacy support, changed scale to scaling
  31789. */
  31790. get scale(): Vector3;
  31791. /**
  31792. * Legacy support, changed scale to scaling
  31793. */
  31794. set scale(scale: Vector3);
  31795. /**
  31796. * Legacy support, changed quaternion to rotationQuaternion
  31797. */
  31798. get quaternion(): Nullable<Quaternion>;
  31799. /**
  31800. * Legacy support, changed quaternion to rotationQuaternion
  31801. */
  31802. set quaternion(q: Nullable<Quaternion>);
  31803. /**
  31804. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31805. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31806. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31807. * @returns true if it intersects
  31808. */
  31809. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31810. /**
  31811. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31812. * A particle is in the frustum if its bounding box intersects the frustum
  31813. * @param frustumPlanes defines the frustum to test
  31814. * @returns true if the particle is in the frustum planes
  31815. */
  31816. isInFrustum(frustumPlanes: Plane[]): boolean;
  31817. /**
  31818. * get the rotation matrix of the particle
  31819. * @hidden
  31820. */
  31821. getRotationMatrix(m: Matrix): void;
  31822. }
  31823. /**
  31824. * Represents the shape of the model used by one particle of a solid particle system.
  31825. * SPS internal tool, don't use it manually.
  31826. */
  31827. export class ModelShape {
  31828. /**
  31829. * The shape id
  31830. * @hidden
  31831. */
  31832. shapeID: number;
  31833. /**
  31834. * flat array of model positions (internal use)
  31835. * @hidden
  31836. */
  31837. _shape: Vector3[];
  31838. /**
  31839. * flat array of model UVs (internal use)
  31840. * @hidden
  31841. */
  31842. _shapeUV: number[];
  31843. /**
  31844. * color array of the model
  31845. * @hidden
  31846. */
  31847. _shapeColors: number[];
  31848. /**
  31849. * indices array of the model
  31850. * @hidden
  31851. */
  31852. _indices: number[];
  31853. /**
  31854. * normals array of the model
  31855. * @hidden
  31856. */
  31857. _normals: number[];
  31858. /**
  31859. * length of the shape in the model indices array (internal use)
  31860. * @hidden
  31861. */
  31862. _indicesLength: number;
  31863. /**
  31864. * Custom position function (internal use)
  31865. * @hidden
  31866. */
  31867. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31868. /**
  31869. * Custom vertex function (internal use)
  31870. * @hidden
  31871. */
  31872. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31873. /**
  31874. * Model material (internal use)
  31875. * @hidden
  31876. */
  31877. _material: Nullable<Material>;
  31878. /**
  31879. * 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.
  31880. * SPS internal tool, don't use it manually.
  31881. * @hidden
  31882. */
  31883. 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>);
  31884. }
  31885. /**
  31886. * Represents a Depth Sorted Particle in the solid particle system.
  31887. * @hidden
  31888. */
  31889. export class DepthSortedParticle {
  31890. /**
  31891. * Particle index
  31892. */
  31893. idx: number;
  31894. /**
  31895. * Index of the particle in the "indices" array
  31896. */
  31897. ind: number;
  31898. /**
  31899. * Length of the particle shape in the "indices" array
  31900. */
  31901. indicesLength: number;
  31902. /**
  31903. * Squared distance from the particle to the camera
  31904. */
  31905. sqDistance: number;
  31906. /**
  31907. * Material index when used with MultiMaterials
  31908. */
  31909. materialIndex: number;
  31910. /**
  31911. * Creates a new sorted particle
  31912. * @param materialIndex
  31913. */
  31914. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31915. }
  31916. /**
  31917. * Represents a solid particle vertex
  31918. */
  31919. export class SolidParticleVertex {
  31920. /**
  31921. * Vertex position
  31922. */
  31923. position: Vector3;
  31924. /**
  31925. * Vertex color
  31926. */
  31927. color: Color4;
  31928. /**
  31929. * Vertex UV
  31930. */
  31931. uv: Vector2;
  31932. /**
  31933. * Creates a new solid particle vertex
  31934. */
  31935. constructor();
  31936. /** Vertex x coordinate */
  31937. get x(): number;
  31938. set x(val: number);
  31939. /** Vertex y coordinate */
  31940. get y(): number;
  31941. set y(val: number);
  31942. /** Vertex z coordinate */
  31943. get z(): number;
  31944. set z(val: number);
  31945. }
  31946. }
  31947. declare module BABYLON {
  31948. /**
  31949. * @hidden
  31950. */
  31951. export class _MeshCollisionData {
  31952. _checkCollisions: boolean;
  31953. _collisionMask: number;
  31954. _collisionGroup: number;
  31955. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31956. _collider: Nullable<Collider>;
  31957. _oldPositionForCollisions: Vector3;
  31958. _diffPositionForCollisions: Vector3;
  31959. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31960. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31961. _collisionResponse: boolean;
  31962. }
  31963. }
  31964. declare module BABYLON {
  31965. /** @hidden */
  31966. class _FacetDataStorage {
  31967. facetPositions: Vector3[];
  31968. facetNormals: Vector3[];
  31969. facetPartitioning: number[][];
  31970. facetNb: number;
  31971. partitioningSubdivisions: number;
  31972. partitioningBBoxRatio: number;
  31973. facetDataEnabled: boolean;
  31974. facetParameters: any;
  31975. bbSize: Vector3;
  31976. subDiv: {
  31977. max: number;
  31978. X: number;
  31979. Y: number;
  31980. Z: number;
  31981. };
  31982. facetDepthSort: boolean;
  31983. facetDepthSortEnabled: boolean;
  31984. depthSortedIndices: IndicesArray;
  31985. depthSortedFacets: {
  31986. ind: number;
  31987. sqDistance: number;
  31988. }[];
  31989. facetDepthSortFunction: (f1: {
  31990. ind: number;
  31991. sqDistance: number;
  31992. }, f2: {
  31993. ind: number;
  31994. sqDistance: number;
  31995. }) => number;
  31996. facetDepthSortFrom: Vector3;
  31997. facetDepthSortOrigin: Vector3;
  31998. invertedMatrix: Matrix;
  31999. }
  32000. /**
  32001. * @hidden
  32002. **/
  32003. class _InternalAbstractMeshDataInfo {
  32004. _hasVertexAlpha: boolean;
  32005. _useVertexColors: boolean;
  32006. _numBoneInfluencers: number;
  32007. _applyFog: boolean;
  32008. _receiveShadows: boolean;
  32009. _facetData: _FacetDataStorage;
  32010. _visibility: number;
  32011. _skeleton: Nullable<Skeleton>;
  32012. _layerMask: number;
  32013. _computeBonesUsingShaders: boolean;
  32014. _isActive: boolean;
  32015. _onlyForInstances: boolean;
  32016. _isActiveIntermediate: boolean;
  32017. _onlyForInstancesIntermediate: boolean;
  32018. _actAsRegularMesh: boolean;
  32019. }
  32020. /**
  32021. * Class used to store all common mesh properties
  32022. */
  32023. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32024. /** No occlusion */
  32025. static OCCLUSION_TYPE_NONE: number;
  32026. /** Occlusion set to optimisitic */
  32027. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32028. /** Occlusion set to strict */
  32029. static OCCLUSION_TYPE_STRICT: number;
  32030. /** Use an accurante occlusion algorithm */
  32031. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32032. /** Use a conservative occlusion algorithm */
  32033. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32034. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32035. * Test order :
  32036. * Is the bounding sphere outside the frustum ?
  32037. * If not, are the bounding box vertices outside the frustum ?
  32038. * It not, then the cullable object is in the frustum.
  32039. */
  32040. static readonly CULLINGSTRATEGY_STANDARD: number;
  32041. /** Culling strategy : Bounding Sphere Only.
  32042. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32043. * It's also less accurate than the standard because some not visible objects can still be selected.
  32044. * Test : is the bounding sphere outside the frustum ?
  32045. * If not, then the cullable object is in the frustum.
  32046. */
  32047. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32048. /** Culling strategy : Optimistic Inclusion.
  32049. * This in an inclusion test first, then the standard exclusion test.
  32050. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32051. * 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.
  32052. * Anyway, it's as accurate as the standard strategy.
  32053. * Test :
  32054. * Is the cullable object bounding sphere center in the frustum ?
  32055. * If not, apply the default culling strategy.
  32056. */
  32057. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32058. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32059. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32060. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32061. * 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.
  32062. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32063. * Test :
  32064. * Is the cullable object bounding sphere center in the frustum ?
  32065. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32066. */
  32067. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32068. /**
  32069. * No billboard
  32070. */
  32071. static get BILLBOARDMODE_NONE(): number;
  32072. /** Billboard on X axis */
  32073. static get BILLBOARDMODE_X(): number;
  32074. /** Billboard on Y axis */
  32075. static get BILLBOARDMODE_Y(): number;
  32076. /** Billboard on Z axis */
  32077. static get BILLBOARDMODE_Z(): number;
  32078. /** Billboard on all axes */
  32079. static get BILLBOARDMODE_ALL(): number;
  32080. /** Billboard on using position instead of orientation */
  32081. static get BILLBOARDMODE_USE_POSITION(): number;
  32082. /** @hidden */
  32083. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32084. /**
  32085. * The culling strategy to use to check whether the mesh must be rendered or not.
  32086. * This value can be changed at any time and will be used on the next render mesh selection.
  32087. * The possible values are :
  32088. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32089. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32090. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32091. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32092. * Please read each static variable documentation to get details about the culling process.
  32093. * */
  32094. cullingStrategy: number;
  32095. /**
  32096. * Gets the number of facets in the mesh
  32097. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32098. */
  32099. get facetNb(): number;
  32100. /**
  32101. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32102. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32103. */
  32104. get partitioningSubdivisions(): number;
  32105. set partitioningSubdivisions(nb: number);
  32106. /**
  32107. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32108. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32109. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32110. */
  32111. get partitioningBBoxRatio(): number;
  32112. set partitioningBBoxRatio(ratio: number);
  32113. /**
  32114. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32115. * Works only for updatable meshes.
  32116. * Doesn't work with multi-materials
  32117. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32118. */
  32119. get mustDepthSortFacets(): boolean;
  32120. set mustDepthSortFacets(sort: boolean);
  32121. /**
  32122. * The location (Vector3) where the facet depth sort must be computed from.
  32123. * By default, the active camera position.
  32124. * Used only when facet depth sort is enabled
  32125. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32126. */
  32127. get facetDepthSortFrom(): Vector3;
  32128. set facetDepthSortFrom(location: Vector3);
  32129. /**
  32130. * gets a boolean indicating if facetData is enabled
  32131. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32132. */
  32133. get isFacetDataEnabled(): boolean;
  32134. /** @hidden */
  32135. _updateNonUniformScalingState(value: boolean): boolean;
  32136. /**
  32137. * An event triggered when this mesh collides with another one
  32138. */
  32139. onCollideObservable: Observable<AbstractMesh>;
  32140. /** Set a function to call when this mesh collides with another one */
  32141. set onCollide(callback: () => void);
  32142. /**
  32143. * An event triggered when the collision's position changes
  32144. */
  32145. onCollisionPositionChangeObservable: Observable<Vector3>;
  32146. /** Set a function to call when the collision's position changes */
  32147. set onCollisionPositionChange(callback: () => void);
  32148. /**
  32149. * An event triggered when material is changed
  32150. */
  32151. onMaterialChangedObservable: Observable<AbstractMesh>;
  32152. /**
  32153. * Gets or sets the orientation for POV movement & rotation
  32154. */
  32155. definedFacingForward: boolean;
  32156. /** @hidden */
  32157. _occlusionQuery: Nullable<WebGLQuery>;
  32158. /** @hidden */
  32159. _renderingGroup: Nullable<RenderingGroup>;
  32160. /**
  32161. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32162. */
  32163. get visibility(): number;
  32164. /**
  32165. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32166. */
  32167. set visibility(value: number);
  32168. /** Gets or sets the alpha index used to sort transparent meshes
  32169. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32170. */
  32171. alphaIndex: number;
  32172. /**
  32173. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32174. */
  32175. isVisible: boolean;
  32176. /**
  32177. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32178. */
  32179. isPickable: boolean;
  32180. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32181. showSubMeshesBoundingBox: boolean;
  32182. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32183. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32184. */
  32185. isBlocker: boolean;
  32186. /**
  32187. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32188. */
  32189. enablePointerMoveEvents: boolean;
  32190. private _renderingGroupId;
  32191. /**
  32192. * Specifies the rendering group id for this mesh (0 by default)
  32193. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32194. */
  32195. get renderingGroupId(): number;
  32196. set renderingGroupId(value: number);
  32197. private _material;
  32198. /** Gets or sets current material */
  32199. get material(): Nullable<Material>;
  32200. set material(value: Nullable<Material>);
  32201. /**
  32202. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32203. * @see https://doc.babylonjs.com/babylon101/shadows
  32204. */
  32205. get receiveShadows(): boolean;
  32206. set receiveShadows(value: boolean);
  32207. /** Defines color to use when rendering outline */
  32208. outlineColor: Color3;
  32209. /** Define width to use when rendering outline */
  32210. outlineWidth: number;
  32211. /** Defines color to use when rendering overlay */
  32212. overlayColor: Color3;
  32213. /** Defines alpha to use when rendering overlay */
  32214. overlayAlpha: number;
  32215. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32216. get hasVertexAlpha(): boolean;
  32217. set hasVertexAlpha(value: boolean);
  32218. /** 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) */
  32219. get useVertexColors(): boolean;
  32220. set useVertexColors(value: boolean);
  32221. /**
  32222. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32223. */
  32224. get computeBonesUsingShaders(): boolean;
  32225. set computeBonesUsingShaders(value: boolean);
  32226. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32227. get numBoneInfluencers(): number;
  32228. set numBoneInfluencers(value: number);
  32229. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32230. get applyFog(): boolean;
  32231. set applyFog(value: boolean);
  32232. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32233. useOctreeForRenderingSelection: boolean;
  32234. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32235. useOctreeForPicking: boolean;
  32236. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32237. useOctreeForCollisions: boolean;
  32238. /**
  32239. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32240. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32241. */
  32242. get layerMask(): number;
  32243. set layerMask(value: number);
  32244. /**
  32245. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32246. */
  32247. alwaysSelectAsActiveMesh: boolean;
  32248. /**
  32249. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32250. */
  32251. doNotSyncBoundingInfo: boolean;
  32252. /**
  32253. * Gets or sets the current action manager
  32254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32255. */
  32256. actionManager: Nullable<AbstractActionManager>;
  32257. private _meshCollisionData;
  32258. /**
  32259. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32260. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32261. */
  32262. ellipsoid: Vector3;
  32263. /**
  32264. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32265. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32266. */
  32267. ellipsoidOffset: Vector3;
  32268. /**
  32269. * Gets or sets a collision mask used to mask collisions (default is -1).
  32270. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32271. */
  32272. get collisionMask(): number;
  32273. set collisionMask(mask: number);
  32274. /**
  32275. * Gets or sets a collision response flag (default is true).
  32276. * when collisionResponse is false, events are still triggered but colliding entity has no response
  32277. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  32278. * to respond to the collision.
  32279. */
  32280. get collisionResponse(): boolean;
  32281. set collisionResponse(response: boolean);
  32282. /**
  32283. * Gets or sets the current collision group mask (-1 by default).
  32284. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32285. */
  32286. get collisionGroup(): number;
  32287. set collisionGroup(mask: number);
  32288. /**
  32289. * Gets or sets current surrounding meshes (null by default).
  32290. *
  32291. * By default collision detection is tested against every mesh in the scene.
  32292. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32293. * meshes will be tested for the collision.
  32294. *
  32295. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32296. */
  32297. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32298. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32299. /**
  32300. * Defines edge width used when edgesRenderer is enabled
  32301. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32302. */
  32303. edgesWidth: number;
  32304. /**
  32305. * Defines edge color used when edgesRenderer is enabled
  32306. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32307. */
  32308. edgesColor: Color4;
  32309. /** @hidden */
  32310. _edgesRenderer: Nullable<IEdgesRenderer>;
  32311. /** @hidden */
  32312. _masterMesh: Nullable<AbstractMesh>;
  32313. /** @hidden */
  32314. _boundingInfo: Nullable<BoundingInfo>;
  32315. /** @hidden */
  32316. _renderId: number;
  32317. /**
  32318. * Gets or sets the list of subMeshes
  32319. * @see https://doc.babylonjs.com/how_to/multi_materials
  32320. */
  32321. subMeshes: SubMesh[];
  32322. /** @hidden */
  32323. _intersectionsInProgress: AbstractMesh[];
  32324. /** @hidden */
  32325. _unIndexed: boolean;
  32326. /** @hidden */
  32327. _lightSources: Light[];
  32328. /** Gets the list of lights affecting that mesh */
  32329. get lightSources(): Light[];
  32330. /** @hidden */
  32331. get _positions(): Nullable<Vector3[]>;
  32332. /** @hidden */
  32333. _waitingData: {
  32334. lods: Nullable<any>;
  32335. actions: Nullable<any>;
  32336. freezeWorldMatrix: Nullable<boolean>;
  32337. };
  32338. /** @hidden */
  32339. _bonesTransformMatrices: Nullable<Float32Array>;
  32340. /** @hidden */
  32341. _transformMatrixTexture: Nullable<RawTexture>;
  32342. /**
  32343. * Gets or sets a skeleton to apply skining transformations
  32344. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32345. */
  32346. set skeleton(value: Nullable<Skeleton>);
  32347. get skeleton(): Nullable<Skeleton>;
  32348. /**
  32349. * An event triggered when the mesh is rebuilt.
  32350. */
  32351. onRebuildObservable: Observable<AbstractMesh>;
  32352. /**
  32353. * Creates a new AbstractMesh
  32354. * @param name defines the name of the mesh
  32355. * @param scene defines the hosting scene
  32356. */
  32357. constructor(name: string, scene?: Nullable<Scene>);
  32358. /**
  32359. * Returns the string "AbstractMesh"
  32360. * @returns "AbstractMesh"
  32361. */
  32362. getClassName(): string;
  32363. /**
  32364. * Gets a string representation of the current mesh
  32365. * @param fullDetails defines a boolean indicating if full details must be included
  32366. * @returns a string representation of the current mesh
  32367. */
  32368. toString(fullDetails?: boolean): string;
  32369. /**
  32370. * @hidden
  32371. */
  32372. protected _getEffectiveParent(): Nullable<Node>;
  32373. /** @hidden */
  32374. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32375. /** @hidden */
  32376. _rebuild(): void;
  32377. /** @hidden */
  32378. _resyncLightSources(): void;
  32379. /** @hidden */
  32380. _resyncLightSource(light: Light): void;
  32381. /** @hidden */
  32382. _unBindEffect(): void;
  32383. /** @hidden */
  32384. _removeLightSource(light: Light, dispose: boolean): void;
  32385. private _markSubMeshesAsDirty;
  32386. /** @hidden */
  32387. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32388. /** @hidden */
  32389. _markSubMeshesAsAttributesDirty(): void;
  32390. /** @hidden */
  32391. _markSubMeshesAsMiscDirty(): void;
  32392. /**
  32393. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32394. */
  32395. get scaling(): Vector3;
  32396. set scaling(newScaling: Vector3);
  32397. /**
  32398. * Returns true if the mesh is blocked. Implemented by child classes
  32399. */
  32400. get isBlocked(): boolean;
  32401. /**
  32402. * Returns the mesh itself by default. Implemented by child classes
  32403. * @param camera defines the camera to use to pick the right LOD level
  32404. * @returns the currentAbstractMesh
  32405. */
  32406. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32407. /**
  32408. * Returns 0 by default. Implemented by child classes
  32409. * @returns an integer
  32410. */
  32411. getTotalVertices(): number;
  32412. /**
  32413. * Returns a positive integer : the total number of indices in this mesh geometry.
  32414. * @returns the numner of indices or zero if the mesh has no geometry.
  32415. */
  32416. getTotalIndices(): number;
  32417. /**
  32418. * Returns null by default. Implemented by child classes
  32419. * @returns null
  32420. */
  32421. getIndices(): Nullable<IndicesArray>;
  32422. /**
  32423. * Returns the array of the requested vertex data kind. Implemented by child classes
  32424. * @param kind defines the vertex data kind to use
  32425. * @returns null
  32426. */
  32427. getVerticesData(kind: string): Nullable<FloatArray>;
  32428. /**
  32429. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32430. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32431. * Note that a new underlying VertexBuffer object is created each call.
  32432. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32433. * @param kind defines vertex data kind:
  32434. * * VertexBuffer.PositionKind
  32435. * * VertexBuffer.UVKind
  32436. * * VertexBuffer.UV2Kind
  32437. * * VertexBuffer.UV3Kind
  32438. * * VertexBuffer.UV4Kind
  32439. * * VertexBuffer.UV5Kind
  32440. * * VertexBuffer.UV6Kind
  32441. * * VertexBuffer.ColorKind
  32442. * * VertexBuffer.MatricesIndicesKind
  32443. * * VertexBuffer.MatricesIndicesExtraKind
  32444. * * VertexBuffer.MatricesWeightsKind
  32445. * * VertexBuffer.MatricesWeightsExtraKind
  32446. * @param data defines the data source
  32447. * @param updatable defines if the data must be flagged as updatable (or static)
  32448. * @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
  32449. * @returns the current mesh
  32450. */
  32451. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32452. /**
  32453. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32454. * If the mesh has no geometry, it is simply returned as it is.
  32455. * @param kind defines vertex data kind:
  32456. * * VertexBuffer.PositionKind
  32457. * * VertexBuffer.UVKind
  32458. * * VertexBuffer.UV2Kind
  32459. * * VertexBuffer.UV3Kind
  32460. * * VertexBuffer.UV4Kind
  32461. * * VertexBuffer.UV5Kind
  32462. * * VertexBuffer.UV6Kind
  32463. * * VertexBuffer.ColorKind
  32464. * * VertexBuffer.MatricesIndicesKind
  32465. * * VertexBuffer.MatricesIndicesExtraKind
  32466. * * VertexBuffer.MatricesWeightsKind
  32467. * * VertexBuffer.MatricesWeightsExtraKind
  32468. * @param data defines the data source
  32469. * @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
  32470. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32471. * @returns the current mesh
  32472. */
  32473. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32474. /**
  32475. * Sets the mesh indices,
  32476. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32477. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32478. * @param totalVertices Defines the total number of vertices
  32479. * @returns the current mesh
  32480. */
  32481. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32482. /**
  32483. * Gets a boolean indicating if specific vertex data is present
  32484. * @param kind defines the vertex data kind to use
  32485. * @returns true is data kind is present
  32486. */
  32487. isVerticesDataPresent(kind: string): boolean;
  32488. /**
  32489. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32490. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32491. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32492. * @returns a BoundingInfo
  32493. */
  32494. getBoundingInfo(): BoundingInfo;
  32495. /**
  32496. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32497. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32498. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32499. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32500. * @returns the current mesh
  32501. */
  32502. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32503. /**
  32504. * Overwrite the current bounding info
  32505. * @param boundingInfo defines the new bounding info
  32506. * @returns the current mesh
  32507. */
  32508. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32509. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32510. get useBones(): boolean;
  32511. /** @hidden */
  32512. _preActivate(): void;
  32513. /** @hidden */
  32514. _preActivateForIntermediateRendering(renderId: number): void;
  32515. /** @hidden */
  32516. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32517. /** @hidden */
  32518. _postActivate(): void;
  32519. /** @hidden */
  32520. _freeze(): void;
  32521. /** @hidden */
  32522. _unFreeze(): void;
  32523. /**
  32524. * Gets the current world matrix
  32525. * @returns a Matrix
  32526. */
  32527. getWorldMatrix(): Matrix;
  32528. /** @hidden */
  32529. _getWorldMatrixDeterminant(): number;
  32530. /**
  32531. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32532. */
  32533. get isAnInstance(): boolean;
  32534. /**
  32535. * Gets a boolean indicating if this mesh has instances
  32536. */
  32537. get hasInstances(): boolean;
  32538. /**
  32539. * Gets a boolean indicating if this mesh has thin instances
  32540. */
  32541. get hasThinInstances(): boolean;
  32542. /**
  32543. * Perform relative position change from the point of view of behind the front of the mesh.
  32544. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32545. * Supports definition of mesh facing forward or backward
  32546. * @param amountRight defines the distance on the right axis
  32547. * @param amountUp defines the distance on the up axis
  32548. * @param amountForward defines the distance on the forward axis
  32549. * @returns the current mesh
  32550. */
  32551. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32552. /**
  32553. * Calculate relative position change from the point of view of behind the front of the mesh.
  32554. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32555. * Supports definition of mesh facing forward or backward
  32556. * @param amountRight defines the distance on the right axis
  32557. * @param amountUp defines the distance on the up axis
  32558. * @param amountForward defines the distance on the forward axis
  32559. * @returns the new displacement vector
  32560. */
  32561. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32562. /**
  32563. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32564. * Supports definition of mesh facing forward or backward
  32565. * @param flipBack defines the flip
  32566. * @param twirlClockwise defines the twirl
  32567. * @param tiltRight defines the tilt
  32568. * @returns the current mesh
  32569. */
  32570. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32571. /**
  32572. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32573. * Supports definition of mesh facing forward or backward.
  32574. * @param flipBack defines the flip
  32575. * @param twirlClockwise defines the twirl
  32576. * @param tiltRight defines the tilt
  32577. * @returns the new rotation vector
  32578. */
  32579. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32580. /**
  32581. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32582. * This means the mesh underlying bounding box and sphere are recomputed.
  32583. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32584. * @returns the current mesh
  32585. */
  32586. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32587. /** @hidden */
  32588. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32589. /** @hidden */
  32590. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32591. /** @hidden */
  32592. _updateBoundingInfo(): AbstractMesh;
  32593. /** @hidden */
  32594. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32595. /** @hidden */
  32596. protected _afterComputeWorldMatrix(): void;
  32597. /** @hidden */
  32598. get _effectiveMesh(): AbstractMesh;
  32599. /**
  32600. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32601. * A mesh is in the frustum if its bounding box intersects the frustum
  32602. * @param frustumPlanes defines the frustum to test
  32603. * @returns true if the mesh is in the frustum planes
  32604. */
  32605. isInFrustum(frustumPlanes: Plane[]): boolean;
  32606. /**
  32607. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32608. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32609. * @param frustumPlanes defines the frustum to test
  32610. * @returns true if the mesh is completely in the frustum planes
  32611. */
  32612. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32613. /**
  32614. * True if the mesh intersects another mesh or a SolidParticle object
  32615. * @param mesh defines a target mesh or SolidParticle to test
  32616. * @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)
  32617. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32618. * @returns true if there is an intersection
  32619. */
  32620. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32621. /**
  32622. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32623. * @param point defines the point to test
  32624. * @returns true if there is an intersection
  32625. */
  32626. intersectsPoint(point: Vector3): boolean;
  32627. /**
  32628. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32629. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32630. */
  32631. get checkCollisions(): boolean;
  32632. set checkCollisions(collisionEnabled: boolean);
  32633. /**
  32634. * Gets Collider object used to compute collisions (not physics)
  32635. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32636. */
  32637. get collider(): Nullable<Collider>;
  32638. /**
  32639. * Move the mesh using collision engine
  32640. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32641. * @param displacement defines the requested displacement vector
  32642. * @returns the current mesh
  32643. */
  32644. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32645. private _onCollisionPositionChange;
  32646. /** @hidden */
  32647. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32648. /** @hidden */
  32649. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32650. /** @hidden */
  32651. _checkCollision(collider: Collider): AbstractMesh;
  32652. /** @hidden */
  32653. _generatePointsArray(): boolean;
  32654. /**
  32655. * Checks if the passed Ray intersects with the mesh
  32656. * @param ray defines the ray to use
  32657. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32658. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32659. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32660. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32661. * @returns the picking info
  32662. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32663. */
  32664. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32665. /**
  32666. * Clones the current mesh
  32667. * @param name defines the mesh name
  32668. * @param newParent defines the new mesh parent
  32669. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32670. * @returns the new mesh
  32671. */
  32672. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32673. /**
  32674. * Disposes all the submeshes of the current meshnp
  32675. * @returns the current mesh
  32676. */
  32677. releaseSubMeshes(): AbstractMesh;
  32678. /**
  32679. * Releases resources associated with this abstract mesh.
  32680. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32681. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32682. */
  32683. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32684. /**
  32685. * Adds the passed mesh as a child to the current mesh
  32686. * @param mesh defines the child mesh
  32687. * @returns the current mesh
  32688. */
  32689. addChild(mesh: AbstractMesh): AbstractMesh;
  32690. /**
  32691. * Removes the passed mesh from the current mesh children list
  32692. * @param mesh defines the child mesh
  32693. * @returns the current mesh
  32694. */
  32695. removeChild(mesh: AbstractMesh): AbstractMesh;
  32696. /** @hidden */
  32697. private _initFacetData;
  32698. /**
  32699. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32700. * This method can be called within the render loop.
  32701. * 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
  32702. * @returns the current mesh
  32703. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32704. */
  32705. updateFacetData(): AbstractMesh;
  32706. /**
  32707. * Returns the facetLocalNormals array.
  32708. * The normals are expressed in the mesh local spac
  32709. * @returns an array of Vector3
  32710. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32711. */
  32712. getFacetLocalNormals(): Vector3[];
  32713. /**
  32714. * Returns the facetLocalPositions array.
  32715. * The facet positions are expressed in the mesh local space
  32716. * @returns an array of Vector3
  32717. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32718. */
  32719. getFacetLocalPositions(): Vector3[];
  32720. /**
  32721. * Returns the facetLocalPartioning array
  32722. * @returns an array of array of numbers
  32723. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32724. */
  32725. getFacetLocalPartitioning(): number[][];
  32726. /**
  32727. * Returns the i-th facet position in the world system.
  32728. * This method allocates a new Vector3 per call
  32729. * @param i defines the facet index
  32730. * @returns a new Vector3
  32731. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32732. */
  32733. getFacetPosition(i: number): Vector3;
  32734. /**
  32735. * Sets the reference Vector3 with the i-th facet position in the world system
  32736. * @param i defines the facet index
  32737. * @param ref defines the target vector
  32738. * @returns the current mesh
  32739. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32740. */
  32741. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32742. /**
  32743. * Returns the i-th facet normal in the world system.
  32744. * This method allocates a new Vector3 per call
  32745. * @param i defines the facet index
  32746. * @returns a new Vector3
  32747. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32748. */
  32749. getFacetNormal(i: number): Vector3;
  32750. /**
  32751. * Sets the reference Vector3 with the i-th facet normal in the world system
  32752. * @param i defines the facet index
  32753. * @param ref defines the target vector
  32754. * @returns the current mesh
  32755. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32756. */
  32757. getFacetNormalToRef(i: number, ref: Vector3): this;
  32758. /**
  32759. * 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)
  32760. * @param x defines x coordinate
  32761. * @param y defines y coordinate
  32762. * @param z defines z coordinate
  32763. * @returns the array of facet indexes
  32764. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32765. */
  32766. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32767. /**
  32768. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32769. * @param projected sets as the (x,y,z) world projection on the facet
  32770. * @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
  32771. * @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
  32772. * @param x defines x coordinate
  32773. * @param y defines y coordinate
  32774. * @param z defines z coordinate
  32775. * @returns the face index if found (or null instead)
  32776. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32777. */
  32778. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32779. /**
  32780. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32781. * @param projected sets as the (x,y,z) local projection on the facet
  32782. * @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
  32783. * @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
  32784. * @param x defines x coordinate
  32785. * @param y defines y coordinate
  32786. * @param z defines z coordinate
  32787. * @returns the face index if found (or null instead)
  32788. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32789. */
  32790. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32791. /**
  32792. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32793. * @returns the parameters
  32794. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32795. */
  32796. getFacetDataParameters(): any;
  32797. /**
  32798. * Disables the feature FacetData and frees the related memory
  32799. * @returns the current mesh
  32800. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32801. */
  32802. disableFacetData(): AbstractMesh;
  32803. /**
  32804. * Updates the AbstractMesh indices array
  32805. * @param indices defines the data source
  32806. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32807. * @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)
  32808. * @returns the current mesh
  32809. */
  32810. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32811. /**
  32812. * Creates new normals data for the mesh
  32813. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32814. * @returns the current mesh
  32815. */
  32816. createNormals(updatable: boolean): AbstractMesh;
  32817. /**
  32818. * Align the mesh with a normal
  32819. * @param normal defines the normal to use
  32820. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32821. * @returns the current mesh
  32822. */
  32823. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32824. /** @hidden */
  32825. _checkOcclusionQuery(): boolean;
  32826. /**
  32827. * Disables the mesh edge rendering mode
  32828. * @returns the currentAbstractMesh
  32829. */
  32830. disableEdgesRendering(): AbstractMesh;
  32831. /**
  32832. * Enables the edge rendering mode on the mesh.
  32833. * This mode makes the mesh edges visible
  32834. * @param epsilon defines the maximal distance between two angles to detect a face
  32835. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32836. * @returns the currentAbstractMesh
  32837. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32838. */
  32839. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32840. /**
  32841. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32842. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32843. */
  32844. getConnectedParticleSystems(): IParticleSystem[];
  32845. }
  32846. }
  32847. declare module BABYLON {
  32848. /**
  32849. * Interface used to define ActionEvent
  32850. */
  32851. export interface IActionEvent {
  32852. /** The mesh or sprite that triggered the action */
  32853. source: any;
  32854. /** The X mouse cursor position at the time of the event */
  32855. pointerX: number;
  32856. /** The Y mouse cursor position at the time of the event */
  32857. pointerY: number;
  32858. /** The mesh that is currently pointed at (can be null) */
  32859. meshUnderPointer: Nullable<AbstractMesh>;
  32860. /** the original (browser) event that triggered the ActionEvent */
  32861. sourceEvent?: any;
  32862. /** additional data for the event */
  32863. additionalData?: any;
  32864. }
  32865. /**
  32866. * ActionEvent is the event being sent when an action is triggered.
  32867. */
  32868. export class ActionEvent implements IActionEvent {
  32869. /** The mesh or sprite that triggered the action */
  32870. source: any;
  32871. /** The X mouse cursor position at the time of the event */
  32872. pointerX: number;
  32873. /** The Y mouse cursor position at the time of the event */
  32874. pointerY: number;
  32875. /** The mesh that is currently pointed at (can be null) */
  32876. meshUnderPointer: Nullable<AbstractMesh>;
  32877. /** the original (browser) event that triggered the ActionEvent */
  32878. sourceEvent?: any;
  32879. /** additional data for the event */
  32880. additionalData?: any;
  32881. /**
  32882. * Creates a new ActionEvent
  32883. * @param source The mesh or sprite that triggered the action
  32884. * @param pointerX The X mouse cursor position at the time of the event
  32885. * @param pointerY The Y mouse cursor position at the time of the event
  32886. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32887. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32888. * @param additionalData additional data for the event
  32889. */
  32890. constructor(
  32891. /** The mesh or sprite that triggered the action */
  32892. source: any,
  32893. /** The X mouse cursor position at the time of the event */
  32894. pointerX: number,
  32895. /** The Y mouse cursor position at the time of the event */
  32896. pointerY: number,
  32897. /** The mesh that is currently pointed at (can be null) */
  32898. meshUnderPointer: Nullable<AbstractMesh>,
  32899. /** the original (browser) event that triggered the ActionEvent */
  32900. sourceEvent?: any,
  32901. /** additional data for the event */
  32902. additionalData?: any);
  32903. /**
  32904. * Helper function to auto-create an ActionEvent from a source mesh.
  32905. * @param source The source mesh that triggered the event
  32906. * @param evt The original (browser) event
  32907. * @param additionalData additional data for the event
  32908. * @returns the new ActionEvent
  32909. */
  32910. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32911. /**
  32912. * Helper function to auto-create an ActionEvent from a source sprite
  32913. * @param source The source sprite that triggered the event
  32914. * @param scene Scene associated with the sprite
  32915. * @param evt The original (browser) event
  32916. * @param additionalData additional data for the event
  32917. * @returns the new ActionEvent
  32918. */
  32919. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32920. /**
  32921. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32922. * @param scene the scene where the event occurred
  32923. * @param evt The original (browser) event
  32924. * @returns the new ActionEvent
  32925. */
  32926. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32927. /**
  32928. * Helper function to auto-create an ActionEvent from a primitive
  32929. * @param prim defines the target primitive
  32930. * @param pointerPos defines the pointer position
  32931. * @param evt The original (browser) event
  32932. * @param additionalData additional data for the event
  32933. * @returns the new ActionEvent
  32934. */
  32935. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32936. }
  32937. }
  32938. declare module BABYLON {
  32939. /**
  32940. * Abstract class used to decouple action Manager from scene and meshes.
  32941. * Do not instantiate.
  32942. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32943. */
  32944. export abstract class AbstractActionManager implements IDisposable {
  32945. /** Gets the list of active triggers */
  32946. static Triggers: {
  32947. [key: string]: number;
  32948. };
  32949. /** Gets the cursor to use when hovering items */
  32950. hoverCursor: string;
  32951. /** Gets the list of actions */
  32952. actions: IAction[];
  32953. /**
  32954. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32955. */
  32956. isRecursive: boolean;
  32957. /**
  32958. * Releases all associated resources
  32959. */
  32960. abstract dispose(): void;
  32961. /**
  32962. * Does this action manager has pointer triggers
  32963. */
  32964. abstract get hasPointerTriggers(): boolean;
  32965. /**
  32966. * Does this action manager has pick triggers
  32967. */
  32968. abstract get hasPickTriggers(): boolean;
  32969. /**
  32970. * Process a specific trigger
  32971. * @param trigger defines the trigger to process
  32972. * @param evt defines the event details to be processed
  32973. */
  32974. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32975. /**
  32976. * Does this action manager handles actions of any of the given triggers
  32977. * @param triggers defines the triggers to be tested
  32978. * @return a boolean indicating whether one (or more) of the triggers is handled
  32979. */
  32980. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32981. /**
  32982. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32983. * speed.
  32984. * @param triggerA defines the trigger to be tested
  32985. * @param triggerB defines the trigger to be tested
  32986. * @return a boolean indicating whether one (or more) of the triggers is handled
  32987. */
  32988. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32989. /**
  32990. * Does this action manager handles actions of a given trigger
  32991. * @param trigger defines the trigger to be tested
  32992. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32993. * @return whether the trigger is handled
  32994. */
  32995. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32996. /**
  32997. * Serialize this manager to a JSON object
  32998. * @param name defines the property name to store this manager
  32999. * @returns a JSON representation of this manager
  33000. */
  33001. abstract serialize(name: string): any;
  33002. /**
  33003. * Registers an action to this action manager
  33004. * @param action defines the action to be registered
  33005. * @return the action amended (prepared) after registration
  33006. */
  33007. abstract registerAction(action: IAction): Nullable<IAction>;
  33008. /**
  33009. * Unregisters an action to this action manager
  33010. * @param action defines the action to be unregistered
  33011. * @return a boolean indicating whether the action has been unregistered
  33012. */
  33013. abstract unregisterAction(action: IAction): Boolean;
  33014. /**
  33015. * Does exist one action manager with at least one trigger
  33016. **/
  33017. static get HasTriggers(): boolean;
  33018. /**
  33019. * Does exist one action manager with at least one pick trigger
  33020. **/
  33021. static get HasPickTriggers(): boolean;
  33022. /**
  33023. * Does exist one action manager that handles actions of a given trigger
  33024. * @param trigger defines the trigger to be tested
  33025. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33026. **/
  33027. static HasSpecificTrigger(trigger: number): boolean;
  33028. }
  33029. }
  33030. declare module BABYLON {
  33031. /**
  33032. * Defines how a node can be built from a string name.
  33033. */
  33034. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33035. /**
  33036. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33037. */
  33038. export class Node implements IBehaviorAware<Node> {
  33039. /** @hidden */
  33040. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33041. private static _NodeConstructors;
  33042. /**
  33043. * Add a new node constructor
  33044. * @param type defines the type name of the node to construct
  33045. * @param constructorFunc defines the constructor function
  33046. */
  33047. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33048. /**
  33049. * Returns a node constructor based on type name
  33050. * @param type defines the type name
  33051. * @param name defines the new node name
  33052. * @param scene defines the hosting scene
  33053. * @param options defines optional options to transmit to constructors
  33054. * @returns the new constructor or null
  33055. */
  33056. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33057. /**
  33058. * Gets or sets the name of the node
  33059. */
  33060. name: string;
  33061. /**
  33062. * Gets or sets the id of the node
  33063. */
  33064. id: string;
  33065. /**
  33066. * Gets or sets the unique id of the node
  33067. */
  33068. uniqueId: number;
  33069. /**
  33070. * Gets or sets a string used to store user defined state for the node
  33071. */
  33072. state: string;
  33073. /**
  33074. * Gets or sets an object used to store user defined information for the node
  33075. */
  33076. metadata: any;
  33077. /**
  33078. * For internal use only. Please do not use.
  33079. */
  33080. reservedDataStore: any;
  33081. /**
  33082. * List of inspectable custom properties (used by the Inspector)
  33083. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33084. */
  33085. inspectableCustomProperties: IInspectable[];
  33086. private _doNotSerialize;
  33087. /**
  33088. * Gets or sets a boolean used to define if the node must be serialized
  33089. */
  33090. get doNotSerialize(): boolean;
  33091. set doNotSerialize(value: boolean);
  33092. /** @hidden */
  33093. _isDisposed: boolean;
  33094. /**
  33095. * Gets a list of Animations associated with the node
  33096. */
  33097. animations: Animation[];
  33098. protected _ranges: {
  33099. [name: string]: Nullable<AnimationRange>;
  33100. };
  33101. /**
  33102. * Callback raised when the node is ready to be used
  33103. */
  33104. onReady: Nullable<(node: Node) => void>;
  33105. private _isEnabled;
  33106. private _isParentEnabled;
  33107. private _isReady;
  33108. /** @hidden */
  33109. _currentRenderId: number;
  33110. private _parentUpdateId;
  33111. /** @hidden */
  33112. _childUpdateId: number;
  33113. /** @hidden */
  33114. _waitingParentId: Nullable<string>;
  33115. /** @hidden */
  33116. _scene: Scene;
  33117. /** @hidden */
  33118. _cache: any;
  33119. private _parentNode;
  33120. private _children;
  33121. /** @hidden */
  33122. _worldMatrix: Matrix;
  33123. /** @hidden */
  33124. _worldMatrixDeterminant: number;
  33125. /** @hidden */
  33126. _worldMatrixDeterminantIsDirty: boolean;
  33127. /** @hidden */
  33128. private _sceneRootNodesIndex;
  33129. /**
  33130. * Gets a boolean indicating if the node has been disposed
  33131. * @returns true if the node was disposed
  33132. */
  33133. isDisposed(): boolean;
  33134. /**
  33135. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33136. * @see https://doc.babylonjs.com/how_to/parenting
  33137. */
  33138. set parent(parent: Nullable<Node>);
  33139. get parent(): Nullable<Node>;
  33140. /** @hidden */
  33141. _addToSceneRootNodes(): void;
  33142. /** @hidden */
  33143. _removeFromSceneRootNodes(): void;
  33144. private _animationPropertiesOverride;
  33145. /**
  33146. * Gets or sets the animation properties override
  33147. */
  33148. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33149. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33150. /**
  33151. * Gets a string identifying the name of the class
  33152. * @returns "Node" string
  33153. */
  33154. getClassName(): string;
  33155. /** @hidden */
  33156. readonly _isNode: boolean;
  33157. /**
  33158. * An event triggered when the mesh is disposed
  33159. */
  33160. onDisposeObservable: Observable<Node>;
  33161. private _onDisposeObserver;
  33162. /**
  33163. * Sets a callback that will be raised when the node will be disposed
  33164. */
  33165. set onDispose(callback: () => void);
  33166. /**
  33167. * Creates a new Node
  33168. * @param name the name and id to be given to this node
  33169. * @param scene the scene this node will be added to
  33170. */
  33171. constructor(name: string, scene?: Nullable<Scene>);
  33172. /**
  33173. * Gets the scene of the node
  33174. * @returns a scene
  33175. */
  33176. getScene(): Scene;
  33177. /**
  33178. * Gets the engine of the node
  33179. * @returns a Engine
  33180. */
  33181. getEngine(): Engine;
  33182. private _behaviors;
  33183. /**
  33184. * Attach a behavior to the node
  33185. * @see https://doc.babylonjs.com/features/behaviour
  33186. * @param behavior defines the behavior to attach
  33187. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33188. * @returns the current Node
  33189. */
  33190. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33191. /**
  33192. * Remove an attached behavior
  33193. * @see https://doc.babylonjs.com/features/behaviour
  33194. * @param behavior defines the behavior to attach
  33195. * @returns the current Node
  33196. */
  33197. removeBehavior(behavior: Behavior<Node>): Node;
  33198. /**
  33199. * Gets the list of attached behaviors
  33200. * @see https://doc.babylonjs.com/features/behaviour
  33201. */
  33202. get behaviors(): Behavior<Node>[];
  33203. /**
  33204. * Gets an attached behavior by name
  33205. * @param name defines the name of the behavior to look for
  33206. * @see https://doc.babylonjs.com/features/behaviour
  33207. * @returns null if behavior was not found else the requested behavior
  33208. */
  33209. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33210. /**
  33211. * Returns the latest update of the World matrix
  33212. * @returns a Matrix
  33213. */
  33214. getWorldMatrix(): Matrix;
  33215. /** @hidden */
  33216. _getWorldMatrixDeterminant(): number;
  33217. /**
  33218. * Returns directly the latest state of the mesh World matrix.
  33219. * A Matrix is returned.
  33220. */
  33221. get worldMatrixFromCache(): Matrix;
  33222. /** @hidden */
  33223. _initCache(): void;
  33224. /** @hidden */
  33225. updateCache(force?: boolean): void;
  33226. /** @hidden */
  33227. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33228. /** @hidden */
  33229. _updateCache(ignoreParentClass?: boolean): void;
  33230. /** @hidden */
  33231. _isSynchronized(): boolean;
  33232. /** @hidden */
  33233. _markSyncedWithParent(): void;
  33234. /** @hidden */
  33235. isSynchronizedWithParent(): boolean;
  33236. /** @hidden */
  33237. isSynchronized(): boolean;
  33238. /**
  33239. * Is this node ready to be used/rendered
  33240. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33241. * @return true if the node is ready
  33242. */
  33243. isReady(completeCheck?: boolean): boolean;
  33244. /**
  33245. * Is this node enabled?
  33246. * 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
  33247. * @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
  33248. * @return whether this node (and its parent) is enabled
  33249. */
  33250. isEnabled(checkAncestors?: boolean): boolean;
  33251. /** @hidden */
  33252. protected _syncParentEnabledState(): void;
  33253. /**
  33254. * Set the enabled state of this node
  33255. * @param value defines the new enabled state
  33256. */
  33257. setEnabled(value: boolean): void;
  33258. /**
  33259. * Is this node a descendant of the given node?
  33260. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33261. * @param ancestor defines the parent node to inspect
  33262. * @returns a boolean indicating if this node is a descendant of the given node
  33263. */
  33264. isDescendantOf(ancestor: Node): boolean;
  33265. /** @hidden */
  33266. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33267. /**
  33268. * Will return all nodes that have this node as ascendant
  33269. * @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
  33270. * @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
  33271. * @return all children nodes of all types
  33272. */
  33273. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33274. /**
  33275. * Get all child-meshes of this node
  33276. * @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)
  33277. * @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
  33278. * @returns an array of AbstractMesh
  33279. */
  33280. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33281. /**
  33282. * Get all direct children of this node
  33283. * @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
  33284. * @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)
  33285. * @returns an array of Node
  33286. */
  33287. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33288. /** @hidden */
  33289. _setReady(state: boolean): void;
  33290. /**
  33291. * Get an animation by name
  33292. * @param name defines the name of the animation to look for
  33293. * @returns null if not found else the requested animation
  33294. */
  33295. getAnimationByName(name: string): Nullable<Animation>;
  33296. /**
  33297. * Creates an animation range for this node
  33298. * @param name defines the name of the range
  33299. * @param from defines the starting key
  33300. * @param to defines the end key
  33301. */
  33302. createAnimationRange(name: string, from: number, to: number): void;
  33303. /**
  33304. * Delete a specific animation range
  33305. * @param name defines the name of the range to delete
  33306. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33307. */
  33308. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33309. /**
  33310. * Get an animation range by name
  33311. * @param name defines the name of the animation range to look for
  33312. * @returns null if not found else the requested animation range
  33313. */
  33314. getAnimationRange(name: string): Nullable<AnimationRange>;
  33315. /**
  33316. * Gets the list of all animation ranges defined on this node
  33317. * @returns an array
  33318. */
  33319. getAnimationRanges(): Nullable<AnimationRange>[];
  33320. /**
  33321. * Will start the animation sequence
  33322. * @param name defines the range frames for animation sequence
  33323. * @param loop defines if the animation should loop (false by default)
  33324. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33325. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33326. * @returns the object created for this animation. If range does not exist, it will return null
  33327. */
  33328. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33329. /**
  33330. * Serialize animation ranges into a JSON compatible object
  33331. * @returns serialization object
  33332. */
  33333. serializeAnimationRanges(): any;
  33334. /**
  33335. * Computes the world matrix of the node
  33336. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33337. * @returns the world matrix
  33338. */
  33339. computeWorldMatrix(force?: boolean): Matrix;
  33340. /**
  33341. * Releases resources associated with this node.
  33342. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33343. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33344. */
  33345. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33346. /**
  33347. * Parse animation range data from a serialization object and store them into a given node
  33348. * @param node defines where to store the animation ranges
  33349. * @param parsedNode defines the serialization object to read data from
  33350. * @param scene defines the hosting scene
  33351. */
  33352. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33353. /**
  33354. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33355. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33356. * @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
  33357. * @returns the new bounding vectors
  33358. */
  33359. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33360. min: Vector3;
  33361. max: Vector3;
  33362. };
  33363. }
  33364. }
  33365. declare module BABYLON {
  33366. /**
  33367. * @hidden
  33368. */
  33369. export class _IAnimationState {
  33370. key: number;
  33371. repeatCount: number;
  33372. workValue?: any;
  33373. loopMode?: number;
  33374. offsetValue?: any;
  33375. highLimitValue?: any;
  33376. }
  33377. /**
  33378. * Class used to store any kind of animation
  33379. */
  33380. export class Animation {
  33381. /**Name of the animation */
  33382. name: string;
  33383. /**Property to animate */
  33384. targetProperty: string;
  33385. /**The frames per second of the animation */
  33386. framePerSecond: number;
  33387. /**The data type of the animation */
  33388. dataType: number;
  33389. /**The loop mode of the animation */
  33390. loopMode?: number | undefined;
  33391. /**Specifies if blending should be enabled */
  33392. enableBlending?: boolean | undefined;
  33393. /**
  33394. * Use matrix interpolation instead of using direct key value when animating matrices
  33395. */
  33396. static AllowMatricesInterpolation: boolean;
  33397. /**
  33398. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33399. */
  33400. static AllowMatrixDecomposeForInterpolation: boolean;
  33401. /** Define the Url to load snippets */
  33402. static SnippetUrl: string;
  33403. /** Snippet ID if the animation was created from the snippet server */
  33404. snippetId: string;
  33405. /**
  33406. * Stores the key frames of the animation
  33407. */
  33408. private _keys;
  33409. /**
  33410. * Stores the easing function of the animation
  33411. */
  33412. private _easingFunction;
  33413. /**
  33414. * @hidden Internal use only
  33415. */
  33416. _runtimeAnimations: RuntimeAnimation[];
  33417. /**
  33418. * The set of event that will be linked to this animation
  33419. */
  33420. private _events;
  33421. /**
  33422. * Stores an array of target property paths
  33423. */
  33424. targetPropertyPath: string[];
  33425. /**
  33426. * Stores the blending speed of the animation
  33427. */
  33428. blendingSpeed: number;
  33429. /**
  33430. * Stores the animation ranges for the animation
  33431. */
  33432. private _ranges;
  33433. /**
  33434. * @hidden Internal use
  33435. */
  33436. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33437. /**
  33438. * Sets up an animation
  33439. * @param property The property to animate
  33440. * @param animationType The animation type to apply
  33441. * @param framePerSecond The frames per second of the animation
  33442. * @param easingFunction The easing function used in the animation
  33443. * @returns The created animation
  33444. */
  33445. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33446. /**
  33447. * Create and start an animation on a node
  33448. * @param name defines the name of the global animation that will be run on all nodes
  33449. * @param node defines the root node where the animation will take place
  33450. * @param targetProperty defines property to animate
  33451. * @param framePerSecond defines the number of frame per second yo use
  33452. * @param totalFrame defines the number of frames in total
  33453. * @param from defines the initial value
  33454. * @param to defines the final value
  33455. * @param loopMode defines which loop mode you want to use (off by default)
  33456. * @param easingFunction defines the easing function to use (linear by default)
  33457. * @param onAnimationEnd defines the callback to call when animation end
  33458. * @returns the animatable created for this animation
  33459. */
  33460. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33461. /**
  33462. * Create and start an animation on a node and its descendants
  33463. * @param name defines the name of the global animation that will be run on all nodes
  33464. * @param node defines the root node where the animation will take place
  33465. * @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
  33466. * @param targetProperty defines property to animate
  33467. * @param framePerSecond defines the number of frame per second to use
  33468. * @param totalFrame defines the number of frames in total
  33469. * @param from defines the initial value
  33470. * @param to defines the final value
  33471. * @param loopMode defines which loop mode you want to use (off by default)
  33472. * @param easingFunction defines the easing function to use (linear by default)
  33473. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33474. * @returns the list of animatables created for all nodes
  33475. * @example https://www.babylonjs-playground.com/#MH0VLI
  33476. */
  33477. 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[]>;
  33478. /**
  33479. * Creates a new animation, merges it with the existing animations and starts it
  33480. * @param name Name of the animation
  33481. * @param node Node which contains the scene that begins the animations
  33482. * @param targetProperty Specifies which property to animate
  33483. * @param framePerSecond The frames per second of the animation
  33484. * @param totalFrame The total number of frames
  33485. * @param from The frame at the beginning of the animation
  33486. * @param to The frame at the end of the animation
  33487. * @param loopMode Specifies the loop mode of the animation
  33488. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33489. * @param onAnimationEnd Callback to run once the animation is complete
  33490. * @returns Nullable animation
  33491. */
  33492. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33493. /**
  33494. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33495. * @param sourceAnimation defines the Animation containing keyframes to convert
  33496. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33497. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33498. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33499. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33500. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33501. */
  33502. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33503. /**
  33504. * Transition property of an host to the target Value
  33505. * @param property The property to transition
  33506. * @param targetValue The target Value of the property
  33507. * @param host The object where the property to animate belongs
  33508. * @param scene Scene used to run the animation
  33509. * @param frameRate Framerate (in frame/s) to use
  33510. * @param transition The transition type we want to use
  33511. * @param duration The duration of the animation, in milliseconds
  33512. * @param onAnimationEnd Callback trigger at the end of the animation
  33513. * @returns Nullable animation
  33514. */
  33515. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33516. /**
  33517. * Return the array of runtime animations currently using this animation
  33518. */
  33519. get runtimeAnimations(): RuntimeAnimation[];
  33520. /**
  33521. * Specifies if any of the runtime animations are currently running
  33522. */
  33523. get hasRunningRuntimeAnimations(): boolean;
  33524. /**
  33525. * Initializes the animation
  33526. * @param name Name of the animation
  33527. * @param targetProperty Property to animate
  33528. * @param framePerSecond The frames per second of the animation
  33529. * @param dataType The data type of the animation
  33530. * @param loopMode The loop mode of the animation
  33531. * @param enableBlending Specifies if blending should be enabled
  33532. */
  33533. constructor(
  33534. /**Name of the animation */
  33535. name: string,
  33536. /**Property to animate */
  33537. targetProperty: string,
  33538. /**The frames per second of the animation */
  33539. framePerSecond: number,
  33540. /**The data type of the animation */
  33541. dataType: number,
  33542. /**The loop mode of the animation */
  33543. loopMode?: number | undefined,
  33544. /**Specifies if blending should be enabled */
  33545. enableBlending?: boolean | undefined);
  33546. /**
  33547. * Converts the animation to a string
  33548. * @param fullDetails support for multiple levels of logging within scene loading
  33549. * @returns String form of the animation
  33550. */
  33551. toString(fullDetails?: boolean): string;
  33552. /**
  33553. * Add an event to this animation
  33554. * @param event Event to add
  33555. */
  33556. addEvent(event: AnimationEvent): void;
  33557. /**
  33558. * Remove all events found at the given frame
  33559. * @param frame The frame to remove events from
  33560. */
  33561. removeEvents(frame: number): void;
  33562. /**
  33563. * Retrieves all the events from the animation
  33564. * @returns Events from the animation
  33565. */
  33566. getEvents(): AnimationEvent[];
  33567. /**
  33568. * Creates an animation range
  33569. * @param name Name of the animation range
  33570. * @param from Starting frame of the animation range
  33571. * @param to Ending frame of the animation
  33572. */
  33573. createRange(name: string, from: number, to: number): void;
  33574. /**
  33575. * Deletes an animation range by name
  33576. * @param name Name of the animation range to delete
  33577. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33578. */
  33579. deleteRange(name: string, deleteFrames?: boolean): void;
  33580. /**
  33581. * Gets the animation range by name, or null if not defined
  33582. * @param name Name of the animation range
  33583. * @returns Nullable animation range
  33584. */
  33585. getRange(name: string): Nullable<AnimationRange>;
  33586. /**
  33587. * Gets the key frames from the animation
  33588. * @returns The key frames of the animation
  33589. */
  33590. getKeys(): Array<IAnimationKey>;
  33591. /**
  33592. * Gets the highest frame rate of the animation
  33593. * @returns Highest frame rate of the animation
  33594. */
  33595. getHighestFrame(): number;
  33596. /**
  33597. * Gets the easing function of the animation
  33598. * @returns Easing function of the animation
  33599. */
  33600. getEasingFunction(): IEasingFunction;
  33601. /**
  33602. * Sets the easing function of the animation
  33603. * @param easingFunction A custom mathematical formula for animation
  33604. */
  33605. setEasingFunction(easingFunction: EasingFunction): void;
  33606. /**
  33607. * Interpolates a scalar linearly
  33608. * @param startValue Start value of the animation curve
  33609. * @param endValue End value of the animation curve
  33610. * @param gradient Scalar amount to interpolate
  33611. * @returns Interpolated scalar value
  33612. */
  33613. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33614. /**
  33615. * Interpolates a scalar cubically
  33616. * @param startValue Start value of the animation curve
  33617. * @param outTangent End tangent of the animation
  33618. * @param endValue End value of the animation curve
  33619. * @param inTangent Start tangent of the animation curve
  33620. * @param gradient Scalar amount to interpolate
  33621. * @returns Interpolated scalar value
  33622. */
  33623. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33624. /**
  33625. * Interpolates a quaternion using a spherical linear interpolation
  33626. * @param startValue Start value of the animation curve
  33627. * @param endValue End value of the animation curve
  33628. * @param gradient Scalar amount to interpolate
  33629. * @returns Interpolated quaternion value
  33630. */
  33631. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33632. /**
  33633. * Interpolates a quaternion cubically
  33634. * @param startValue Start value of the animation curve
  33635. * @param outTangent End tangent of the animation curve
  33636. * @param endValue End value of the animation curve
  33637. * @param inTangent Start tangent of the animation curve
  33638. * @param gradient Scalar amount to interpolate
  33639. * @returns Interpolated quaternion value
  33640. */
  33641. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33642. /**
  33643. * Interpolates a Vector3 linearl
  33644. * @param startValue Start value of the animation curve
  33645. * @param endValue End value of the animation curve
  33646. * @param gradient Scalar amount to interpolate
  33647. * @returns Interpolated scalar value
  33648. */
  33649. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33650. /**
  33651. * Interpolates a Vector3 cubically
  33652. * @param startValue Start value of the animation curve
  33653. * @param outTangent End tangent of the animation
  33654. * @param endValue End value of the animation curve
  33655. * @param inTangent Start tangent of the animation curve
  33656. * @param gradient Scalar amount to interpolate
  33657. * @returns InterpolatedVector3 value
  33658. */
  33659. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33660. /**
  33661. * Interpolates a Vector2 linearly
  33662. * @param startValue Start value of the animation curve
  33663. * @param endValue End value of the animation curve
  33664. * @param gradient Scalar amount to interpolate
  33665. * @returns Interpolated Vector2 value
  33666. */
  33667. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33668. /**
  33669. * Interpolates a Vector2 cubically
  33670. * @param startValue Start value of the animation curve
  33671. * @param outTangent End tangent of the animation
  33672. * @param endValue End value of the animation curve
  33673. * @param inTangent Start tangent of the animation curve
  33674. * @param gradient Scalar amount to interpolate
  33675. * @returns Interpolated Vector2 value
  33676. */
  33677. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33678. /**
  33679. * Interpolates a size linearly
  33680. * @param startValue Start value of the animation curve
  33681. * @param endValue End value of the animation curve
  33682. * @param gradient Scalar amount to interpolate
  33683. * @returns Interpolated Size value
  33684. */
  33685. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33686. /**
  33687. * Interpolates a Color3 linearly
  33688. * @param startValue Start value of the animation curve
  33689. * @param endValue End value of the animation curve
  33690. * @param gradient Scalar amount to interpolate
  33691. * @returns Interpolated Color3 value
  33692. */
  33693. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33694. /**
  33695. * Interpolates a Color4 linearly
  33696. * @param startValue Start value of the animation curve
  33697. * @param endValue End value of the animation curve
  33698. * @param gradient Scalar amount to interpolate
  33699. * @returns Interpolated Color3 value
  33700. */
  33701. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33702. /**
  33703. * @hidden Internal use only
  33704. */
  33705. _getKeyValue(value: any): any;
  33706. /**
  33707. * @hidden Internal use only
  33708. */
  33709. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33710. /**
  33711. * Defines the function to use to interpolate matrices
  33712. * @param startValue defines the start matrix
  33713. * @param endValue defines the end matrix
  33714. * @param gradient defines the gradient between both matrices
  33715. * @param result defines an optional target matrix where to store the interpolation
  33716. * @returns the interpolated matrix
  33717. */
  33718. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33719. /**
  33720. * Makes a copy of the animation
  33721. * @returns Cloned animation
  33722. */
  33723. clone(): Animation;
  33724. /**
  33725. * Sets the key frames of the animation
  33726. * @param values The animation key frames to set
  33727. */
  33728. setKeys(values: Array<IAnimationKey>): void;
  33729. /**
  33730. * Serializes the animation to an object
  33731. * @returns Serialized object
  33732. */
  33733. serialize(): any;
  33734. /**
  33735. * Float animation type
  33736. */
  33737. static readonly ANIMATIONTYPE_FLOAT: number;
  33738. /**
  33739. * Vector3 animation type
  33740. */
  33741. static readonly ANIMATIONTYPE_VECTOR3: number;
  33742. /**
  33743. * Quaternion animation type
  33744. */
  33745. static readonly ANIMATIONTYPE_QUATERNION: number;
  33746. /**
  33747. * Matrix animation type
  33748. */
  33749. static readonly ANIMATIONTYPE_MATRIX: number;
  33750. /**
  33751. * Color3 animation type
  33752. */
  33753. static readonly ANIMATIONTYPE_COLOR3: number;
  33754. /**
  33755. * Color3 animation type
  33756. */
  33757. static readonly ANIMATIONTYPE_COLOR4: number;
  33758. /**
  33759. * Vector2 animation type
  33760. */
  33761. static readonly ANIMATIONTYPE_VECTOR2: number;
  33762. /**
  33763. * Size animation type
  33764. */
  33765. static readonly ANIMATIONTYPE_SIZE: number;
  33766. /**
  33767. * Relative Loop Mode
  33768. */
  33769. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33770. /**
  33771. * Cycle Loop Mode
  33772. */
  33773. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33774. /**
  33775. * Constant Loop Mode
  33776. */
  33777. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33778. /** @hidden */
  33779. static _UniversalLerp(left: any, right: any, amount: number): any;
  33780. /**
  33781. * Parses an animation object and creates an animation
  33782. * @param parsedAnimation Parsed animation object
  33783. * @returns Animation object
  33784. */
  33785. static Parse(parsedAnimation: any): Animation;
  33786. /**
  33787. * Appends the serialized animations from the source animations
  33788. * @param source Source containing the animations
  33789. * @param destination Target to store the animations
  33790. */
  33791. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33792. /**
  33793. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33794. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33795. * @param url defines the url to load from
  33796. * @returns a promise that will resolve to the new animation or an array of animations
  33797. */
  33798. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33799. /**
  33800. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33801. * @param snippetId defines the snippet to load
  33802. * @returns a promise that will resolve to the new animation or a new array of animations
  33803. */
  33804. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33805. }
  33806. }
  33807. declare module BABYLON {
  33808. /**
  33809. * Interface containing an array of animations
  33810. */
  33811. export interface IAnimatable {
  33812. /**
  33813. * Array of animations
  33814. */
  33815. animations: Nullable<Array<Animation>>;
  33816. }
  33817. }
  33818. declare module BABYLON {
  33819. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33820. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33821. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33822. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33823. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33824. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33825. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33826. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33827. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33828. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33829. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33830. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33831. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33832. /**
  33833. * Decorator used to define property that can be serialized as reference to a camera
  33834. * @param sourceName defines the name of the property to decorate
  33835. */
  33836. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33837. /**
  33838. * Class used to help serialization objects
  33839. */
  33840. export class SerializationHelper {
  33841. /** @hidden */
  33842. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33843. /** @hidden */
  33844. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33845. /** @hidden */
  33846. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33847. /** @hidden */
  33848. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33849. /**
  33850. * Appends the serialized animations from the source animations
  33851. * @param source Source containing the animations
  33852. * @param destination Target to store the animations
  33853. */
  33854. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33855. /**
  33856. * Static function used to serialized a specific entity
  33857. * @param entity defines the entity to serialize
  33858. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33859. * @returns a JSON compatible object representing the serialization of the entity
  33860. */
  33861. static Serialize<T>(entity: T, serializationObject?: any): any;
  33862. /**
  33863. * Creates a new entity from a serialization data object
  33864. * @param creationFunction defines a function used to instanciated the new entity
  33865. * @param source defines the source serialization data
  33866. * @param scene defines the hosting scene
  33867. * @param rootUrl defines the root url for resources
  33868. * @returns a new entity
  33869. */
  33870. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33871. /**
  33872. * Clones an object
  33873. * @param creationFunction defines the function used to instanciate the new object
  33874. * @param source defines the source object
  33875. * @returns the cloned object
  33876. */
  33877. static Clone<T>(creationFunction: () => T, source: T): T;
  33878. /**
  33879. * Instanciates a new object based on a source one (some data will be shared between both object)
  33880. * @param creationFunction defines the function used to instanciate the new object
  33881. * @param source defines the source object
  33882. * @returns the new object
  33883. */
  33884. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33885. }
  33886. }
  33887. declare module BABYLON {
  33888. /**
  33889. * Base class of all the textures in babylon.
  33890. * It groups all the common properties the materials, post process, lights... might need
  33891. * in order to make a correct use of the texture.
  33892. */
  33893. export class BaseTexture implements IAnimatable {
  33894. /**
  33895. * Default anisotropic filtering level for the application.
  33896. * It is set to 4 as a good tradeoff between perf and quality.
  33897. */
  33898. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33899. /**
  33900. * Gets or sets the unique id of the texture
  33901. */
  33902. uniqueId: number;
  33903. /**
  33904. * Define the name of the texture.
  33905. */
  33906. name: string;
  33907. /**
  33908. * Gets or sets an object used to store user defined information.
  33909. */
  33910. metadata: any;
  33911. /**
  33912. * For internal use only. Please do not use.
  33913. */
  33914. reservedDataStore: any;
  33915. private _hasAlpha;
  33916. /**
  33917. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33918. */
  33919. set hasAlpha(value: boolean);
  33920. get hasAlpha(): boolean;
  33921. /**
  33922. * Defines if the alpha value should be determined via the rgb values.
  33923. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33924. */
  33925. getAlphaFromRGB: boolean;
  33926. /**
  33927. * Intensity or strength of the texture.
  33928. * It is commonly used by materials to fine tune the intensity of the texture
  33929. */
  33930. level: number;
  33931. /**
  33932. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33933. * This is part of the texture as textures usually maps to one uv set.
  33934. */
  33935. coordinatesIndex: number;
  33936. protected _coordinatesMode: number;
  33937. /**
  33938. * How a texture is mapped.
  33939. *
  33940. * | Value | Type | Description |
  33941. * | ----- | ----------------------------------- | ----------- |
  33942. * | 0 | EXPLICIT_MODE | |
  33943. * | 1 | SPHERICAL_MODE | |
  33944. * | 2 | PLANAR_MODE | |
  33945. * | 3 | CUBIC_MODE | |
  33946. * | 4 | PROJECTION_MODE | |
  33947. * | 5 | SKYBOX_MODE | |
  33948. * | 6 | INVCUBIC_MODE | |
  33949. * | 7 | EQUIRECTANGULAR_MODE | |
  33950. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33951. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33952. */
  33953. set coordinatesMode(value: number);
  33954. get coordinatesMode(): number;
  33955. private _wrapU;
  33956. /**
  33957. * | Value | Type | Description |
  33958. * | ----- | ------------------ | ----------- |
  33959. * | 0 | CLAMP_ADDRESSMODE | |
  33960. * | 1 | WRAP_ADDRESSMODE | |
  33961. * | 2 | MIRROR_ADDRESSMODE | |
  33962. */
  33963. get wrapU(): number;
  33964. set wrapU(value: number);
  33965. private _wrapV;
  33966. /**
  33967. * | Value | Type | Description |
  33968. * | ----- | ------------------ | ----------- |
  33969. * | 0 | CLAMP_ADDRESSMODE | |
  33970. * | 1 | WRAP_ADDRESSMODE | |
  33971. * | 2 | MIRROR_ADDRESSMODE | |
  33972. */
  33973. get wrapV(): number;
  33974. set wrapV(value: number);
  33975. /**
  33976. * | Value | Type | Description |
  33977. * | ----- | ------------------ | ----------- |
  33978. * | 0 | CLAMP_ADDRESSMODE | |
  33979. * | 1 | WRAP_ADDRESSMODE | |
  33980. * | 2 | MIRROR_ADDRESSMODE | |
  33981. */
  33982. wrapR: number;
  33983. /**
  33984. * With compliant hardware and browser (supporting anisotropic filtering)
  33985. * this defines the level of anisotropic filtering in the texture.
  33986. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33987. */
  33988. anisotropicFilteringLevel: number;
  33989. /**
  33990. * Define if the texture is a cube texture or if false a 2d texture.
  33991. */
  33992. get isCube(): boolean;
  33993. set isCube(value: boolean);
  33994. /**
  33995. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33996. */
  33997. get is3D(): boolean;
  33998. set is3D(value: boolean);
  33999. /**
  34000. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34001. */
  34002. get is2DArray(): boolean;
  34003. set is2DArray(value: boolean);
  34004. private _gammaSpace;
  34005. /**
  34006. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34007. * HDR texture are usually stored in linear space.
  34008. * This only impacts the PBR and Background materials
  34009. */
  34010. get gammaSpace(): boolean;
  34011. set gammaSpace(gamma: boolean);
  34012. /**
  34013. * Gets or sets whether or not the texture contains RGBD data.
  34014. */
  34015. get isRGBD(): boolean;
  34016. set isRGBD(value: boolean);
  34017. /**
  34018. * Is Z inverted in the texture (useful in a cube texture).
  34019. */
  34020. invertZ: boolean;
  34021. /**
  34022. * Are mip maps generated for this texture or not.
  34023. */
  34024. get noMipmap(): boolean;
  34025. /**
  34026. * @hidden
  34027. */
  34028. lodLevelInAlpha: boolean;
  34029. /**
  34030. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34031. */
  34032. get lodGenerationOffset(): number;
  34033. set lodGenerationOffset(value: number);
  34034. /**
  34035. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34036. */
  34037. get lodGenerationScale(): number;
  34038. set lodGenerationScale(value: number);
  34039. /**
  34040. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34041. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34042. * average roughness values.
  34043. */
  34044. get linearSpecularLOD(): boolean;
  34045. set linearSpecularLOD(value: boolean);
  34046. /**
  34047. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34048. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34049. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34050. */
  34051. get irradianceTexture(): Nullable<BaseTexture>;
  34052. set irradianceTexture(value: Nullable<BaseTexture>);
  34053. /**
  34054. * Define if the texture is a render target.
  34055. */
  34056. isRenderTarget: boolean;
  34057. /**
  34058. * Define the unique id of the texture in the scene.
  34059. */
  34060. get uid(): string;
  34061. /** @hidden */
  34062. _prefiltered: boolean;
  34063. /**
  34064. * Return a string representation of the texture.
  34065. * @returns the texture as a string
  34066. */
  34067. toString(): string;
  34068. /**
  34069. * Get the class name of the texture.
  34070. * @returns "BaseTexture"
  34071. */
  34072. getClassName(): string;
  34073. /**
  34074. * Define the list of animation attached to the texture.
  34075. */
  34076. animations: Animation[];
  34077. /**
  34078. * An event triggered when the texture is disposed.
  34079. */
  34080. onDisposeObservable: Observable<BaseTexture>;
  34081. private _onDisposeObserver;
  34082. /**
  34083. * Callback triggered when the texture has been disposed.
  34084. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34085. */
  34086. set onDispose(callback: () => void);
  34087. /**
  34088. * Define the current state of the loading sequence when in delayed load mode.
  34089. */
  34090. delayLoadState: number;
  34091. protected _scene: Nullable<Scene>;
  34092. protected _engine: Nullable<ThinEngine>;
  34093. /** @hidden */
  34094. _texture: Nullable<InternalTexture>;
  34095. private _uid;
  34096. /**
  34097. * Define if the texture is preventinga material to render or not.
  34098. * If not and the texture is not ready, the engine will use a default black texture instead.
  34099. */
  34100. get isBlocking(): boolean;
  34101. /**
  34102. * Instantiates a new BaseTexture.
  34103. * Base class of all the textures in babylon.
  34104. * It groups all the common properties the materials, post process, lights... might need
  34105. * in order to make a correct use of the texture.
  34106. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34107. */
  34108. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34109. /**
  34110. * Get the scene the texture belongs to.
  34111. * @returns the scene or null if undefined
  34112. */
  34113. getScene(): Nullable<Scene>;
  34114. /** @hidden */
  34115. protected _getEngine(): Nullable<ThinEngine>;
  34116. /**
  34117. * Get the texture transform matrix used to offset tile the texture for istance.
  34118. * @returns the transformation matrix
  34119. */
  34120. getTextureMatrix(): Matrix;
  34121. /**
  34122. * Get the texture reflection matrix used to rotate/transform the reflection.
  34123. * @returns the reflection matrix
  34124. */
  34125. getReflectionTextureMatrix(): Matrix;
  34126. /**
  34127. * Get the underlying lower level texture from Babylon.
  34128. * @returns the insternal texture
  34129. */
  34130. getInternalTexture(): Nullable<InternalTexture>;
  34131. /**
  34132. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34133. * @returns true if ready or not blocking
  34134. */
  34135. isReadyOrNotBlocking(): boolean;
  34136. /**
  34137. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34138. * @returns true if fully ready
  34139. */
  34140. isReady(): boolean;
  34141. private _cachedSize;
  34142. /**
  34143. * Get the size of the texture.
  34144. * @returns the texture size.
  34145. */
  34146. getSize(): ISize;
  34147. /**
  34148. * Get the base size of the texture.
  34149. * It can be different from the size if the texture has been resized for POT for instance
  34150. * @returns the base size
  34151. */
  34152. getBaseSize(): ISize;
  34153. /**
  34154. * Update the sampling mode of the texture.
  34155. * Default is Trilinear mode.
  34156. *
  34157. * | Value | Type | Description |
  34158. * | ----- | ------------------ | ----------- |
  34159. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34160. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34161. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34162. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34163. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34164. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34165. * | 7 | NEAREST_LINEAR | |
  34166. * | 8 | NEAREST_NEAREST | |
  34167. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34168. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34169. * | 11 | LINEAR_LINEAR | |
  34170. * | 12 | LINEAR_NEAREST | |
  34171. *
  34172. * > _mag_: magnification filter (close to the viewer)
  34173. * > _min_: minification filter (far from the viewer)
  34174. * > _mip_: filter used between mip map levels
  34175. *@param samplingMode Define the new sampling mode of the texture
  34176. */
  34177. updateSamplingMode(samplingMode: number): void;
  34178. /**
  34179. * Scales the texture if is `canRescale()`
  34180. * @param ratio the resize factor we want to use to rescale
  34181. */
  34182. scale(ratio: number): void;
  34183. /**
  34184. * Get if the texture can rescale.
  34185. */
  34186. get canRescale(): boolean;
  34187. /** @hidden */
  34188. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34189. /** @hidden */
  34190. _rebuild(): void;
  34191. /**
  34192. * Triggers the load sequence in delayed load mode.
  34193. */
  34194. delayLoad(): void;
  34195. /**
  34196. * Clones the texture.
  34197. * @returns the cloned texture
  34198. */
  34199. clone(): Nullable<BaseTexture>;
  34200. /**
  34201. * Get the texture underlying type (INT, FLOAT...)
  34202. */
  34203. get textureType(): number;
  34204. /**
  34205. * Get the texture underlying format (RGB, RGBA...)
  34206. */
  34207. get textureFormat(): number;
  34208. /**
  34209. * Indicates that textures need to be re-calculated for all materials
  34210. */
  34211. protected _markAllSubMeshesAsTexturesDirty(): void;
  34212. /**
  34213. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34214. * This will returns an RGBA array buffer containing either in values (0-255) or
  34215. * float values (0-1) depending of the underlying buffer type.
  34216. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34217. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34218. * @param buffer defines a user defined buffer to fill with data (can be null)
  34219. * @returns The Array buffer containing the pixels data.
  34220. */
  34221. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34222. /**
  34223. * Release and destroy the underlying lower level texture aka internalTexture.
  34224. */
  34225. releaseInternalTexture(): void;
  34226. /** @hidden */
  34227. get _lodTextureHigh(): Nullable<BaseTexture>;
  34228. /** @hidden */
  34229. get _lodTextureMid(): Nullable<BaseTexture>;
  34230. /** @hidden */
  34231. get _lodTextureLow(): Nullable<BaseTexture>;
  34232. /**
  34233. * Dispose the texture and release its associated resources.
  34234. */
  34235. dispose(): void;
  34236. /**
  34237. * Serialize the texture into a JSON representation that can be parsed later on.
  34238. * @returns the JSON representation of the texture
  34239. */
  34240. serialize(): any;
  34241. /**
  34242. * Helper function to be called back once a list of texture contains only ready textures.
  34243. * @param textures Define the list of textures to wait for
  34244. * @param callback Define the callback triggered once the entire list will be ready
  34245. */
  34246. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34247. private static _isScene;
  34248. }
  34249. }
  34250. declare module BABYLON {
  34251. /**
  34252. * Options to be used when creating an effect.
  34253. */
  34254. export interface IEffectCreationOptions {
  34255. /**
  34256. * Atrributes that will be used in the shader.
  34257. */
  34258. attributes: string[];
  34259. /**
  34260. * Uniform varible names that will be set in the shader.
  34261. */
  34262. uniformsNames: string[];
  34263. /**
  34264. * Uniform buffer variable names that will be set in the shader.
  34265. */
  34266. uniformBuffersNames: string[];
  34267. /**
  34268. * Sampler texture variable names that will be set in the shader.
  34269. */
  34270. samplers: string[];
  34271. /**
  34272. * Define statements that will be set in the shader.
  34273. */
  34274. defines: any;
  34275. /**
  34276. * Possible fallbacks for this effect to improve performance when needed.
  34277. */
  34278. fallbacks: Nullable<IEffectFallbacks>;
  34279. /**
  34280. * Callback that will be called when the shader is compiled.
  34281. */
  34282. onCompiled: Nullable<(effect: Effect) => void>;
  34283. /**
  34284. * Callback that will be called if an error occurs during shader compilation.
  34285. */
  34286. onError: Nullable<(effect: Effect, errors: string) => void>;
  34287. /**
  34288. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34289. */
  34290. indexParameters?: any;
  34291. /**
  34292. * Max number of lights that can be used in the shader.
  34293. */
  34294. maxSimultaneousLights?: number;
  34295. /**
  34296. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34297. */
  34298. transformFeedbackVaryings?: Nullable<string[]>;
  34299. /**
  34300. * 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
  34301. */
  34302. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34303. /**
  34304. * Is this effect rendering to several color attachments ?
  34305. */
  34306. multiTarget?: boolean;
  34307. }
  34308. /**
  34309. * Effect containing vertex and fragment shader that can be executed on an object.
  34310. */
  34311. export class Effect implements IDisposable {
  34312. /**
  34313. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34314. */
  34315. static ShadersRepository: string;
  34316. /**
  34317. * Enable logging of the shader code when a compilation error occurs
  34318. */
  34319. static LogShaderCodeOnCompilationError: boolean;
  34320. /**
  34321. * Name of the effect.
  34322. */
  34323. name: any;
  34324. /**
  34325. * String container all the define statements that should be set on the shader.
  34326. */
  34327. defines: string;
  34328. /**
  34329. * Callback that will be called when the shader is compiled.
  34330. */
  34331. onCompiled: Nullable<(effect: Effect) => void>;
  34332. /**
  34333. * Callback that will be called if an error occurs during shader compilation.
  34334. */
  34335. onError: Nullable<(effect: Effect, errors: string) => void>;
  34336. /**
  34337. * Callback that will be called when effect is bound.
  34338. */
  34339. onBind: Nullable<(effect: Effect) => void>;
  34340. /**
  34341. * Unique ID of the effect.
  34342. */
  34343. uniqueId: number;
  34344. /**
  34345. * Observable that will be called when the shader is compiled.
  34346. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34347. */
  34348. onCompileObservable: Observable<Effect>;
  34349. /**
  34350. * Observable that will be called if an error occurs during shader compilation.
  34351. */
  34352. onErrorObservable: Observable<Effect>;
  34353. /** @hidden */
  34354. _onBindObservable: Nullable<Observable<Effect>>;
  34355. /**
  34356. * @hidden
  34357. * Specifies if the effect was previously ready
  34358. */
  34359. _wasPreviouslyReady: boolean;
  34360. /**
  34361. * Observable that will be called when effect is bound.
  34362. */
  34363. get onBindObservable(): Observable<Effect>;
  34364. /** @hidden */
  34365. _bonesComputationForcedToCPU: boolean;
  34366. /** @hidden */
  34367. _multiTarget: boolean;
  34368. private static _uniqueIdSeed;
  34369. private _engine;
  34370. private _uniformBuffersNames;
  34371. private _uniformBuffersNamesList;
  34372. private _uniformsNames;
  34373. private _samplerList;
  34374. private _samplers;
  34375. private _isReady;
  34376. private _compilationError;
  34377. private _allFallbacksProcessed;
  34378. private _attributesNames;
  34379. private _attributes;
  34380. private _attributeLocationByName;
  34381. private _uniforms;
  34382. /**
  34383. * Key for the effect.
  34384. * @hidden
  34385. */
  34386. _key: string;
  34387. private _indexParameters;
  34388. private _fallbacks;
  34389. private _vertexSourceCode;
  34390. private _fragmentSourceCode;
  34391. private _vertexSourceCodeOverride;
  34392. private _fragmentSourceCodeOverride;
  34393. private _transformFeedbackVaryings;
  34394. /**
  34395. * Compiled shader to webGL program.
  34396. * @hidden
  34397. */
  34398. _pipelineContext: Nullable<IPipelineContext>;
  34399. private _valueCache;
  34400. private static _baseCache;
  34401. /**
  34402. * Instantiates an effect.
  34403. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34404. * @param baseName Name of the effect.
  34405. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34406. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34407. * @param samplers List of sampler variables that will be passed to the shader.
  34408. * @param engine Engine to be used to render the effect
  34409. * @param defines Define statements to be added to the shader.
  34410. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34411. * @param onCompiled Callback that will be called when the shader is compiled.
  34412. * @param onError Callback that will be called if an error occurs during shader compilation.
  34413. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34414. */
  34415. 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);
  34416. private _useFinalCode;
  34417. /**
  34418. * Unique key for this effect
  34419. */
  34420. get key(): string;
  34421. /**
  34422. * If the effect has been compiled and prepared.
  34423. * @returns if the effect is compiled and prepared.
  34424. */
  34425. isReady(): boolean;
  34426. private _isReadyInternal;
  34427. /**
  34428. * The engine the effect was initialized with.
  34429. * @returns the engine.
  34430. */
  34431. getEngine(): Engine;
  34432. /**
  34433. * The pipeline context for this effect
  34434. * @returns the associated pipeline context
  34435. */
  34436. getPipelineContext(): Nullable<IPipelineContext>;
  34437. /**
  34438. * The set of names of attribute variables for the shader.
  34439. * @returns An array of attribute names.
  34440. */
  34441. getAttributesNames(): string[];
  34442. /**
  34443. * Returns the attribute at the given index.
  34444. * @param index The index of the attribute.
  34445. * @returns The location of the attribute.
  34446. */
  34447. getAttributeLocation(index: number): number;
  34448. /**
  34449. * Returns the attribute based on the name of the variable.
  34450. * @param name of the attribute to look up.
  34451. * @returns the attribute location.
  34452. */
  34453. getAttributeLocationByName(name: string): number;
  34454. /**
  34455. * The number of attributes.
  34456. * @returns the numnber of attributes.
  34457. */
  34458. getAttributesCount(): number;
  34459. /**
  34460. * Gets the index of a uniform variable.
  34461. * @param uniformName of the uniform to look up.
  34462. * @returns the index.
  34463. */
  34464. getUniformIndex(uniformName: string): number;
  34465. /**
  34466. * Returns the attribute based on the name of the variable.
  34467. * @param uniformName of the uniform to look up.
  34468. * @returns the location of the uniform.
  34469. */
  34470. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34471. /**
  34472. * Returns an array of sampler variable names
  34473. * @returns The array of sampler variable names.
  34474. */
  34475. getSamplers(): string[];
  34476. /**
  34477. * Returns an array of uniform variable names
  34478. * @returns The array of uniform variable names.
  34479. */
  34480. getUniformNames(): string[];
  34481. /**
  34482. * Returns an array of uniform buffer variable names
  34483. * @returns The array of uniform buffer variable names.
  34484. */
  34485. getUniformBuffersNames(): string[];
  34486. /**
  34487. * Returns the index parameters used to create the effect
  34488. * @returns The index parameters object
  34489. */
  34490. getIndexParameters(): any;
  34491. /**
  34492. * The error from the last compilation.
  34493. * @returns the error string.
  34494. */
  34495. getCompilationError(): string;
  34496. /**
  34497. * Gets a boolean indicating that all fallbacks were used during compilation
  34498. * @returns true if all fallbacks were used
  34499. */
  34500. allFallbacksProcessed(): boolean;
  34501. /**
  34502. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34503. * @param func The callback to be used.
  34504. */
  34505. executeWhenCompiled(func: (effect: Effect) => void): void;
  34506. private _checkIsReady;
  34507. private _loadShader;
  34508. /**
  34509. * Gets the vertex shader source code of this effect
  34510. */
  34511. get vertexSourceCode(): string;
  34512. /**
  34513. * Gets the fragment shader source code of this effect
  34514. */
  34515. get fragmentSourceCode(): string;
  34516. /**
  34517. * Recompiles the webGL program
  34518. * @param vertexSourceCode The source code for the vertex shader.
  34519. * @param fragmentSourceCode The source code for the fragment shader.
  34520. * @param onCompiled Callback called when completed.
  34521. * @param onError Callback called on error.
  34522. * @hidden
  34523. */
  34524. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34525. /**
  34526. * Prepares the effect
  34527. * @hidden
  34528. */
  34529. _prepareEffect(): void;
  34530. private _getShaderCodeAndErrorLine;
  34531. private _processCompilationErrors;
  34532. /**
  34533. * Checks if the effect is supported. (Must be called after compilation)
  34534. */
  34535. get isSupported(): boolean;
  34536. /**
  34537. * Binds a texture to the engine to be used as output of the shader.
  34538. * @param channel Name of the output variable.
  34539. * @param texture Texture to bind.
  34540. * @hidden
  34541. */
  34542. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34543. /**
  34544. * Sets a texture on the engine to be used in the shader.
  34545. * @param channel Name of the sampler variable.
  34546. * @param texture Texture to set.
  34547. */
  34548. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34549. /**
  34550. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34551. * @param channel Name of the sampler variable.
  34552. * @param texture Texture to set.
  34553. */
  34554. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34555. /**
  34556. * Sets an array of textures on the engine to be used in the shader.
  34557. * @param channel Name of the variable.
  34558. * @param textures Textures to set.
  34559. */
  34560. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34561. /**
  34562. * 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)
  34563. * @param channel Name of the sampler variable.
  34564. * @param postProcess Post process to get the input texture from.
  34565. */
  34566. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34567. /**
  34568. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34569. * 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)
  34570. * @param channel Name of the sampler variable.
  34571. * @param postProcess Post process to get the output texture from.
  34572. */
  34573. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34574. /** @hidden */
  34575. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34576. /** @hidden */
  34577. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34578. /** @hidden */
  34579. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34580. /** @hidden */
  34581. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34582. /**
  34583. * Binds a buffer to a uniform.
  34584. * @param buffer Buffer to bind.
  34585. * @param name Name of the uniform variable to bind to.
  34586. */
  34587. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34588. /**
  34589. * Binds block to a uniform.
  34590. * @param blockName Name of the block to bind.
  34591. * @param index Index to bind.
  34592. */
  34593. bindUniformBlock(blockName: string, index: number): void;
  34594. /**
  34595. * Sets an interger value on a uniform variable.
  34596. * @param uniformName Name of the variable.
  34597. * @param value Value to be set.
  34598. * @returns this effect.
  34599. */
  34600. setInt(uniformName: string, value: number): Effect;
  34601. /**
  34602. * Sets an int array on a uniform variable.
  34603. * @param uniformName Name of the variable.
  34604. * @param array array to be set.
  34605. * @returns this effect.
  34606. */
  34607. setIntArray(uniformName: string, array: Int32Array): Effect;
  34608. /**
  34609. * 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)
  34610. * @param uniformName Name of the variable.
  34611. * @param array array to be set.
  34612. * @returns this effect.
  34613. */
  34614. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34615. /**
  34616. * 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)
  34617. * @param uniformName Name of the variable.
  34618. * @param array array to be set.
  34619. * @returns this effect.
  34620. */
  34621. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34622. /**
  34623. * 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)
  34624. * @param uniformName Name of the variable.
  34625. * @param array array to be set.
  34626. * @returns this effect.
  34627. */
  34628. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34629. /**
  34630. * Sets an float array on a uniform variable.
  34631. * @param uniformName Name of the variable.
  34632. * @param array array to be set.
  34633. * @returns this effect.
  34634. */
  34635. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34636. /**
  34637. * 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)
  34638. * @param uniformName Name of the variable.
  34639. * @param array array to be set.
  34640. * @returns this effect.
  34641. */
  34642. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34643. /**
  34644. * 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)
  34645. * @param uniformName Name of the variable.
  34646. * @param array array to be set.
  34647. * @returns this effect.
  34648. */
  34649. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34650. /**
  34651. * 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)
  34652. * @param uniformName Name of the variable.
  34653. * @param array array to be set.
  34654. * @returns this effect.
  34655. */
  34656. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34657. /**
  34658. * Sets an array on a uniform variable.
  34659. * @param uniformName Name of the variable.
  34660. * @param array array to be set.
  34661. * @returns this effect.
  34662. */
  34663. setArray(uniformName: string, array: number[]): Effect;
  34664. /**
  34665. * 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)
  34666. * @param uniformName Name of the variable.
  34667. * @param array array to be set.
  34668. * @returns this effect.
  34669. */
  34670. setArray2(uniformName: string, array: number[]): Effect;
  34671. /**
  34672. * 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)
  34673. * @param uniformName Name of the variable.
  34674. * @param array array to be set.
  34675. * @returns this effect.
  34676. */
  34677. setArray3(uniformName: string, array: number[]): Effect;
  34678. /**
  34679. * 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)
  34680. * @param uniformName Name of the variable.
  34681. * @param array array to be set.
  34682. * @returns this effect.
  34683. */
  34684. setArray4(uniformName: string, array: number[]): Effect;
  34685. /**
  34686. * Sets matrices on a uniform variable.
  34687. * @param uniformName Name of the variable.
  34688. * @param matrices matrices to be set.
  34689. * @returns this effect.
  34690. */
  34691. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34692. /**
  34693. * Sets matrix on a uniform variable.
  34694. * @param uniformName Name of the variable.
  34695. * @param matrix matrix to be set.
  34696. * @returns this effect.
  34697. */
  34698. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34699. /**
  34700. * 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)
  34701. * @param uniformName Name of the variable.
  34702. * @param matrix matrix to be set.
  34703. * @returns this effect.
  34704. */
  34705. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34706. /**
  34707. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34708. * @param uniformName Name of the variable.
  34709. * @param matrix matrix to be set.
  34710. * @returns this effect.
  34711. */
  34712. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34713. /**
  34714. * Sets a float on a uniform variable.
  34715. * @param uniformName Name of the variable.
  34716. * @param value value to be set.
  34717. * @returns this effect.
  34718. */
  34719. setFloat(uniformName: string, value: number): Effect;
  34720. /**
  34721. * Sets a boolean on a uniform variable.
  34722. * @param uniformName Name of the variable.
  34723. * @param bool value to be set.
  34724. * @returns this effect.
  34725. */
  34726. setBool(uniformName: string, bool: boolean): Effect;
  34727. /**
  34728. * Sets a Vector2 on a uniform variable.
  34729. * @param uniformName Name of the variable.
  34730. * @param vector2 vector2 to be set.
  34731. * @returns this effect.
  34732. */
  34733. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34734. /**
  34735. * Sets a float2 on a uniform variable.
  34736. * @param uniformName Name of the variable.
  34737. * @param x First float in float2.
  34738. * @param y Second float in float2.
  34739. * @returns this effect.
  34740. */
  34741. setFloat2(uniformName: string, x: number, y: number): Effect;
  34742. /**
  34743. * Sets a Vector3 on a uniform variable.
  34744. * @param uniformName Name of the variable.
  34745. * @param vector3 Value to be set.
  34746. * @returns this effect.
  34747. */
  34748. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34749. /**
  34750. * Sets a float3 on a uniform variable.
  34751. * @param uniformName Name of the variable.
  34752. * @param x First float in float3.
  34753. * @param y Second float in float3.
  34754. * @param z Third float in float3.
  34755. * @returns this effect.
  34756. */
  34757. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34758. /**
  34759. * Sets a Vector4 on a uniform variable.
  34760. * @param uniformName Name of the variable.
  34761. * @param vector4 Value to be set.
  34762. * @returns this effect.
  34763. */
  34764. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34765. /**
  34766. * Sets a float4 on a uniform variable.
  34767. * @param uniformName Name of the variable.
  34768. * @param x First float in float4.
  34769. * @param y Second float in float4.
  34770. * @param z Third float in float4.
  34771. * @param w Fourth float in float4.
  34772. * @returns this effect.
  34773. */
  34774. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34775. /**
  34776. * Sets a Color3 on a uniform variable.
  34777. * @param uniformName Name of the variable.
  34778. * @param color3 Value to be set.
  34779. * @returns this effect.
  34780. */
  34781. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34782. /**
  34783. * Sets a Color4 on a uniform variable.
  34784. * @param uniformName Name of the variable.
  34785. * @param color3 Value to be set.
  34786. * @param alpha Alpha value to be set.
  34787. * @returns this effect.
  34788. */
  34789. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34790. /**
  34791. * Sets a Color4 on a uniform variable
  34792. * @param uniformName defines the name of the variable
  34793. * @param color4 defines the value to be set
  34794. * @returns this effect.
  34795. */
  34796. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34797. /** Release all associated resources */
  34798. dispose(): void;
  34799. /**
  34800. * This function will add a new shader to the shader store
  34801. * @param name the name of the shader
  34802. * @param pixelShader optional pixel shader content
  34803. * @param vertexShader optional vertex shader content
  34804. */
  34805. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34806. /**
  34807. * Store of each shader (The can be looked up using effect.key)
  34808. */
  34809. static ShadersStore: {
  34810. [key: string]: string;
  34811. };
  34812. /**
  34813. * Store of each included file for a shader (The can be looked up using effect.key)
  34814. */
  34815. static IncludesShadersStore: {
  34816. [key: string]: string;
  34817. };
  34818. /**
  34819. * Resets the cache of effects.
  34820. */
  34821. static ResetCache(): void;
  34822. }
  34823. }
  34824. declare module BABYLON {
  34825. /**
  34826. * Interface used to describe the capabilities of the engine relatively to the current browser
  34827. */
  34828. export interface EngineCapabilities {
  34829. /** Maximum textures units per fragment shader */
  34830. maxTexturesImageUnits: number;
  34831. /** Maximum texture units per vertex shader */
  34832. maxVertexTextureImageUnits: number;
  34833. /** Maximum textures units in the entire pipeline */
  34834. maxCombinedTexturesImageUnits: number;
  34835. /** Maximum texture size */
  34836. maxTextureSize: number;
  34837. /** Maximum texture samples */
  34838. maxSamples?: number;
  34839. /** Maximum cube texture size */
  34840. maxCubemapTextureSize: number;
  34841. /** Maximum render texture size */
  34842. maxRenderTextureSize: number;
  34843. /** Maximum number of vertex attributes */
  34844. maxVertexAttribs: number;
  34845. /** Maximum number of varyings */
  34846. maxVaryingVectors: number;
  34847. /** Maximum number of uniforms per vertex shader */
  34848. maxVertexUniformVectors: number;
  34849. /** Maximum number of uniforms per fragment shader */
  34850. maxFragmentUniformVectors: number;
  34851. /** Defines if standard derivates (dx/dy) are supported */
  34852. standardDerivatives: boolean;
  34853. /** Defines if s3tc texture compression is supported */
  34854. s3tc?: WEBGL_compressed_texture_s3tc;
  34855. /** Defines if pvrtc texture compression is supported */
  34856. pvrtc: any;
  34857. /** Defines if etc1 texture compression is supported */
  34858. etc1: any;
  34859. /** Defines if etc2 texture compression is supported */
  34860. etc2: any;
  34861. /** Defines if astc texture compression is supported */
  34862. astc: any;
  34863. /** Defines if bptc texture compression is supported */
  34864. bptc: any;
  34865. /** Defines if float textures are supported */
  34866. textureFloat: boolean;
  34867. /** Defines if vertex array objects are supported */
  34868. vertexArrayObject: boolean;
  34869. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34870. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34871. /** Gets the maximum level of anisotropy supported */
  34872. maxAnisotropy: number;
  34873. /** Defines if instancing is supported */
  34874. instancedArrays: boolean;
  34875. /** Defines if 32 bits indices are supported */
  34876. uintIndices: boolean;
  34877. /** Defines if high precision shaders are supported */
  34878. highPrecisionShaderSupported: boolean;
  34879. /** Defines if depth reading in the fragment shader is supported */
  34880. fragmentDepthSupported: boolean;
  34881. /** Defines if float texture linear filtering is supported*/
  34882. textureFloatLinearFiltering: boolean;
  34883. /** Defines if rendering to float textures is supported */
  34884. textureFloatRender: boolean;
  34885. /** Defines if half float textures are supported*/
  34886. textureHalfFloat: boolean;
  34887. /** Defines if half float texture linear filtering is supported*/
  34888. textureHalfFloatLinearFiltering: boolean;
  34889. /** Defines if rendering to half float textures is supported */
  34890. textureHalfFloatRender: boolean;
  34891. /** Defines if textureLOD shader command is supported */
  34892. textureLOD: boolean;
  34893. /** Defines if draw buffers extension is supported */
  34894. drawBuffersExtension: boolean;
  34895. /** Defines if depth textures are supported */
  34896. depthTextureExtension: boolean;
  34897. /** Defines if float color buffer are supported */
  34898. colorBufferFloat: boolean;
  34899. /** Gets disjoint timer query extension (null if not supported) */
  34900. timerQuery?: EXT_disjoint_timer_query;
  34901. /** Defines if timestamp can be used with timer query */
  34902. canUseTimestampForTimerQuery: boolean;
  34903. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34904. multiview?: any;
  34905. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34906. oculusMultiview?: any;
  34907. /** Function used to let the system compiles shaders in background */
  34908. parallelShaderCompile?: {
  34909. COMPLETION_STATUS_KHR: number;
  34910. };
  34911. /** Max number of texture samples for MSAA */
  34912. maxMSAASamples: number;
  34913. /** Defines if the blend min max extension is supported */
  34914. blendMinMax: boolean;
  34915. }
  34916. }
  34917. declare module BABYLON {
  34918. /**
  34919. * @hidden
  34920. **/
  34921. export class DepthCullingState {
  34922. private _isDepthTestDirty;
  34923. private _isDepthMaskDirty;
  34924. private _isDepthFuncDirty;
  34925. private _isCullFaceDirty;
  34926. private _isCullDirty;
  34927. private _isZOffsetDirty;
  34928. private _isFrontFaceDirty;
  34929. private _depthTest;
  34930. private _depthMask;
  34931. private _depthFunc;
  34932. private _cull;
  34933. private _cullFace;
  34934. private _zOffset;
  34935. private _frontFace;
  34936. /**
  34937. * Initializes the state.
  34938. */
  34939. constructor();
  34940. get isDirty(): boolean;
  34941. get zOffset(): number;
  34942. set zOffset(value: number);
  34943. get cullFace(): Nullable<number>;
  34944. set cullFace(value: Nullable<number>);
  34945. get cull(): Nullable<boolean>;
  34946. set cull(value: Nullable<boolean>);
  34947. get depthFunc(): Nullable<number>;
  34948. set depthFunc(value: Nullable<number>);
  34949. get depthMask(): boolean;
  34950. set depthMask(value: boolean);
  34951. get depthTest(): boolean;
  34952. set depthTest(value: boolean);
  34953. get frontFace(): Nullable<number>;
  34954. set frontFace(value: Nullable<number>);
  34955. reset(): void;
  34956. apply(gl: WebGLRenderingContext): void;
  34957. }
  34958. }
  34959. declare module BABYLON {
  34960. /**
  34961. * @hidden
  34962. **/
  34963. export class StencilState {
  34964. /** 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 */
  34965. static readonly ALWAYS: number;
  34966. /** Passed to stencilOperation to specify that stencil value must be kept */
  34967. static readonly KEEP: number;
  34968. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34969. static readonly REPLACE: number;
  34970. private _isStencilTestDirty;
  34971. private _isStencilMaskDirty;
  34972. private _isStencilFuncDirty;
  34973. private _isStencilOpDirty;
  34974. private _stencilTest;
  34975. private _stencilMask;
  34976. private _stencilFunc;
  34977. private _stencilFuncRef;
  34978. private _stencilFuncMask;
  34979. private _stencilOpStencilFail;
  34980. private _stencilOpDepthFail;
  34981. private _stencilOpStencilDepthPass;
  34982. get isDirty(): boolean;
  34983. get stencilFunc(): number;
  34984. set stencilFunc(value: number);
  34985. get stencilFuncRef(): number;
  34986. set stencilFuncRef(value: number);
  34987. get stencilFuncMask(): number;
  34988. set stencilFuncMask(value: number);
  34989. get stencilOpStencilFail(): number;
  34990. set stencilOpStencilFail(value: number);
  34991. get stencilOpDepthFail(): number;
  34992. set stencilOpDepthFail(value: number);
  34993. get stencilOpStencilDepthPass(): number;
  34994. set stencilOpStencilDepthPass(value: number);
  34995. get stencilMask(): number;
  34996. set stencilMask(value: number);
  34997. get stencilTest(): boolean;
  34998. set stencilTest(value: boolean);
  34999. constructor();
  35000. reset(): void;
  35001. apply(gl: WebGLRenderingContext): void;
  35002. }
  35003. }
  35004. declare module BABYLON {
  35005. /**
  35006. * @hidden
  35007. **/
  35008. export class AlphaState {
  35009. private _isAlphaBlendDirty;
  35010. private _isBlendFunctionParametersDirty;
  35011. private _isBlendEquationParametersDirty;
  35012. private _isBlendConstantsDirty;
  35013. private _alphaBlend;
  35014. private _blendFunctionParameters;
  35015. private _blendEquationParameters;
  35016. private _blendConstants;
  35017. /**
  35018. * Initializes the state.
  35019. */
  35020. constructor();
  35021. get isDirty(): boolean;
  35022. get alphaBlend(): boolean;
  35023. set alphaBlend(value: boolean);
  35024. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35025. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35026. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35027. reset(): void;
  35028. apply(gl: WebGLRenderingContext): void;
  35029. }
  35030. }
  35031. declare module BABYLON {
  35032. /** @hidden */
  35033. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35034. attributeProcessor(attribute: string): string;
  35035. varyingProcessor(varying: string, isFragment: boolean): string;
  35036. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35037. }
  35038. }
  35039. declare module BABYLON {
  35040. /**
  35041. * Interface for attribute information associated with buffer instanciation
  35042. */
  35043. export interface InstancingAttributeInfo {
  35044. /**
  35045. * Name of the GLSL attribute
  35046. * if attribute index is not specified, this is used to retrieve the index from the effect
  35047. */
  35048. attributeName: string;
  35049. /**
  35050. * Index/offset of the attribute in the vertex shader
  35051. * if not specified, this will be computes from the name.
  35052. */
  35053. index?: number;
  35054. /**
  35055. * size of the attribute, 1, 2, 3 or 4
  35056. */
  35057. attributeSize: number;
  35058. /**
  35059. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35060. */
  35061. offset: number;
  35062. /**
  35063. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35064. * default to 1
  35065. */
  35066. divisor?: number;
  35067. /**
  35068. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35069. * default is FLOAT
  35070. */
  35071. attributeType?: number;
  35072. /**
  35073. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35074. */
  35075. normalized?: boolean;
  35076. }
  35077. }
  35078. declare module BABYLON {
  35079. interface ThinEngine {
  35080. /**
  35081. * Update a video texture
  35082. * @param texture defines the texture to update
  35083. * @param video defines the video element to use
  35084. * @param invertY defines if data must be stored with Y axis inverted
  35085. */
  35086. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35087. }
  35088. }
  35089. declare module BABYLON {
  35090. interface ThinEngine {
  35091. /**
  35092. * Creates a dynamic texture
  35093. * @param width defines the width of the texture
  35094. * @param height defines the height of the texture
  35095. * @param generateMipMaps defines if the engine should generate the mip levels
  35096. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35097. * @returns the dynamic texture inside an InternalTexture
  35098. */
  35099. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35100. /**
  35101. * Update the content of a dynamic texture
  35102. * @param texture defines the texture to update
  35103. * @param canvas defines the canvas containing the source
  35104. * @param invertY defines if data must be stored with Y axis inverted
  35105. * @param premulAlpha defines if alpha is stored as premultiplied
  35106. * @param format defines the format of the data
  35107. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35108. */
  35109. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35110. }
  35111. }
  35112. declare module BABYLON {
  35113. /**
  35114. * Settings for finer control over video usage
  35115. */
  35116. export interface VideoTextureSettings {
  35117. /**
  35118. * Applies `autoplay` to video, if specified
  35119. */
  35120. autoPlay?: boolean;
  35121. /**
  35122. * Applies `loop` to video, if specified
  35123. */
  35124. loop?: boolean;
  35125. /**
  35126. * Automatically updates internal texture from video at every frame in the render loop
  35127. */
  35128. autoUpdateTexture: boolean;
  35129. /**
  35130. * Image src displayed during the video loading or until the user interacts with the video.
  35131. */
  35132. poster?: string;
  35133. }
  35134. /**
  35135. * If you want to display a video in your scene, this is the special texture for that.
  35136. * This special texture works similar to other textures, with the exception of a few parameters.
  35137. * @see https://doc.babylonjs.com/how_to/video_texture
  35138. */
  35139. export class VideoTexture extends Texture {
  35140. /**
  35141. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35142. */
  35143. readonly autoUpdateTexture: boolean;
  35144. /**
  35145. * The video instance used by the texture internally
  35146. */
  35147. readonly video: HTMLVideoElement;
  35148. private _onUserActionRequestedObservable;
  35149. /**
  35150. * Event triggerd when a dom action is required by the user to play the video.
  35151. * This happens due to recent changes in browser policies preventing video to auto start.
  35152. */
  35153. get onUserActionRequestedObservable(): Observable<Texture>;
  35154. private _generateMipMaps;
  35155. private _stillImageCaptured;
  35156. private _displayingPosterTexture;
  35157. private _settings;
  35158. private _createInternalTextureOnEvent;
  35159. private _frameId;
  35160. private _currentSrc;
  35161. /**
  35162. * Creates a video texture.
  35163. * If you want to display a video in your scene, this is the special texture for that.
  35164. * This special texture works similar to other textures, with the exception of a few parameters.
  35165. * @see https://doc.babylonjs.com/how_to/video_texture
  35166. * @param name optional name, will detect from video source, if not defined
  35167. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35168. * @param scene is obviously the current scene.
  35169. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35170. * @param invertY is false by default but can be used to invert video on Y axis
  35171. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35172. * @param settings allows finer control over video usage
  35173. */
  35174. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35175. private _getName;
  35176. private _getVideo;
  35177. private _createInternalTexture;
  35178. private reset;
  35179. /**
  35180. * @hidden Internal method to initiate `update`.
  35181. */
  35182. _rebuild(): void;
  35183. /**
  35184. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35185. */
  35186. update(): void;
  35187. /**
  35188. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35189. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35190. */
  35191. updateTexture(isVisible: boolean): void;
  35192. protected _updateInternalTexture: () => void;
  35193. /**
  35194. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35195. * @param url New url.
  35196. */
  35197. updateURL(url: string): void;
  35198. /**
  35199. * Clones the texture.
  35200. * @returns the cloned texture
  35201. */
  35202. clone(): VideoTexture;
  35203. /**
  35204. * Dispose the texture and release its associated resources.
  35205. */
  35206. dispose(): void;
  35207. /**
  35208. * Creates a video texture straight from a stream.
  35209. * @param scene Define the scene the texture should be created in
  35210. * @param stream Define the stream the texture should be created from
  35211. * @returns The created video texture as a promise
  35212. */
  35213. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35214. /**
  35215. * Creates a video texture straight from your WebCam video feed.
  35216. * @param scene Define the scene the texture should be created in
  35217. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35218. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35219. * @returns The created video texture as a promise
  35220. */
  35221. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35222. minWidth: number;
  35223. maxWidth: number;
  35224. minHeight: number;
  35225. maxHeight: number;
  35226. deviceId: string;
  35227. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35228. /**
  35229. * Creates a video texture straight from your WebCam video feed.
  35230. * @param scene Define the scene the texture should be created in
  35231. * @param onReady Define a callback to triggered once the texture will be ready
  35232. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35233. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35234. */
  35235. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35236. minWidth: number;
  35237. maxWidth: number;
  35238. minHeight: number;
  35239. maxHeight: number;
  35240. deviceId: string;
  35241. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35242. }
  35243. }
  35244. declare module BABYLON {
  35245. /**
  35246. * Defines the interface used by objects working like Scene
  35247. * @hidden
  35248. */
  35249. export interface ISceneLike {
  35250. _addPendingData(data: any): void;
  35251. _removePendingData(data: any): void;
  35252. offlineProvider: IOfflineProvider;
  35253. }
  35254. /**
  35255. * Information about the current host
  35256. */
  35257. export interface HostInformation {
  35258. /**
  35259. * Defines if the current host is a mobile
  35260. */
  35261. isMobile: boolean;
  35262. }
  35263. /** Interface defining initialization parameters for Engine class */
  35264. export interface EngineOptions extends WebGLContextAttributes {
  35265. /**
  35266. * Defines if the engine should no exceed a specified device ratio
  35267. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35268. */
  35269. limitDeviceRatio?: number;
  35270. /**
  35271. * Defines if webvr should be enabled automatically
  35272. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35273. */
  35274. autoEnableWebVR?: boolean;
  35275. /**
  35276. * Defines if webgl2 should be turned off even if supported
  35277. * @see https://doc.babylonjs.com/features/webgl2
  35278. */
  35279. disableWebGL2Support?: boolean;
  35280. /**
  35281. * Defines if webaudio should be initialized as well
  35282. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35283. */
  35284. audioEngine?: boolean;
  35285. /**
  35286. * Defines if animations should run using a deterministic lock step
  35287. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35288. */
  35289. deterministicLockstep?: boolean;
  35290. /** Defines the maximum steps to use with deterministic lock step mode */
  35291. lockstepMaxSteps?: number;
  35292. /** Defines the seconds between each deterministic lock step */
  35293. timeStep?: number;
  35294. /**
  35295. * Defines that engine should ignore context lost events
  35296. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35297. */
  35298. doNotHandleContextLost?: boolean;
  35299. /**
  35300. * Defines that engine should ignore modifying touch action attribute and style
  35301. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35302. */
  35303. doNotHandleTouchAction?: boolean;
  35304. /**
  35305. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35306. */
  35307. useHighPrecisionFloats?: boolean;
  35308. /**
  35309. * Make the canvas XR Compatible for XR sessions
  35310. */
  35311. xrCompatible?: boolean;
  35312. /**
  35313. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35314. */
  35315. useHighPrecisionMatrix?: boolean;
  35316. }
  35317. /**
  35318. * The base engine class (root of all engines)
  35319. */
  35320. export class ThinEngine {
  35321. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35322. static ExceptionList: ({
  35323. key: string;
  35324. capture: string;
  35325. captureConstraint: number;
  35326. targets: string[];
  35327. } | {
  35328. key: string;
  35329. capture: null;
  35330. captureConstraint: null;
  35331. targets: string[];
  35332. })[];
  35333. /** @hidden */
  35334. static _TextureLoaders: IInternalTextureLoader[];
  35335. /**
  35336. * Returns the current npm package of the sdk
  35337. */
  35338. static get NpmPackage(): string;
  35339. /**
  35340. * Returns the current version of the framework
  35341. */
  35342. static get Version(): string;
  35343. /**
  35344. * Returns a string describing the current engine
  35345. */
  35346. get description(): string;
  35347. /**
  35348. * Gets or sets the epsilon value used by collision engine
  35349. */
  35350. static CollisionsEpsilon: number;
  35351. /**
  35352. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35353. */
  35354. static get ShadersRepository(): string;
  35355. static set ShadersRepository(value: string);
  35356. /** @hidden */
  35357. _shaderProcessor: IShaderProcessor;
  35358. /**
  35359. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35360. */
  35361. forcePOTTextures: boolean;
  35362. /**
  35363. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35364. */
  35365. isFullscreen: boolean;
  35366. /**
  35367. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35368. */
  35369. cullBackFaces: boolean;
  35370. /**
  35371. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35372. */
  35373. renderEvenInBackground: boolean;
  35374. /**
  35375. * Gets or sets a boolean indicating that cache can be kept between frames
  35376. */
  35377. preventCacheWipeBetweenFrames: boolean;
  35378. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35379. validateShaderPrograms: boolean;
  35380. /**
  35381. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35382. * This can provide greater z depth for distant objects.
  35383. */
  35384. useReverseDepthBuffer: boolean;
  35385. /**
  35386. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35387. */
  35388. disableUniformBuffers: boolean;
  35389. /** @hidden */
  35390. _uniformBuffers: UniformBuffer[];
  35391. /**
  35392. * Gets a boolean indicating that the engine supports uniform buffers
  35393. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35394. */
  35395. get supportsUniformBuffers(): boolean;
  35396. /** @hidden */
  35397. _gl: WebGLRenderingContext;
  35398. /** @hidden */
  35399. _webGLVersion: number;
  35400. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35401. protected _windowIsBackground: boolean;
  35402. protected _creationOptions: EngineOptions;
  35403. protected _highPrecisionShadersAllowed: boolean;
  35404. /** @hidden */
  35405. get _shouldUseHighPrecisionShader(): boolean;
  35406. /**
  35407. * Gets a boolean indicating that only power of 2 textures are supported
  35408. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35409. */
  35410. get needPOTTextures(): boolean;
  35411. /** @hidden */
  35412. _badOS: boolean;
  35413. /** @hidden */
  35414. _badDesktopOS: boolean;
  35415. private _hardwareScalingLevel;
  35416. /** @hidden */
  35417. _caps: EngineCapabilities;
  35418. private _isStencilEnable;
  35419. private _glVersion;
  35420. private _glRenderer;
  35421. private _glVendor;
  35422. /** @hidden */
  35423. _videoTextureSupported: boolean;
  35424. protected _renderingQueueLaunched: boolean;
  35425. protected _activeRenderLoops: (() => void)[];
  35426. /**
  35427. * Observable signaled when a context lost event is raised
  35428. */
  35429. onContextLostObservable: Observable<ThinEngine>;
  35430. /**
  35431. * Observable signaled when a context restored event is raised
  35432. */
  35433. onContextRestoredObservable: Observable<ThinEngine>;
  35434. private _onContextLost;
  35435. private _onContextRestored;
  35436. protected _contextWasLost: boolean;
  35437. /** @hidden */
  35438. _doNotHandleContextLost: boolean;
  35439. /**
  35440. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35441. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35442. */
  35443. get doNotHandleContextLost(): boolean;
  35444. set doNotHandleContextLost(value: boolean);
  35445. /**
  35446. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35447. */
  35448. disableVertexArrayObjects: boolean;
  35449. /** @hidden */
  35450. protected _colorWrite: boolean;
  35451. /** @hidden */
  35452. protected _colorWriteChanged: boolean;
  35453. /** @hidden */
  35454. protected _depthCullingState: DepthCullingState;
  35455. /** @hidden */
  35456. protected _stencilState: StencilState;
  35457. /** @hidden */
  35458. _alphaState: AlphaState;
  35459. /** @hidden */
  35460. _alphaMode: number;
  35461. /** @hidden */
  35462. _alphaEquation: number;
  35463. /** @hidden */
  35464. _internalTexturesCache: InternalTexture[];
  35465. /** @hidden */
  35466. protected _activeChannel: number;
  35467. private _currentTextureChannel;
  35468. /** @hidden */
  35469. protected _boundTexturesCache: {
  35470. [key: string]: Nullable<InternalTexture>;
  35471. };
  35472. /** @hidden */
  35473. protected _currentEffect: Nullable<Effect>;
  35474. /** @hidden */
  35475. protected _currentProgram: Nullable<WebGLProgram>;
  35476. private _compiledEffects;
  35477. private _vertexAttribArraysEnabled;
  35478. /** @hidden */
  35479. protected _cachedViewport: Nullable<IViewportLike>;
  35480. private _cachedVertexArrayObject;
  35481. /** @hidden */
  35482. protected _cachedVertexBuffers: any;
  35483. /** @hidden */
  35484. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35485. /** @hidden */
  35486. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35487. /** @hidden */
  35488. _currentRenderTarget: Nullable<InternalTexture>;
  35489. private _uintIndicesCurrentlySet;
  35490. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35491. /** @hidden */
  35492. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35493. /** @hidden */
  35494. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35495. private _currentBufferPointers;
  35496. private _currentInstanceLocations;
  35497. private _currentInstanceBuffers;
  35498. private _textureUnits;
  35499. /** @hidden */
  35500. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35501. /** @hidden */
  35502. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35503. /** @hidden */
  35504. _boundRenderFunction: any;
  35505. private _vaoRecordInProgress;
  35506. private _mustWipeVertexAttributes;
  35507. private _emptyTexture;
  35508. private _emptyCubeTexture;
  35509. private _emptyTexture3D;
  35510. private _emptyTexture2DArray;
  35511. /** @hidden */
  35512. _frameHandler: number;
  35513. private _nextFreeTextureSlots;
  35514. private _maxSimultaneousTextures;
  35515. private _activeRequests;
  35516. /** @hidden */
  35517. _transformTextureUrl: Nullable<(url: string) => string>;
  35518. /**
  35519. * Gets information about the current host
  35520. */
  35521. hostInformation: HostInformation;
  35522. protected get _supportsHardwareTextureRescaling(): boolean;
  35523. private _framebufferDimensionsObject;
  35524. /**
  35525. * sets the object from which width and height will be taken from when getting render width and height
  35526. * Will fallback to the gl object
  35527. * @param dimensions the framebuffer width and height that will be used.
  35528. */
  35529. set framebufferDimensionsObject(dimensions: Nullable<{
  35530. framebufferWidth: number;
  35531. framebufferHeight: number;
  35532. }>);
  35533. /**
  35534. * Gets the current viewport
  35535. */
  35536. get currentViewport(): Nullable<IViewportLike>;
  35537. /**
  35538. * Gets the default empty texture
  35539. */
  35540. get emptyTexture(): InternalTexture;
  35541. /**
  35542. * Gets the default empty 3D texture
  35543. */
  35544. get emptyTexture3D(): InternalTexture;
  35545. /**
  35546. * Gets the default empty 2D array texture
  35547. */
  35548. get emptyTexture2DArray(): InternalTexture;
  35549. /**
  35550. * Gets the default empty cube texture
  35551. */
  35552. get emptyCubeTexture(): InternalTexture;
  35553. /**
  35554. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35555. */
  35556. readonly premultipliedAlpha: boolean;
  35557. /**
  35558. * Observable event triggered before each texture is initialized
  35559. */
  35560. onBeforeTextureInitObservable: Observable<Texture>;
  35561. /**
  35562. * Creates a new engine
  35563. * @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
  35564. * @param antialias defines enable antialiasing (default: false)
  35565. * @param options defines further options to be sent to the getContext() function
  35566. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35567. */
  35568. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35569. private _rebuildInternalTextures;
  35570. private _rebuildEffects;
  35571. /**
  35572. * Gets a boolean indicating if all created effects are ready
  35573. * @returns true if all effects are ready
  35574. */
  35575. areAllEffectsReady(): boolean;
  35576. protected _rebuildBuffers(): void;
  35577. protected _initGLContext(): void;
  35578. /**
  35579. * Gets version of the current webGL context
  35580. */
  35581. get webGLVersion(): number;
  35582. /**
  35583. * Gets a string identifying the name of the class
  35584. * @returns "Engine" string
  35585. */
  35586. getClassName(): string;
  35587. /**
  35588. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35589. */
  35590. get isStencilEnable(): boolean;
  35591. /** @hidden */
  35592. _prepareWorkingCanvas(): void;
  35593. /**
  35594. * Reset the texture cache to empty state
  35595. */
  35596. resetTextureCache(): void;
  35597. /**
  35598. * Gets an object containing information about the current webGL context
  35599. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35600. */
  35601. getGlInfo(): {
  35602. vendor: string;
  35603. renderer: string;
  35604. version: string;
  35605. };
  35606. /**
  35607. * Defines the hardware scaling level.
  35608. * By default the hardware scaling level is computed from the window device ratio.
  35609. * 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.
  35610. * @param level defines the level to use
  35611. */
  35612. setHardwareScalingLevel(level: number): void;
  35613. /**
  35614. * Gets the current hardware scaling level.
  35615. * By default the hardware scaling level is computed from the window device ratio.
  35616. * 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.
  35617. * @returns a number indicating the current hardware scaling level
  35618. */
  35619. getHardwareScalingLevel(): number;
  35620. /**
  35621. * Gets the list of loaded textures
  35622. * @returns an array containing all loaded textures
  35623. */
  35624. getLoadedTexturesCache(): InternalTexture[];
  35625. /**
  35626. * Gets the object containing all engine capabilities
  35627. * @returns the EngineCapabilities object
  35628. */
  35629. getCaps(): EngineCapabilities;
  35630. /**
  35631. * stop executing a render loop function and remove it from the execution array
  35632. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35633. */
  35634. stopRenderLoop(renderFunction?: () => void): void;
  35635. /** @hidden */
  35636. _renderLoop(): void;
  35637. /**
  35638. * Gets the HTML canvas attached with the current webGL context
  35639. * @returns a HTML canvas
  35640. */
  35641. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35642. /**
  35643. * Gets host window
  35644. * @returns the host window object
  35645. */
  35646. getHostWindow(): Nullable<Window>;
  35647. /**
  35648. * Gets the current render width
  35649. * @param useScreen defines if screen size must be used (or the current render target if any)
  35650. * @returns a number defining the current render width
  35651. */
  35652. getRenderWidth(useScreen?: boolean): number;
  35653. /**
  35654. * Gets the current render height
  35655. * @param useScreen defines if screen size must be used (or the current render target if any)
  35656. * @returns a number defining the current render height
  35657. */
  35658. getRenderHeight(useScreen?: boolean): number;
  35659. /**
  35660. * Can be used to override the current requestAnimationFrame requester.
  35661. * @hidden
  35662. */
  35663. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35664. /**
  35665. * Register and execute a render loop. The engine can have more than one render function
  35666. * @param renderFunction defines the function to continuously execute
  35667. */
  35668. runRenderLoop(renderFunction: () => void): void;
  35669. /**
  35670. * Clear the current render buffer or the current render target (if any is set up)
  35671. * @param color defines the color to use
  35672. * @param backBuffer defines if the back buffer must be cleared
  35673. * @param depth defines if the depth buffer must be cleared
  35674. * @param stencil defines if the stencil buffer must be cleared
  35675. */
  35676. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35677. private _viewportCached;
  35678. /** @hidden */
  35679. _viewport(x: number, y: number, width: number, height: number): void;
  35680. /**
  35681. * Set the WebGL's viewport
  35682. * @param viewport defines the viewport element to be used
  35683. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35684. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35685. */
  35686. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35687. /**
  35688. * Begin a new frame
  35689. */
  35690. beginFrame(): void;
  35691. /**
  35692. * Enf the current frame
  35693. */
  35694. endFrame(): void;
  35695. /**
  35696. * Resize the view according to the canvas' size
  35697. */
  35698. resize(): void;
  35699. /**
  35700. * Force a specific size of the canvas
  35701. * @param width defines the new canvas' width
  35702. * @param height defines the new canvas' height
  35703. * @returns true if the size was changed
  35704. */
  35705. setSize(width: number, height: number): boolean;
  35706. /**
  35707. * Binds the frame buffer to the specified texture.
  35708. * @param texture The texture to render to or null for the default canvas
  35709. * @param faceIndex The face of the texture to render to in case of cube texture
  35710. * @param requiredWidth The width of the target to render to
  35711. * @param requiredHeight The height of the target to render to
  35712. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35713. * @param lodLevel defines the lod level to bind to the frame buffer
  35714. * @param layer defines the 2d array index to bind to frame buffer to
  35715. */
  35716. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35717. /** @hidden */
  35718. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35719. /**
  35720. * Unbind the current render target texture from the webGL context
  35721. * @param texture defines the render target texture to unbind
  35722. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35723. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35724. */
  35725. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35726. /**
  35727. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35728. */
  35729. flushFramebuffer(): void;
  35730. /**
  35731. * Unbind the current render target and bind the default framebuffer
  35732. */
  35733. restoreDefaultFramebuffer(): void;
  35734. /** @hidden */
  35735. protected _resetVertexBufferBinding(): void;
  35736. /**
  35737. * Creates a vertex buffer
  35738. * @param data the data for the vertex buffer
  35739. * @returns the new WebGL static buffer
  35740. */
  35741. createVertexBuffer(data: DataArray): DataBuffer;
  35742. private _createVertexBuffer;
  35743. /**
  35744. * Creates a dynamic vertex buffer
  35745. * @param data the data for the dynamic vertex buffer
  35746. * @returns the new WebGL dynamic buffer
  35747. */
  35748. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35749. protected _resetIndexBufferBinding(): void;
  35750. /**
  35751. * Creates a new index buffer
  35752. * @param indices defines the content of the index buffer
  35753. * @param updatable defines if the index buffer must be updatable
  35754. * @returns a new webGL buffer
  35755. */
  35756. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35757. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35758. /**
  35759. * Bind a webGL buffer to the webGL context
  35760. * @param buffer defines the buffer to bind
  35761. */
  35762. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35763. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35764. private bindBuffer;
  35765. /**
  35766. * update the bound buffer with the given data
  35767. * @param data defines the data to update
  35768. */
  35769. updateArrayBuffer(data: Float32Array): void;
  35770. private _vertexAttribPointer;
  35771. /** @hidden */
  35772. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35773. private _bindVertexBuffersAttributes;
  35774. /**
  35775. * Records a vertex array object
  35776. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35777. * @param vertexBuffers defines the list of vertex buffers to store
  35778. * @param indexBuffer defines the index buffer to store
  35779. * @param effect defines the effect to store
  35780. * @returns the new vertex array object
  35781. */
  35782. recordVertexArrayObject(vertexBuffers: {
  35783. [key: string]: VertexBuffer;
  35784. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35785. /**
  35786. * Bind a specific vertex array object
  35787. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35788. * @param vertexArrayObject defines the vertex array object to bind
  35789. * @param indexBuffer defines the index buffer to bind
  35790. */
  35791. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35792. /**
  35793. * Bind webGl buffers directly to the webGL context
  35794. * @param vertexBuffer defines the vertex buffer to bind
  35795. * @param indexBuffer defines the index buffer to bind
  35796. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35797. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35798. * @param effect defines the effect associated with the vertex buffer
  35799. */
  35800. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35801. private _unbindVertexArrayObject;
  35802. /**
  35803. * Bind a list of vertex buffers to the webGL context
  35804. * @param vertexBuffers defines the list of vertex buffers to bind
  35805. * @param indexBuffer defines the index buffer to bind
  35806. * @param effect defines the effect associated with the vertex buffers
  35807. */
  35808. bindBuffers(vertexBuffers: {
  35809. [key: string]: Nullable<VertexBuffer>;
  35810. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35811. /**
  35812. * Unbind all instance attributes
  35813. */
  35814. unbindInstanceAttributes(): void;
  35815. /**
  35816. * Release and free the memory of a vertex array object
  35817. * @param vao defines the vertex array object to delete
  35818. */
  35819. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35820. /** @hidden */
  35821. _releaseBuffer(buffer: DataBuffer): boolean;
  35822. protected _deleteBuffer(buffer: DataBuffer): void;
  35823. /**
  35824. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35825. * @param instancesBuffer defines the webGL buffer to update and bind
  35826. * @param data defines the data to store in the buffer
  35827. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35828. */
  35829. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35830. /**
  35831. * Bind the content of a webGL buffer used with instantiation
  35832. * @param instancesBuffer defines the webGL buffer to bind
  35833. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35834. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35835. */
  35836. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35837. /**
  35838. * Disable the instance attribute corresponding to the name in parameter
  35839. * @param name defines the name of the attribute to disable
  35840. */
  35841. disableInstanceAttributeByName(name: string): void;
  35842. /**
  35843. * Disable the instance attribute corresponding to the location in parameter
  35844. * @param attributeLocation defines the attribute location of the attribute to disable
  35845. */
  35846. disableInstanceAttribute(attributeLocation: number): void;
  35847. /**
  35848. * Disable the attribute corresponding to the location in parameter
  35849. * @param attributeLocation defines the attribute location of the attribute to disable
  35850. */
  35851. disableAttributeByIndex(attributeLocation: number): void;
  35852. /**
  35853. * Send a draw order
  35854. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35855. * @param indexStart defines the starting index
  35856. * @param indexCount defines the number of index to draw
  35857. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35858. */
  35859. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35860. /**
  35861. * Draw a list of points
  35862. * @param verticesStart defines the index of first vertex to draw
  35863. * @param verticesCount defines the count of vertices to draw
  35864. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35865. */
  35866. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35867. /**
  35868. * Draw a list of unindexed primitives
  35869. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35870. * @param verticesStart defines the index of first vertex to draw
  35871. * @param verticesCount defines the count of vertices to draw
  35872. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35873. */
  35874. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35875. /**
  35876. * Draw a list of indexed primitives
  35877. * @param fillMode defines the primitive to use
  35878. * @param indexStart defines the starting index
  35879. * @param indexCount defines the number of index to draw
  35880. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35881. */
  35882. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35883. /**
  35884. * Draw a list of unindexed primitives
  35885. * @param fillMode defines the primitive to use
  35886. * @param verticesStart defines the index of first vertex to draw
  35887. * @param verticesCount defines the count of vertices to draw
  35888. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35889. */
  35890. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35891. private _drawMode;
  35892. /** @hidden */
  35893. protected _reportDrawCall(): void;
  35894. /** @hidden */
  35895. _releaseEffect(effect: Effect): void;
  35896. /** @hidden */
  35897. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35898. /**
  35899. * Create a new effect (used to store vertex/fragment shaders)
  35900. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35901. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35902. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35903. * @param samplers defines an array of string used to represent textures
  35904. * @param defines defines the string containing the defines to use to compile the shaders
  35905. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35906. * @param onCompiled defines a function to call when the effect creation is successful
  35907. * @param onError defines a function to call when the effect creation has failed
  35908. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35909. * @returns the new Effect
  35910. */
  35911. 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;
  35912. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35913. private _compileShader;
  35914. private _compileRawShader;
  35915. /** @hidden */
  35916. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35917. /**
  35918. * Directly creates a webGL program
  35919. * @param pipelineContext defines the pipeline context to attach to
  35920. * @param vertexCode defines the vertex shader code to use
  35921. * @param fragmentCode defines the fragment shader code to use
  35922. * @param context defines the webGL context to use (if not set, the current one will be used)
  35923. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35924. * @returns the new webGL program
  35925. */
  35926. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35927. /**
  35928. * Creates a webGL program
  35929. * @param pipelineContext defines the pipeline context to attach to
  35930. * @param vertexCode defines the vertex shader code to use
  35931. * @param fragmentCode defines the fragment shader code to use
  35932. * @param defines defines the string containing the defines to use to compile the shaders
  35933. * @param context defines the webGL context to use (if not set, the current one will be used)
  35934. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35935. * @returns the new webGL program
  35936. */
  35937. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35938. /**
  35939. * Creates a new pipeline context
  35940. * @returns the new pipeline
  35941. */
  35942. createPipelineContext(): IPipelineContext;
  35943. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35944. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35945. /** @hidden */
  35946. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35947. /** @hidden */
  35948. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35949. /** @hidden */
  35950. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35951. /**
  35952. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35953. * @param pipelineContext defines the pipeline context to use
  35954. * @param uniformsNames defines the list of uniform names
  35955. * @returns an array of webGL uniform locations
  35956. */
  35957. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35958. /**
  35959. * Gets the lsit of active attributes for a given webGL program
  35960. * @param pipelineContext defines the pipeline context to use
  35961. * @param attributesNames defines the list of attribute names to get
  35962. * @returns an array of indices indicating the offset of each attribute
  35963. */
  35964. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35965. /**
  35966. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35967. * @param effect defines the effect to activate
  35968. */
  35969. enableEffect(effect: Nullable<Effect>): void;
  35970. /**
  35971. * Set the value of an uniform to a number (int)
  35972. * @param uniform defines the webGL uniform location where to store the value
  35973. * @param value defines the int number to store
  35974. */
  35975. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35976. /**
  35977. * Set the value of an uniform to an array of int32
  35978. * @param uniform defines the webGL uniform location where to store the value
  35979. * @param array defines the array of int32 to store
  35980. */
  35981. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35982. /**
  35983. * Set the value of an uniform to an array of int32 (stored as vec2)
  35984. * @param uniform defines the webGL uniform location where to store the value
  35985. * @param array defines the array of int32 to store
  35986. */
  35987. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35988. /**
  35989. * Set the value of an uniform to an array of int32 (stored as vec3)
  35990. * @param uniform defines the webGL uniform location where to store the value
  35991. * @param array defines the array of int32 to store
  35992. */
  35993. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35994. /**
  35995. * Set the value of an uniform to an array of int32 (stored as vec4)
  35996. * @param uniform defines the webGL uniform location where to store the value
  35997. * @param array defines the array of int32 to store
  35998. */
  35999. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36000. /**
  36001. * Set the value of an uniform to an array of number
  36002. * @param uniform defines the webGL uniform location where to store the value
  36003. * @param array defines the array of number to store
  36004. */
  36005. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36006. /**
  36007. * Set the value of an uniform to an array of number (stored as vec2)
  36008. * @param uniform defines the webGL uniform location where to store the value
  36009. * @param array defines the array of number to store
  36010. */
  36011. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36012. /**
  36013. * Set the value of an uniform to an array of number (stored as vec3)
  36014. * @param uniform defines the webGL uniform location where to store the value
  36015. * @param array defines the array of number to store
  36016. */
  36017. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36018. /**
  36019. * Set the value of an uniform to an array of number (stored as vec4)
  36020. * @param uniform defines the webGL uniform location where to store the value
  36021. * @param array defines the array of number to store
  36022. */
  36023. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36024. /**
  36025. * Set the value of an uniform to an array of float32 (stored as matrices)
  36026. * @param uniform defines the webGL uniform location where to store the value
  36027. * @param matrices defines the array of float32 to store
  36028. */
  36029. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36030. /**
  36031. * Set the value of an uniform to a matrix (3x3)
  36032. * @param uniform defines the webGL uniform location where to store the value
  36033. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36034. */
  36035. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36036. /**
  36037. * Set the value of an uniform to a matrix (2x2)
  36038. * @param uniform defines the webGL uniform location where to store the value
  36039. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36040. */
  36041. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36042. /**
  36043. * Set the value of an uniform to a number (float)
  36044. * @param uniform defines the webGL uniform location where to store the value
  36045. * @param value defines the float number to store
  36046. */
  36047. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36048. /**
  36049. * Set the value of an uniform to a vec2
  36050. * @param uniform defines the webGL uniform location where to store the value
  36051. * @param x defines the 1st component of the value
  36052. * @param y defines the 2nd component of the value
  36053. */
  36054. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36055. /**
  36056. * Set the value of an uniform to a vec3
  36057. * @param uniform defines the webGL uniform location where to store the value
  36058. * @param x defines the 1st component of the value
  36059. * @param y defines the 2nd component of the value
  36060. * @param z defines the 3rd component of the value
  36061. */
  36062. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36063. /**
  36064. * Set the value of an uniform to a vec4
  36065. * @param uniform defines the webGL uniform location where to store the value
  36066. * @param x defines the 1st component of the value
  36067. * @param y defines the 2nd component of the value
  36068. * @param z defines the 3rd component of the value
  36069. * @param w defines the 4th component of the value
  36070. */
  36071. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36072. /**
  36073. * Apply all cached states (depth, culling, stencil and alpha)
  36074. */
  36075. applyStates(): void;
  36076. /**
  36077. * Enable or disable color writing
  36078. * @param enable defines the state to set
  36079. */
  36080. setColorWrite(enable: boolean): void;
  36081. /**
  36082. * Gets a boolean indicating if color writing is enabled
  36083. * @returns the current color writing state
  36084. */
  36085. getColorWrite(): boolean;
  36086. /**
  36087. * Gets the depth culling state manager
  36088. */
  36089. get depthCullingState(): DepthCullingState;
  36090. /**
  36091. * Gets the alpha state manager
  36092. */
  36093. get alphaState(): AlphaState;
  36094. /**
  36095. * Gets the stencil state manager
  36096. */
  36097. get stencilState(): StencilState;
  36098. /**
  36099. * Clears the list of texture accessible through engine.
  36100. * This can help preventing texture load conflict due to name collision.
  36101. */
  36102. clearInternalTexturesCache(): void;
  36103. /**
  36104. * Force the entire cache to be cleared
  36105. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36106. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36107. */
  36108. wipeCaches(bruteForce?: boolean): void;
  36109. /** @hidden */
  36110. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36111. min: number;
  36112. mag: number;
  36113. };
  36114. /** @hidden */
  36115. _createTexture(): WebGLTexture;
  36116. /**
  36117. * Usually called from Texture.ts.
  36118. * Passed information to create a WebGLTexture
  36119. * @param url defines a value which contains one of the following:
  36120. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36121. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36122. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36123. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36124. * @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)
  36125. * @param scene needed for loading to the correct scene
  36126. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36127. * @param onLoad optional callback to be called upon successful completion
  36128. * @param onError optional callback to be called upon failure
  36129. * @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
  36130. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36131. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36132. * @param forcedExtension defines the extension to use to pick the right loader
  36133. * @param mimeType defines an optional mime type
  36134. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36135. */
  36136. 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;
  36137. /**
  36138. * Loads an image as an HTMLImageElement.
  36139. * @param input url string, ArrayBuffer, or Blob to load
  36140. * @param onLoad callback called when the image successfully loads
  36141. * @param onError callback called when the image fails to load
  36142. * @param offlineProvider offline provider for caching
  36143. * @param mimeType optional mime type
  36144. * @returns the HTMLImageElement of the loaded image
  36145. * @hidden
  36146. */
  36147. 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>;
  36148. /**
  36149. * @hidden
  36150. */
  36151. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36152. private _unpackFlipYCached;
  36153. /**
  36154. * In case you are sharing the context with other applications, it might
  36155. * be interested to not cache the unpack flip y state to ensure a consistent
  36156. * value would be set.
  36157. */
  36158. enableUnpackFlipYCached: boolean;
  36159. /** @hidden */
  36160. _unpackFlipY(value: boolean): void;
  36161. /** @hidden */
  36162. _getUnpackAlignement(): number;
  36163. private _getTextureTarget;
  36164. /**
  36165. * Update the sampling mode of a given texture
  36166. * @param samplingMode defines the required sampling mode
  36167. * @param texture defines the texture to update
  36168. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36169. */
  36170. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36171. /**
  36172. * Update the sampling mode of a given texture
  36173. * @param texture defines the texture to update
  36174. * @param wrapU defines the texture wrap mode of the u coordinates
  36175. * @param wrapV defines the texture wrap mode of the v coordinates
  36176. * @param wrapR defines the texture wrap mode of the r coordinates
  36177. */
  36178. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36179. /** @hidden */
  36180. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36181. width: number;
  36182. height: number;
  36183. layers?: number;
  36184. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36185. /** @hidden */
  36186. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36187. /** @hidden */
  36188. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36189. /**
  36190. * Update a portion of an internal texture
  36191. * @param texture defines the texture to update
  36192. * @param imageData defines the data to store into the texture
  36193. * @param xOffset defines the x coordinates of the update rectangle
  36194. * @param yOffset defines the y coordinates of the update rectangle
  36195. * @param width defines the width of the update rectangle
  36196. * @param height defines the height of the update rectangle
  36197. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36198. * @param lod defines the lod level to update (0 by default)
  36199. */
  36200. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36201. /** @hidden */
  36202. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36203. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36204. private _prepareWebGLTexture;
  36205. /** @hidden */
  36206. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36207. private _getDepthStencilBuffer;
  36208. /** @hidden */
  36209. _releaseFramebufferObjects(texture: InternalTexture): void;
  36210. /** @hidden */
  36211. _releaseTexture(texture: InternalTexture): void;
  36212. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36213. protected _setProgram(program: WebGLProgram): void;
  36214. protected _boundUniforms: {
  36215. [key: number]: WebGLUniformLocation;
  36216. };
  36217. /**
  36218. * Binds an effect to the webGL context
  36219. * @param effect defines the effect to bind
  36220. */
  36221. bindSamplers(effect: Effect): void;
  36222. private _activateCurrentTexture;
  36223. /** @hidden */
  36224. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36225. /** @hidden */
  36226. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36227. /**
  36228. * Unbind all textures from the webGL context
  36229. */
  36230. unbindAllTextures(): void;
  36231. /**
  36232. * Sets a texture to the according uniform.
  36233. * @param channel The texture channel
  36234. * @param uniform The uniform to set
  36235. * @param texture The texture to apply
  36236. */
  36237. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36238. private _bindSamplerUniformToChannel;
  36239. private _getTextureWrapMode;
  36240. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36241. /**
  36242. * Sets an array of texture to the webGL context
  36243. * @param channel defines the channel where the texture array must be set
  36244. * @param uniform defines the associated uniform location
  36245. * @param textures defines the array of textures to bind
  36246. */
  36247. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36248. /** @hidden */
  36249. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36250. private _setTextureParameterFloat;
  36251. private _setTextureParameterInteger;
  36252. /**
  36253. * Unbind all vertex attributes from the webGL context
  36254. */
  36255. unbindAllAttributes(): void;
  36256. /**
  36257. * 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
  36258. */
  36259. releaseEffects(): void;
  36260. /**
  36261. * Dispose and release all associated resources
  36262. */
  36263. dispose(): void;
  36264. /**
  36265. * Attach a new callback raised when context lost event is fired
  36266. * @param callback defines the callback to call
  36267. */
  36268. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36269. /**
  36270. * Attach a new callback raised when context restored event is fired
  36271. * @param callback defines the callback to call
  36272. */
  36273. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36274. /**
  36275. * Get the current error code of the webGL context
  36276. * @returns the error code
  36277. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36278. */
  36279. getError(): number;
  36280. private _canRenderToFloatFramebuffer;
  36281. private _canRenderToHalfFloatFramebuffer;
  36282. private _canRenderToFramebuffer;
  36283. /** @hidden */
  36284. _getWebGLTextureType(type: number): number;
  36285. /** @hidden */
  36286. _getInternalFormat(format: number): number;
  36287. /** @hidden */
  36288. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36289. /** @hidden */
  36290. _getRGBAMultiSampleBufferFormat(type: number): number;
  36291. /** @hidden */
  36292. _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;
  36293. /**
  36294. * Loads a file from a url
  36295. * @param url url to load
  36296. * @param onSuccess callback called when the file successfully loads
  36297. * @param onProgress callback called while file is loading (if the server supports this mode)
  36298. * @param offlineProvider defines the offline provider for caching
  36299. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36300. * @param onError callback called when the file fails to load
  36301. * @returns a file request object
  36302. * @hidden
  36303. */
  36304. 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;
  36305. /**
  36306. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36307. * @param x defines the x coordinate of the rectangle where pixels must be read
  36308. * @param y defines the y coordinate of the rectangle where pixels must be read
  36309. * @param width defines the width of the rectangle where pixels must be read
  36310. * @param height defines the height of the rectangle where pixels must be read
  36311. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36312. * @returns a Uint8Array containing RGBA colors
  36313. */
  36314. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36315. private static _isSupported;
  36316. /**
  36317. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36318. * @returns true if the engine can be created
  36319. * @ignorenaming
  36320. */
  36321. static isSupported(): boolean;
  36322. /**
  36323. * Find the next highest power of two.
  36324. * @param x Number to start search from.
  36325. * @return Next highest power of two.
  36326. */
  36327. static CeilingPOT(x: number): number;
  36328. /**
  36329. * Find the next lowest power of two.
  36330. * @param x Number to start search from.
  36331. * @return Next lowest power of two.
  36332. */
  36333. static FloorPOT(x: number): number;
  36334. /**
  36335. * Find the nearest power of two.
  36336. * @param x Number to start search from.
  36337. * @return Next nearest power of two.
  36338. */
  36339. static NearestPOT(x: number): number;
  36340. /**
  36341. * Get the closest exponent of two
  36342. * @param value defines the value to approximate
  36343. * @param max defines the maximum value to return
  36344. * @param mode defines how to define the closest value
  36345. * @returns closest exponent of two of the given value
  36346. */
  36347. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36348. /**
  36349. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36350. * @param func - the function to be called
  36351. * @param requester - the object that will request the next frame. Falls back to window.
  36352. * @returns frame number
  36353. */
  36354. static QueueNewFrame(func: () => void, requester?: any): number;
  36355. /**
  36356. * Gets host document
  36357. * @returns the host document object
  36358. */
  36359. getHostDocument(): Nullable<Document>;
  36360. }
  36361. }
  36362. declare module BABYLON {
  36363. /**
  36364. * Class representing spherical harmonics coefficients to the 3rd degree
  36365. */
  36366. export class SphericalHarmonics {
  36367. /**
  36368. * Defines whether or not the harmonics have been prescaled for rendering.
  36369. */
  36370. preScaled: boolean;
  36371. /**
  36372. * The l0,0 coefficients of the spherical harmonics
  36373. */
  36374. l00: Vector3;
  36375. /**
  36376. * The l1,-1 coefficients of the spherical harmonics
  36377. */
  36378. l1_1: Vector3;
  36379. /**
  36380. * The l1,0 coefficients of the spherical harmonics
  36381. */
  36382. l10: Vector3;
  36383. /**
  36384. * The l1,1 coefficients of the spherical harmonics
  36385. */
  36386. l11: Vector3;
  36387. /**
  36388. * The l2,-2 coefficients of the spherical harmonics
  36389. */
  36390. l2_2: Vector3;
  36391. /**
  36392. * The l2,-1 coefficients of the spherical harmonics
  36393. */
  36394. l2_1: Vector3;
  36395. /**
  36396. * The l2,0 coefficients of the spherical harmonics
  36397. */
  36398. l20: Vector3;
  36399. /**
  36400. * The l2,1 coefficients of the spherical harmonics
  36401. */
  36402. l21: Vector3;
  36403. /**
  36404. * The l2,2 coefficients of the spherical harmonics
  36405. */
  36406. l22: Vector3;
  36407. /**
  36408. * Adds a light to the spherical harmonics
  36409. * @param direction the direction of the light
  36410. * @param color the color of the light
  36411. * @param deltaSolidAngle the delta solid angle of the light
  36412. */
  36413. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36414. /**
  36415. * Scales the spherical harmonics by the given amount
  36416. * @param scale the amount to scale
  36417. */
  36418. scaleInPlace(scale: number): void;
  36419. /**
  36420. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36421. *
  36422. * ```
  36423. * E_lm = A_l * L_lm
  36424. * ```
  36425. *
  36426. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36427. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36428. * the scaling factors are given in equation 9.
  36429. */
  36430. convertIncidentRadianceToIrradiance(): void;
  36431. /**
  36432. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36433. *
  36434. * ```
  36435. * L = (1/pi) * E * rho
  36436. * ```
  36437. *
  36438. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36439. */
  36440. convertIrradianceToLambertianRadiance(): void;
  36441. /**
  36442. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36443. * required operations at run time.
  36444. *
  36445. * This is simply done by scaling back the SH with Ylm constants parameter.
  36446. * The trigonometric part being applied by the shader at run time.
  36447. */
  36448. preScaleForRendering(): void;
  36449. /**
  36450. * Constructs a spherical harmonics from an array.
  36451. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36452. * @returns the spherical harmonics
  36453. */
  36454. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36455. /**
  36456. * Gets the spherical harmonics from polynomial
  36457. * @param polynomial the spherical polynomial
  36458. * @returns the spherical harmonics
  36459. */
  36460. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36461. }
  36462. /**
  36463. * Class representing spherical polynomial coefficients to the 3rd degree
  36464. */
  36465. export class SphericalPolynomial {
  36466. private _harmonics;
  36467. /**
  36468. * The spherical harmonics used to create the polynomials.
  36469. */
  36470. get preScaledHarmonics(): SphericalHarmonics;
  36471. /**
  36472. * The x coefficients of the spherical polynomial
  36473. */
  36474. x: Vector3;
  36475. /**
  36476. * The y coefficients of the spherical polynomial
  36477. */
  36478. y: Vector3;
  36479. /**
  36480. * The z coefficients of the spherical polynomial
  36481. */
  36482. z: Vector3;
  36483. /**
  36484. * The xx coefficients of the spherical polynomial
  36485. */
  36486. xx: Vector3;
  36487. /**
  36488. * The yy coefficients of the spherical polynomial
  36489. */
  36490. yy: Vector3;
  36491. /**
  36492. * The zz coefficients of the spherical polynomial
  36493. */
  36494. zz: Vector3;
  36495. /**
  36496. * The xy coefficients of the spherical polynomial
  36497. */
  36498. xy: Vector3;
  36499. /**
  36500. * The yz coefficients of the spherical polynomial
  36501. */
  36502. yz: Vector3;
  36503. /**
  36504. * The zx coefficients of the spherical polynomial
  36505. */
  36506. zx: Vector3;
  36507. /**
  36508. * Adds an ambient color to the spherical polynomial
  36509. * @param color the color to add
  36510. */
  36511. addAmbient(color: Color3): void;
  36512. /**
  36513. * Scales the spherical polynomial by the given amount
  36514. * @param scale the amount to scale
  36515. */
  36516. scaleInPlace(scale: number): void;
  36517. /**
  36518. * Gets the spherical polynomial from harmonics
  36519. * @param harmonics the spherical harmonics
  36520. * @returns the spherical polynomial
  36521. */
  36522. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36523. /**
  36524. * Constructs a spherical polynomial from an array.
  36525. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36526. * @returns the spherical polynomial
  36527. */
  36528. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36529. }
  36530. }
  36531. declare module BABYLON {
  36532. /**
  36533. * Defines the source of the internal texture
  36534. */
  36535. export enum InternalTextureSource {
  36536. /**
  36537. * The source of the texture data is unknown
  36538. */
  36539. Unknown = 0,
  36540. /**
  36541. * Texture data comes from an URL
  36542. */
  36543. Url = 1,
  36544. /**
  36545. * Texture data is only used for temporary storage
  36546. */
  36547. Temp = 2,
  36548. /**
  36549. * Texture data comes from raw data (ArrayBuffer)
  36550. */
  36551. Raw = 3,
  36552. /**
  36553. * Texture content is dynamic (video or dynamic texture)
  36554. */
  36555. Dynamic = 4,
  36556. /**
  36557. * Texture content is generated by rendering to it
  36558. */
  36559. RenderTarget = 5,
  36560. /**
  36561. * Texture content is part of a multi render target process
  36562. */
  36563. MultiRenderTarget = 6,
  36564. /**
  36565. * Texture data comes from a cube data file
  36566. */
  36567. Cube = 7,
  36568. /**
  36569. * Texture data comes from a raw cube data
  36570. */
  36571. CubeRaw = 8,
  36572. /**
  36573. * Texture data come from a prefiltered cube data file
  36574. */
  36575. CubePrefiltered = 9,
  36576. /**
  36577. * Texture content is raw 3D data
  36578. */
  36579. Raw3D = 10,
  36580. /**
  36581. * Texture content is raw 2D array data
  36582. */
  36583. Raw2DArray = 11,
  36584. /**
  36585. * Texture content is a depth texture
  36586. */
  36587. Depth = 12,
  36588. /**
  36589. * Texture data comes from a raw cube data encoded with RGBD
  36590. */
  36591. CubeRawRGBD = 13
  36592. }
  36593. /**
  36594. * Class used to store data associated with WebGL texture data for the engine
  36595. * This class should not be used directly
  36596. */
  36597. export class InternalTexture {
  36598. /** @hidden */
  36599. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36600. /**
  36601. * Defines if the texture is ready
  36602. */
  36603. isReady: boolean;
  36604. /**
  36605. * Defines if the texture is a cube texture
  36606. */
  36607. isCube: boolean;
  36608. /**
  36609. * Defines if the texture contains 3D data
  36610. */
  36611. is3D: boolean;
  36612. /**
  36613. * Defines if the texture contains 2D array data
  36614. */
  36615. is2DArray: boolean;
  36616. /**
  36617. * Defines if the texture contains multiview data
  36618. */
  36619. isMultiview: boolean;
  36620. /**
  36621. * Gets the URL used to load this texture
  36622. */
  36623. url: string;
  36624. /**
  36625. * Gets the sampling mode of the texture
  36626. */
  36627. samplingMode: number;
  36628. /**
  36629. * Gets a boolean indicating if the texture needs mipmaps generation
  36630. */
  36631. generateMipMaps: boolean;
  36632. /**
  36633. * Gets the number of samples used by the texture (WebGL2+ only)
  36634. */
  36635. samples: number;
  36636. /**
  36637. * Gets the type of the texture (int, float...)
  36638. */
  36639. type: number;
  36640. /**
  36641. * Gets the format of the texture (RGB, RGBA...)
  36642. */
  36643. format: number;
  36644. /**
  36645. * Observable called when the texture is loaded
  36646. */
  36647. onLoadedObservable: Observable<InternalTexture>;
  36648. /**
  36649. * Gets the width of the texture
  36650. */
  36651. width: number;
  36652. /**
  36653. * Gets the height of the texture
  36654. */
  36655. height: number;
  36656. /**
  36657. * Gets the depth of the texture
  36658. */
  36659. depth: number;
  36660. /**
  36661. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36662. */
  36663. baseWidth: number;
  36664. /**
  36665. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36666. */
  36667. baseHeight: number;
  36668. /**
  36669. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36670. */
  36671. baseDepth: number;
  36672. /**
  36673. * Gets a boolean indicating if the texture is inverted on Y axis
  36674. */
  36675. invertY: boolean;
  36676. /** @hidden */
  36677. _invertVScale: boolean;
  36678. /** @hidden */
  36679. _associatedChannel: number;
  36680. /** @hidden */
  36681. _source: InternalTextureSource;
  36682. /** @hidden */
  36683. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36684. /** @hidden */
  36685. _bufferView: Nullable<ArrayBufferView>;
  36686. /** @hidden */
  36687. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36688. /** @hidden */
  36689. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36690. /** @hidden */
  36691. _size: number;
  36692. /** @hidden */
  36693. _extension: string;
  36694. /** @hidden */
  36695. _files: Nullable<string[]>;
  36696. /** @hidden */
  36697. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36698. /** @hidden */
  36699. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36700. /** @hidden */
  36701. _framebuffer: Nullable<WebGLFramebuffer>;
  36702. /** @hidden */
  36703. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36704. /** @hidden */
  36705. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36706. /** @hidden */
  36707. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36708. /** @hidden */
  36709. _attachments: Nullable<number[]>;
  36710. /** @hidden */
  36711. _textureArray: Nullable<InternalTexture[]>;
  36712. /** @hidden */
  36713. _cachedCoordinatesMode: Nullable<number>;
  36714. /** @hidden */
  36715. _cachedWrapU: Nullable<number>;
  36716. /** @hidden */
  36717. _cachedWrapV: Nullable<number>;
  36718. /** @hidden */
  36719. _cachedWrapR: Nullable<number>;
  36720. /** @hidden */
  36721. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36722. /** @hidden */
  36723. _isDisabled: boolean;
  36724. /** @hidden */
  36725. _compression: Nullable<string>;
  36726. /** @hidden */
  36727. _generateStencilBuffer: boolean;
  36728. /** @hidden */
  36729. _generateDepthBuffer: boolean;
  36730. /** @hidden */
  36731. _comparisonFunction: number;
  36732. /** @hidden */
  36733. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36734. /** @hidden */
  36735. _lodGenerationScale: number;
  36736. /** @hidden */
  36737. _lodGenerationOffset: number;
  36738. /** @hidden */
  36739. _depthStencilTexture: Nullable<InternalTexture>;
  36740. /** @hidden */
  36741. _colorTextureArray: Nullable<WebGLTexture>;
  36742. /** @hidden */
  36743. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36744. /** @hidden */
  36745. _lodTextureHigh: Nullable<BaseTexture>;
  36746. /** @hidden */
  36747. _lodTextureMid: Nullable<BaseTexture>;
  36748. /** @hidden */
  36749. _lodTextureLow: Nullable<BaseTexture>;
  36750. /** @hidden */
  36751. _isRGBD: boolean;
  36752. /** @hidden */
  36753. _linearSpecularLOD: boolean;
  36754. /** @hidden */
  36755. _irradianceTexture: Nullable<BaseTexture>;
  36756. /** @hidden */
  36757. _webGLTexture: Nullable<WebGLTexture>;
  36758. /** @hidden */
  36759. _references: number;
  36760. /** @hidden */
  36761. _gammaSpace: Nullable<boolean>;
  36762. private _engine;
  36763. /**
  36764. * Gets the Engine the texture belongs to.
  36765. * @returns The babylon engine
  36766. */
  36767. getEngine(): ThinEngine;
  36768. /**
  36769. * Gets the data source type of the texture
  36770. */
  36771. get source(): InternalTextureSource;
  36772. /**
  36773. * Creates a new InternalTexture
  36774. * @param engine defines the engine to use
  36775. * @param source defines the type of data that will be used
  36776. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36777. */
  36778. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36779. /**
  36780. * Increments the number of references (ie. the number of Texture that point to it)
  36781. */
  36782. incrementReferences(): void;
  36783. /**
  36784. * Change the size of the texture (not the size of the content)
  36785. * @param width defines the new width
  36786. * @param height defines the new height
  36787. * @param depth defines the new depth (1 by default)
  36788. */
  36789. updateSize(width: int, height: int, depth?: int): void;
  36790. /** @hidden */
  36791. _rebuild(): void;
  36792. /** @hidden */
  36793. _swapAndDie(target: InternalTexture): void;
  36794. /**
  36795. * Dispose the current allocated resources
  36796. */
  36797. dispose(): void;
  36798. }
  36799. }
  36800. declare module BABYLON {
  36801. /**
  36802. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36803. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36804. */
  36805. export class Analyser {
  36806. /**
  36807. * Gets or sets the smoothing
  36808. * @ignorenaming
  36809. */
  36810. SMOOTHING: number;
  36811. /**
  36812. * Gets or sets the FFT table size
  36813. * @ignorenaming
  36814. */
  36815. FFT_SIZE: number;
  36816. /**
  36817. * Gets or sets the bar graph amplitude
  36818. * @ignorenaming
  36819. */
  36820. BARGRAPHAMPLITUDE: number;
  36821. /**
  36822. * Gets or sets the position of the debug canvas
  36823. * @ignorenaming
  36824. */
  36825. DEBUGCANVASPOS: {
  36826. x: number;
  36827. y: number;
  36828. };
  36829. /**
  36830. * Gets or sets the debug canvas size
  36831. * @ignorenaming
  36832. */
  36833. DEBUGCANVASSIZE: {
  36834. width: number;
  36835. height: number;
  36836. };
  36837. private _byteFreqs;
  36838. private _byteTime;
  36839. private _floatFreqs;
  36840. private _webAudioAnalyser;
  36841. private _debugCanvas;
  36842. private _debugCanvasContext;
  36843. private _scene;
  36844. private _registerFunc;
  36845. private _audioEngine;
  36846. /**
  36847. * Creates a new analyser
  36848. * @param scene defines hosting scene
  36849. */
  36850. constructor(scene: Scene);
  36851. /**
  36852. * Get the number of data values you will have to play with for the visualization
  36853. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36854. * @returns a number
  36855. */
  36856. getFrequencyBinCount(): number;
  36857. /**
  36858. * Gets the current frequency data as a byte array
  36859. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36860. * @returns a Uint8Array
  36861. */
  36862. getByteFrequencyData(): Uint8Array;
  36863. /**
  36864. * Gets the current waveform as a byte array
  36865. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36866. * @returns a Uint8Array
  36867. */
  36868. getByteTimeDomainData(): Uint8Array;
  36869. /**
  36870. * Gets the current frequency data as a float array
  36871. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36872. * @returns a Float32Array
  36873. */
  36874. getFloatFrequencyData(): Float32Array;
  36875. /**
  36876. * Renders the debug canvas
  36877. */
  36878. drawDebugCanvas(): void;
  36879. /**
  36880. * Stops rendering the debug canvas and removes it
  36881. */
  36882. stopDebugCanvas(): void;
  36883. /**
  36884. * Connects two audio nodes
  36885. * @param inputAudioNode defines first node to connect
  36886. * @param outputAudioNode defines second node to connect
  36887. */
  36888. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36889. /**
  36890. * Releases all associated resources
  36891. */
  36892. dispose(): void;
  36893. }
  36894. }
  36895. declare module BABYLON {
  36896. /**
  36897. * This represents an audio engine and it is responsible
  36898. * to play, synchronize and analyse sounds throughout the application.
  36899. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36900. */
  36901. export interface IAudioEngine extends IDisposable {
  36902. /**
  36903. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36904. */
  36905. readonly canUseWebAudio: boolean;
  36906. /**
  36907. * Gets the current AudioContext if available.
  36908. */
  36909. readonly audioContext: Nullable<AudioContext>;
  36910. /**
  36911. * The master gain node defines the global audio volume of your audio engine.
  36912. */
  36913. readonly masterGain: GainNode;
  36914. /**
  36915. * Gets whether or not mp3 are supported by your browser.
  36916. */
  36917. readonly isMP3supported: boolean;
  36918. /**
  36919. * Gets whether or not ogg are supported by your browser.
  36920. */
  36921. readonly isOGGsupported: boolean;
  36922. /**
  36923. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36924. * @ignoreNaming
  36925. */
  36926. WarnedWebAudioUnsupported: boolean;
  36927. /**
  36928. * Defines if the audio engine relies on a custom unlocked button.
  36929. * In this case, the embedded button will not be displayed.
  36930. */
  36931. useCustomUnlockedButton: boolean;
  36932. /**
  36933. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36934. */
  36935. readonly unlocked: boolean;
  36936. /**
  36937. * Event raised when audio has been unlocked on the browser.
  36938. */
  36939. onAudioUnlockedObservable: Observable<AudioEngine>;
  36940. /**
  36941. * Event raised when audio has been locked on the browser.
  36942. */
  36943. onAudioLockedObservable: Observable<AudioEngine>;
  36944. /**
  36945. * Flags the audio engine in Locked state.
  36946. * This happens due to new browser policies preventing audio to autoplay.
  36947. */
  36948. lock(): void;
  36949. /**
  36950. * Unlocks the audio engine once a user action has been done on the dom.
  36951. * This is helpful to resume play once browser policies have been satisfied.
  36952. */
  36953. unlock(): void;
  36954. /**
  36955. * Gets the global volume sets on the master gain.
  36956. * @returns the global volume if set or -1 otherwise
  36957. */
  36958. getGlobalVolume(): number;
  36959. /**
  36960. * Sets the global volume of your experience (sets on the master gain).
  36961. * @param newVolume Defines the new global volume of the application
  36962. */
  36963. setGlobalVolume(newVolume: number): void;
  36964. /**
  36965. * Connect the audio engine to an audio analyser allowing some amazing
  36966. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36967. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36968. * @param analyser The analyser to connect to the engine
  36969. */
  36970. connectToAnalyser(analyser: Analyser): void;
  36971. }
  36972. /**
  36973. * This represents the default audio engine used in babylon.
  36974. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36975. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36976. */
  36977. export class AudioEngine implements IAudioEngine {
  36978. private _audioContext;
  36979. private _audioContextInitialized;
  36980. private _muteButton;
  36981. private _hostElement;
  36982. /**
  36983. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36984. */
  36985. canUseWebAudio: boolean;
  36986. /**
  36987. * The master gain node defines the global audio volume of your audio engine.
  36988. */
  36989. masterGain: GainNode;
  36990. /**
  36991. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36992. * @ignoreNaming
  36993. */
  36994. WarnedWebAudioUnsupported: boolean;
  36995. /**
  36996. * Gets whether or not mp3 are supported by your browser.
  36997. */
  36998. isMP3supported: boolean;
  36999. /**
  37000. * Gets whether or not ogg are supported by your browser.
  37001. */
  37002. isOGGsupported: boolean;
  37003. /**
  37004. * Gets whether audio has been unlocked on the device.
  37005. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37006. * a user interaction has happened.
  37007. */
  37008. unlocked: boolean;
  37009. /**
  37010. * Defines if the audio engine relies on a custom unlocked button.
  37011. * In this case, the embedded button will not be displayed.
  37012. */
  37013. useCustomUnlockedButton: boolean;
  37014. /**
  37015. * Event raised when audio has been unlocked on the browser.
  37016. */
  37017. onAudioUnlockedObservable: Observable<AudioEngine>;
  37018. /**
  37019. * Event raised when audio has been locked on the browser.
  37020. */
  37021. onAudioLockedObservable: Observable<AudioEngine>;
  37022. /**
  37023. * Gets the current AudioContext if available.
  37024. */
  37025. get audioContext(): Nullable<AudioContext>;
  37026. private _connectedAnalyser;
  37027. /**
  37028. * Instantiates a new audio engine.
  37029. *
  37030. * There should be only one per page as some browsers restrict the number
  37031. * of audio contexts you can create.
  37032. * @param hostElement defines the host element where to display the mute icon if necessary
  37033. */
  37034. constructor(hostElement?: Nullable<HTMLElement>);
  37035. /**
  37036. * Flags the audio engine in Locked state.
  37037. * This happens due to new browser policies preventing audio to autoplay.
  37038. */
  37039. lock(): void;
  37040. /**
  37041. * Unlocks the audio engine once a user action has been done on the dom.
  37042. * This is helpful to resume play once browser policies have been satisfied.
  37043. */
  37044. unlock(): void;
  37045. private _resumeAudioContext;
  37046. private _initializeAudioContext;
  37047. private _tryToRun;
  37048. private _triggerRunningState;
  37049. private _triggerSuspendedState;
  37050. private _displayMuteButton;
  37051. private _moveButtonToTopLeft;
  37052. private _onResize;
  37053. private _hideMuteButton;
  37054. /**
  37055. * Destroy and release the resources associated with the audio ccontext.
  37056. */
  37057. dispose(): void;
  37058. /**
  37059. * Gets the global volume sets on the master gain.
  37060. * @returns the global volume if set or -1 otherwise
  37061. */
  37062. getGlobalVolume(): number;
  37063. /**
  37064. * Sets the global volume of your experience (sets on the master gain).
  37065. * @param newVolume Defines the new global volume of the application
  37066. */
  37067. setGlobalVolume(newVolume: number): void;
  37068. /**
  37069. * Connect the audio engine to an audio analyser allowing some amazing
  37070. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37071. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37072. * @param analyser The analyser to connect to the engine
  37073. */
  37074. connectToAnalyser(analyser: Analyser): void;
  37075. }
  37076. }
  37077. declare module BABYLON {
  37078. /**
  37079. * Interface used to present a loading screen while loading a scene
  37080. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37081. */
  37082. export interface ILoadingScreen {
  37083. /**
  37084. * Function called to display the loading screen
  37085. */
  37086. displayLoadingUI: () => void;
  37087. /**
  37088. * Function called to hide the loading screen
  37089. */
  37090. hideLoadingUI: () => void;
  37091. /**
  37092. * Gets or sets the color to use for the background
  37093. */
  37094. loadingUIBackgroundColor: string;
  37095. /**
  37096. * Gets or sets the text to display while loading
  37097. */
  37098. loadingUIText: string;
  37099. }
  37100. /**
  37101. * Class used for the default loading screen
  37102. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37103. */
  37104. export class DefaultLoadingScreen implements ILoadingScreen {
  37105. private _renderingCanvas;
  37106. private _loadingText;
  37107. private _loadingDivBackgroundColor;
  37108. private _loadingDiv;
  37109. private _loadingTextDiv;
  37110. /** Gets or sets the logo url to use for the default loading screen */
  37111. static DefaultLogoUrl: string;
  37112. /** Gets or sets the spinner url to use for the default loading screen */
  37113. static DefaultSpinnerUrl: string;
  37114. /**
  37115. * Creates a new default loading screen
  37116. * @param _renderingCanvas defines the canvas used to render the scene
  37117. * @param _loadingText defines the default text to display
  37118. * @param _loadingDivBackgroundColor defines the default background color
  37119. */
  37120. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37121. /**
  37122. * Function called to display the loading screen
  37123. */
  37124. displayLoadingUI(): void;
  37125. /**
  37126. * Function called to hide the loading screen
  37127. */
  37128. hideLoadingUI(): void;
  37129. /**
  37130. * Gets or sets the text to display while loading
  37131. */
  37132. set loadingUIText(text: string);
  37133. get loadingUIText(): string;
  37134. /**
  37135. * Gets or sets the color to use for the background
  37136. */
  37137. get loadingUIBackgroundColor(): string;
  37138. set loadingUIBackgroundColor(color: string);
  37139. private _resizeLoadingUI;
  37140. }
  37141. }
  37142. declare module BABYLON {
  37143. /**
  37144. * Interface for any object that can request an animation frame
  37145. */
  37146. export interface ICustomAnimationFrameRequester {
  37147. /**
  37148. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37149. */
  37150. renderFunction?: Function;
  37151. /**
  37152. * Called to request the next frame to render to
  37153. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37154. */
  37155. requestAnimationFrame: Function;
  37156. /**
  37157. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37158. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37159. */
  37160. requestID?: number;
  37161. }
  37162. }
  37163. declare module BABYLON {
  37164. /**
  37165. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37166. */
  37167. export class PerformanceMonitor {
  37168. private _enabled;
  37169. private _rollingFrameTime;
  37170. private _lastFrameTimeMs;
  37171. /**
  37172. * constructor
  37173. * @param frameSampleSize The number of samples required to saturate the sliding window
  37174. */
  37175. constructor(frameSampleSize?: number);
  37176. /**
  37177. * Samples current frame
  37178. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37179. */
  37180. sampleFrame(timeMs?: number): void;
  37181. /**
  37182. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37183. */
  37184. get averageFrameTime(): number;
  37185. /**
  37186. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37187. */
  37188. get averageFrameTimeVariance(): number;
  37189. /**
  37190. * Returns the frame time of the most recent frame
  37191. */
  37192. get instantaneousFrameTime(): number;
  37193. /**
  37194. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37195. */
  37196. get averageFPS(): number;
  37197. /**
  37198. * Returns the average framerate in frames per second using the most recent frame time
  37199. */
  37200. get instantaneousFPS(): number;
  37201. /**
  37202. * Returns true if enough samples have been taken to completely fill the sliding window
  37203. */
  37204. get isSaturated(): boolean;
  37205. /**
  37206. * Enables contributions to the sliding window sample set
  37207. */
  37208. enable(): void;
  37209. /**
  37210. * Disables contributions to the sliding window sample set
  37211. * Samples will not be interpolated over the disabled period
  37212. */
  37213. disable(): void;
  37214. /**
  37215. * Returns true if sampling is enabled
  37216. */
  37217. get isEnabled(): boolean;
  37218. /**
  37219. * Resets performance monitor
  37220. */
  37221. reset(): void;
  37222. }
  37223. /**
  37224. * RollingAverage
  37225. *
  37226. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37227. */
  37228. export class RollingAverage {
  37229. /**
  37230. * Current average
  37231. */
  37232. average: number;
  37233. /**
  37234. * Current variance
  37235. */
  37236. variance: number;
  37237. protected _samples: Array<number>;
  37238. protected _sampleCount: number;
  37239. protected _pos: number;
  37240. protected _m2: number;
  37241. /**
  37242. * constructor
  37243. * @param length The number of samples required to saturate the sliding window
  37244. */
  37245. constructor(length: number);
  37246. /**
  37247. * Adds a sample to the sample set
  37248. * @param v The sample value
  37249. */
  37250. add(v: number): void;
  37251. /**
  37252. * Returns previously added values or null if outside of history or outside the sliding window domain
  37253. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37254. * @return Value previously recorded with add() or null if outside of range
  37255. */
  37256. history(i: number): number;
  37257. /**
  37258. * Returns true if enough samples have been taken to completely fill the sliding window
  37259. * @return true if sample-set saturated
  37260. */
  37261. isSaturated(): boolean;
  37262. /**
  37263. * Resets the rolling average (equivalent to 0 samples taken so far)
  37264. */
  37265. reset(): void;
  37266. /**
  37267. * Wraps a value around the sample range boundaries
  37268. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37269. * @return Wrapped position in sample range
  37270. */
  37271. protected _wrapPosition(i: number): number;
  37272. }
  37273. }
  37274. declare module BABYLON {
  37275. /**
  37276. * This class is used to track a performance counter which is number based.
  37277. * The user has access to many properties which give statistics of different nature.
  37278. *
  37279. * The implementer can track two kinds of Performance Counter: time and count.
  37280. * 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.
  37281. * 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.
  37282. */
  37283. export class PerfCounter {
  37284. /**
  37285. * Gets or sets a global boolean to turn on and off all the counters
  37286. */
  37287. static Enabled: boolean;
  37288. /**
  37289. * Returns the smallest value ever
  37290. */
  37291. get min(): number;
  37292. /**
  37293. * Returns the biggest value ever
  37294. */
  37295. get max(): number;
  37296. /**
  37297. * Returns the average value since the performance counter is running
  37298. */
  37299. get average(): number;
  37300. /**
  37301. * Returns the average value of the last second the counter was monitored
  37302. */
  37303. get lastSecAverage(): number;
  37304. /**
  37305. * Returns the current value
  37306. */
  37307. get current(): number;
  37308. /**
  37309. * Gets the accumulated total
  37310. */
  37311. get total(): number;
  37312. /**
  37313. * Gets the total value count
  37314. */
  37315. get count(): number;
  37316. /**
  37317. * Creates a new counter
  37318. */
  37319. constructor();
  37320. /**
  37321. * Call this method to start monitoring a new frame.
  37322. * 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.
  37323. */
  37324. fetchNewFrame(): void;
  37325. /**
  37326. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37327. * @param newCount the count value to add to the monitored count
  37328. * @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.
  37329. */
  37330. addCount(newCount: number, fetchResult: boolean): void;
  37331. /**
  37332. * Start monitoring this performance counter
  37333. */
  37334. beginMonitoring(): void;
  37335. /**
  37336. * Compute the time lapsed since the previous beginMonitoring() call.
  37337. * @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
  37338. */
  37339. endMonitoring(newFrame?: boolean): void;
  37340. private _fetchResult;
  37341. private _startMonitoringTime;
  37342. private _min;
  37343. private _max;
  37344. private _average;
  37345. private _current;
  37346. private _totalValueCount;
  37347. private _totalAccumulated;
  37348. private _lastSecAverage;
  37349. private _lastSecAccumulated;
  37350. private _lastSecTime;
  37351. private _lastSecValueCount;
  37352. }
  37353. }
  37354. declare module BABYLON {
  37355. interface ThinEngine {
  37356. /** @hidden */
  37357. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37358. }
  37359. }
  37360. declare module BABYLON {
  37361. /**
  37362. * Defines the interface used by display changed events
  37363. */
  37364. export interface IDisplayChangedEventArgs {
  37365. /** Gets the vrDisplay object (if any) */
  37366. vrDisplay: Nullable<any>;
  37367. /** Gets a boolean indicating if webVR is supported */
  37368. vrSupported: boolean;
  37369. }
  37370. /**
  37371. * Defines the interface used by objects containing a viewport (like a camera)
  37372. */
  37373. interface IViewportOwnerLike {
  37374. /**
  37375. * Gets or sets the viewport
  37376. */
  37377. viewport: IViewportLike;
  37378. }
  37379. /**
  37380. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37381. */
  37382. export class Engine extends ThinEngine {
  37383. /** Defines that alpha blending is disabled */
  37384. static readonly ALPHA_DISABLE: number;
  37385. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37386. static readonly ALPHA_ADD: number;
  37387. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37388. static readonly ALPHA_COMBINE: number;
  37389. /** Defines that alpha blending to DEST - SRC * DEST */
  37390. static readonly ALPHA_SUBTRACT: number;
  37391. /** Defines that alpha blending to SRC * DEST */
  37392. static readonly ALPHA_MULTIPLY: number;
  37393. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37394. static readonly ALPHA_MAXIMIZED: number;
  37395. /** Defines that alpha blending to SRC + DEST */
  37396. static readonly ALPHA_ONEONE: number;
  37397. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37398. static readonly ALPHA_PREMULTIPLIED: number;
  37399. /**
  37400. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37401. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37402. */
  37403. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37404. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37405. static readonly ALPHA_INTERPOLATE: number;
  37406. /**
  37407. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37408. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37409. */
  37410. static readonly ALPHA_SCREENMODE: number;
  37411. /** Defines that the ressource is not delayed*/
  37412. static readonly DELAYLOADSTATE_NONE: number;
  37413. /** Defines that the ressource was successfully delay loaded */
  37414. static readonly DELAYLOADSTATE_LOADED: number;
  37415. /** Defines that the ressource is currently delay loading */
  37416. static readonly DELAYLOADSTATE_LOADING: number;
  37417. /** Defines that the ressource is delayed and has not started loading */
  37418. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37419. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37420. static readonly NEVER: number;
  37421. /** 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 */
  37422. static readonly ALWAYS: number;
  37423. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37424. static readonly LESS: number;
  37425. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37426. static readonly EQUAL: number;
  37427. /** 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 */
  37428. static readonly LEQUAL: number;
  37429. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37430. static readonly GREATER: number;
  37431. /** 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 */
  37432. static readonly GEQUAL: number;
  37433. /** 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 */
  37434. static readonly NOTEQUAL: number;
  37435. /** Passed to stencilOperation to specify that stencil value must be kept */
  37436. static readonly KEEP: number;
  37437. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37438. static readonly REPLACE: number;
  37439. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37440. static readonly INCR: number;
  37441. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37442. static readonly DECR: number;
  37443. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37444. static readonly INVERT: number;
  37445. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37446. static readonly INCR_WRAP: number;
  37447. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37448. static readonly DECR_WRAP: number;
  37449. /** Texture is not repeating outside of 0..1 UVs */
  37450. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37451. /** Texture is repeating outside of 0..1 UVs */
  37452. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37453. /** Texture is repeating and mirrored */
  37454. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37455. /** ALPHA */
  37456. static readonly TEXTUREFORMAT_ALPHA: number;
  37457. /** LUMINANCE */
  37458. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37459. /** LUMINANCE_ALPHA */
  37460. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37461. /** RGB */
  37462. static readonly TEXTUREFORMAT_RGB: number;
  37463. /** RGBA */
  37464. static readonly TEXTUREFORMAT_RGBA: number;
  37465. /** RED */
  37466. static readonly TEXTUREFORMAT_RED: number;
  37467. /** RED (2nd reference) */
  37468. static readonly TEXTUREFORMAT_R: number;
  37469. /** RG */
  37470. static readonly TEXTUREFORMAT_RG: number;
  37471. /** RED_INTEGER */
  37472. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37473. /** RED_INTEGER (2nd reference) */
  37474. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37475. /** RG_INTEGER */
  37476. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37477. /** RGB_INTEGER */
  37478. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37479. /** RGBA_INTEGER */
  37480. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37481. /** UNSIGNED_BYTE */
  37482. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37483. /** UNSIGNED_BYTE (2nd reference) */
  37484. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37485. /** FLOAT */
  37486. static readonly TEXTURETYPE_FLOAT: number;
  37487. /** HALF_FLOAT */
  37488. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37489. /** BYTE */
  37490. static readonly TEXTURETYPE_BYTE: number;
  37491. /** SHORT */
  37492. static readonly TEXTURETYPE_SHORT: number;
  37493. /** UNSIGNED_SHORT */
  37494. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37495. /** INT */
  37496. static readonly TEXTURETYPE_INT: number;
  37497. /** UNSIGNED_INT */
  37498. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37499. /** UNSIGNED_SHORT_4_4_4_4 */
  37500. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37501. /** UNSIGNED_SHORT_5_5_5_1 */
  37502. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37503. /** UNSIGNED_SHORT_5_6_5 */
  37504. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37505. /** UNSIGNED_INT_2_10_10_10_REV */
  37506. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37507. /** UNSIGNED_INT_24_8 */
  37508. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37509. /** UNSIGNED_INT_10F_11F_11F_REV */
  37510. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37511. /** UNSIGNED_INT_5_9_9_9_REV */
  37512. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37513. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37514. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37515. /** nearest is mag = nearest and min = nearest and mip = linear */
  37516. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37517. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37518. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37519. /** Trilinear is mag = linear and min = linear and mip = linear */
  37520. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37521. /** nearest is mag = nearest and min = nearest and mip = linear */
  37522. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37524. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37525. /** Trilinear is mag = linear and min = linear and mip = linear */
  37526. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37527. /** mag = nearest and min = nearest and mip = nearest */
  37528. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37529. /** mag = nearest and min = linear and mip = nearest */
  37530. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37531. /** mag = nearest and min = linear and mip = linear */
  37532. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37533. /** mag = nearest and min = linear and mip = none */
  37534. static readonly TEXTURE_NEAREST_LINEAR: number;
  37535. /** mag = nearest and min = nearest and mip = none */
  37536. static readonly TEXTURE_NEAREST_NEAREST: number;
  37537. /** mag = linear and min = nearest and mip = nearest */
  37538. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37539. /** mag = linear and min = nearest and mip = linear */
  37540. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37541. /** mag = linear and min = linear and mip = none */
  37542. static readonly TEXTURE_LINEAR_LINEAR: number;
  37543. /** mag = linear and min = nearest and mip = none */
  37544. static readonly TEXTURE_LINEAR_NEAREST: number;
  37545. /** Explicit coordinates mode */
  37546. static readonly TEXTURE_EXPLICIT_MODE: number;
  37547. /** Spherical coordinates mode */
  37548. static readonly TEXTURE_SPHERICAL_MODE: number;
  37549. /** Planar coordinates mode */
  37550. static readonly TEXTURE_PLANAR_MODE: number;
  37551. /** Cubic coordinates mode */
  37552. static readonly TEXTURE_CUBIC_MODE: number;
  37553. /** Projection coordinates mode */
  37554. static readonly TEXTURE_PROJECTION_MODE: number;
  37555. /** Skybox coordinates mode */
  37556. static readonly TEXTURE_SKYBOX_MODE: number;
  37557. /** Inverse Cubic coordinates mode */
  37558. static readonly TEXTURE_INVCUBIC_MODE: number;
  37559. /** Equirectangular coordinates mode */
  37560. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37561. /** Equirectangular Fixed coordinates mode */
  37562. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37563. /** Equirectangular Fixed Mirrored coordinates mode */
  37564. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37565. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37566. static readonly SCALEMODE_FLOOR: number;
  37567. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37568. static readonly SCALEMODE_NEAREST: number;
  37569. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37570. static readonly SCALEMODE_CEILING: number;
  37571. /**
  37572. * Returns the current npm package of the sdk
  37573. */
  37574. static get NpmPackage(): string;
  37575. /**
  37576. * Returns the current version of the framework
  37577. */
  37578. static get Version(): string;
  37579. /** Gets the list of created engines */
  37580. static get Instances(): Engine[];
  37581. /**
  37582. * Gets the latest created engine
  37583. */
  37584. static get LastCreatedEngine(): Nullable<Engine>;
  37585. /**
  37586. * Gets the latest created scene
  37587. */
  37588. static get LastCreatedScene(): Nullable<Scene>;
  37589. /**
  37590. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37591. * @param flag defines which part of the materials must be marked as dirty
  37592. * @param predicate defines a predicate used to filter which materials should be affected
  37593. */
  37594. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37595. /**
  37596. * Method called to create the default loading screen.
  37597. * This can be overriden in your own app.
  37598. * @param canvas The rendering canvas element
  37599. * @returns The loading screen
  37600. */
  37601. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37602. /**
  37603. * Method called to create the default rescale post process on each engine.
  37604. */
  37605. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37606. /**
  37607. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37608. **/
  37609. enableOfflineSupport: boolean;
  37610. /**
  37611. * 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)
  37612. **/
  37613. disableManifestCheck: boolean;
  37614. /**
  37615. * Gets the list of created scenes
  37616. */
  37617. scenes: Scene[];
  37618. /**
  37619. * Event raised when a new scene is created
  37620. */
  37621. onNewSceneAddedObservable: Observable<Scene>;
  37622. /**
  37623. * Gets the list of created postprocesses
  37624. */
  37625. postProcesses: PostProcess[];
  37626. /**
  37627. * Gets a boolean indicating if the pointer is currently locked
  37628. */
  37629. isPointerLock: boolean;
  37630. /**
  37631. * Observable event triggered each time the rendering canvas is resized
  37632. */
  37633. onResizeObservable: Observable<Engine>;
  37634. /**
  37635. * Observable event triggered each time the canvas loses focus
  37636. */
  37637. onCanvasBlurObservable: Observable<Engine>;
  37638. /**
  37639. * Observable event triggered each time the canvas gains focus
  37640. */
  37641. onCanvasFocusObservable: Observable<Engine>;
  37642. /**
  37643. * Observable event triggered each time the canvas receives pointerout event
  37644. */
  37645. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37646. /**
  37647. * Observable raised when the engine begins a new frame
  37648. */
  37649. onBeginFrameObservable: Observable<Engine>;
  37650. /**
  37651. * If set, will be used to request the next animation frame for the render loop
  37652. */
  37653. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37654. /**
  37655. * Observable raised when the engine ends the current frame
  37656. */
  37657. onEndFrameObservable: Observable<Engine>;
  37658. /**
  37659. * Observable raised when the engine is about to compile a shader
  37660. */
  37661. onBeforeShaderCompilationObservable: Observable<Engine>;
  37662. /**
  37663. * Observable raised when the engine has jsut compiled a shader
  37664. */
  37665. onAfterShaderCompilationObservable: Observable<Engine>;
  37666. /**
  37667. * Gets the audio engine
  37668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37669. * @ignorenaming
  37670. */
  37671. static audioEngine: IAudioEngine;
  37672. /**
  37673. * Default AudioEngine factory responsible of creating the Audio Engine.
  37674. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37675. */
  37676. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37677. /**
  37678. * Default offline support factory responsible of creating a tool used to store data locally.
  37679. * By default, this will create a Database object if the workload has been embedded.
  37680. */
  37681. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37682. private _loadingScreen;
  37683. private _pointerLockRequested;
  37684. private _rescalePostProcess;
  37685. private _deterministicLockstep;
  37686. private _lockstepMaxSteps;
  37687. private _timeStep;
  37688. protected get _supportsHardwareTextureRescaling(): boolean;
  37689. private _fps;
  37690. private _deltaTime;
  37691. /** @hidden */
  37692. _drawCalls: PerfCounter;
  37693. /** 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 */
  37694. canvasTabIndex: number;
  37695. /**
  37696. * Turn this value on if you want to pause FPS computation when in background
  37697. */
  37698. disablePerformanceMonitorInBackground: boolean;
  37699. private _performanceMonitor;
  37700. /**
  37701. * Gets the performance monitor attached to this engine
  37702. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37703. */
  37704. get performanceMonitor(): PerformanceMonitor;
  37705. private _onFocus;
  37706. private _onBlur;
  37707. private _onCanvasPointerOut;
  37708. private _onCanvasBlur;
  37709. private _onCanvasFocus;
  37710. private _onFullscreenChange;
  37711. private _onPointerLockChange;
  37712. /**
  37713. * Gets the HTML element used to attach event listeners
  37714. * @returns a HTML element
  37715. */
  37716. getInputElement(): Nullable<HTMLElement>;
  37717. /**
  37718. * Creates a new engine
  37719. * @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
  37720. * @param antialias defines enable antialiasing (default: false)
  37721. * @param options defines further options to be sent to the getContext() function
  37722. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37723. */
  37724. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37725. /**
  37726. * Gets current aspect ratio
  37727. * @param viewportOwner defines the camera to use to get the aspect ratio
  37728. * @param useScreen defines if screen size must be used (or the current render target if any)
  37729. * @returns a number defining the aspect ratio
  37730. */
  37731. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37732. /**
  37733. * Gets current screen aspect ratio
  37734. * @returns a number defining the aspect ratio
  37735. */
  37736. getScreenAspectRatio(): number;
  37737. /**
  37738. * Gets the client rect of the HTML canvas attached with the current webGL context
  37739. * @returns a client rectanglee
  37740. */
  37741. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37742. /**
  37743. * Gets the client rect of the HTML element used for events
  37744. * @returns a client rectanglee
  37745. */
  37746. getInputElementClientRect(): Nullable<ClientRect>;
  37747. /**
  37748. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37749. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37750. * @returns true if engine is in deterministic lock step mode
  37751. */
  37752. isDeterministicLockStep(): boolean;
  37753. /**
  37754. * Gets the max steps when engine is running in deterministic lock step
  37755. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37756. * @returns the max steps
  37757. */
  37758. getLockstepMaxSteps(): number;
  37759. /**
  37760. * Returns the time in ms between steps when using deterministic lock step.
  37761. * @returns time step in (ms)
  37762. */
  37763. getTimeStep(): number;
  37764. /**
  37765. * Force the mipmap generation for the given render target texture
  37766. * @param texture defines the render target texture to use
  37767. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37768. */
  37769. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37770. /** States */
  37771. /**
  37772. * Set various states to the webGL context
  37773. * @param culling defines backface culling state
  37774. * @param zOffset defines the value to apply to zOffset (0 by default)
  37775. * @param force defines if states must be applied even if cache is up to date
  37776. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37777. */
  37778. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37779. /**
  37780. * Set the z offset to apply to current rendering
  37781. * @param value defines the offset to apply
  37782. */
  37783. setZOffset(value: number): void;
  37784. /**
  37785. * Gets the current value of the zOffset
  37786. * @returns the current zOffset state
  37787. */
  37788. getZOffset(): number;
  37789. /**
  37790. * Enable or disable depth buffering
  37791. * @param enable defines the state to set
  37792. */
  37793. setDepthBuffer(enable: boolean): void;
  37794. /**
  37795. * Gets a boolean indicating if depth writing is enabled
  37796. * @returns the current depth writing state
  37797. */
  37798. getDepthWrite(): boolean;
  37799. /**
  37800. * Enable or disable depth writing
  37801. * @param enable defines the state to set
  37802. */
  37803. setDepthWrite(enable: boolean): void;
  37804. /**
  37805. * Gets a boolean indicating if stencil buffer is enabled
  37806. * @returns the current stencil buffer state
  37807. */
  37808. getStencilBuffer(): boolean;
  37809. /**
  37810. * Enable or disable the stencil buffer
  37811. * @param enable defines if the stencil buffer must be enabled or disabled
  37812. */
  37813. setStencilBuffer(enable: boolean): void;
  37814. /**
  37815. * Gets the current stencil mask
  37816. * @returns a number defining the new stencil mask to use
  37817. */
  37818. getStencilMask(): number;
  37819. /**
  37820. * Sets the current stencil mask
  37821. * @param mask defines the new stencil mask to use
  37822. */
  37823. setStencilMask(mask: number): void;
  37824. /**
  37825. * Gets the current stencil function
  37826. * @returns a number defining the stencil function to use
  37827. */
  37828. getStencilFunction(): number;
  37829. /**
  37830. * Gets the current stencil reference value
  37831. * @returns a number defining the stencil reference value to use
  37832. */
  37833. getStencilFunctionReference(): number;
  37834. /**
  37835. * Gets the current stencil mask
  37836. * @returns a number defining the stencil mask to use
  37837. */
  37838. getStencilFunctionMask(): number;
  37839. /**
  37840. * Sets the current stencil function
  37841. * @param stencilFunc defines the new stencil function to use
  37842. */
  37843. setStencilFunction(stencilFunc: number): void;
  37844. /**
  37845. * Sets the current stencil reference
  37846. * @param reference defines the new stencil reference to use
  37847. */
  37848. setStencilFunctionReference(reference: number): void;
  37849. /**
  37850. * Sets the current stencil mask
  37851. * @param mask defines the new stencil mask to use
  37852. */
  37853. setStencilFunctionMask(mask: number): void;
  37854. /**
  37855. * Gets the current stencil operation when stencil fails
  37856. * @returns a number defining stencil operation to use when stencil fails
  37857. */
  37858. getStencilOperationFail(): number;
  37859. /**
  37860. * Gets the current stencil operation when depth fails
  37861. * @returns a number defining stencil operation to use when depth fails
  37862. */
  37863. getStencilOperationDepthFail(): number;
  37864. /**
  37865. * Gets the current stencil operation when stencil passes
  37866. * @returns a number defining stencil operation to use when stencil passes
  37867. */
  37868. getStencilOperationPass(): number;
  37869. /**
  37870. * Sets the stencil operation to use when stencil fails
  37871. * @param operation defines the stencil operation to use when stencil fails
  37872. */
  37873. setStencilOperationFail(operation: number): void;
  37874. /**
  37875. * Sets the stencil operation to use when depth fails
  37876. * @param operation defines the stencil operation to use when depth fails
  37877. */
  37878. setStencilOperationDepthFail(operation: number): void;
  37879. /**
  37880. * Sets the stencil operation to use when stencil passes
  37881. * @param operation defines the stencil operation to use when stencil passes
  37882. */
  37883. setStencilOperationPass(operation: number): void;
  37884. /**
  37885. * Sets a boolean indicating if the dithering state is enabled or disabled
  37886. * @param value defines the dithering state
  37887. */
  37888. setDitheringState(value: boolean): void;
  37889. /**
  37890. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37891. * @param value defines the rasterizer state
  37892. */
  37893. setRasterizerState(value: boolean): void;
  37894. /**
  37895. * Gets the current depth function
  37896. * @returns a number defining the depth function
  37897. */
  37898. getDepthFunction(): Nullable<number>;
  37899. /**
  37900. * Sets the current depth function
  37901. * @param depthFunc defines the function to use
  37902. */
  37903. setDepthFunction(depthFunc: number): void;
  37904. /**
  37905. * Sets the current depth function to GREATER
  37906. */
  37907. setDepthFunctionToGreater(): void;
  37908. /**
  37909. * Sets the current depth function to GEQUAL
  37910. */
  37911. setDepthFunctionToGreaterOrEqual(): void;
  37912. /**
  37913. * Sets the current depth function to LESS
  37914. */
  37915. setDepthFunctionToLess(): void;
  37916. /**
  37917. * Sets the current depth function to LEQUAL
  37918. */
  37919. setDepthFunctionToLessOrEqual(): void;
  37920. private _cachedStencilBuffer;
  37921. private _cachedStencilFunction;
  37922. private _cachedStencilMask;
  37923. private _cachedStencilOperationPass;
  37924. private _cachedStencilOperationFail;
  37925. private _cachedStencilOperationDepthFail;
  37926. private _cachedStencilReference;
  37927. /**
  37928. * Caches the the state of the stencil buffer
  37929. */
  37930. cacheStencilState(): void;
  37931. /**
  37932. * Restores the state of the stencil buffer
  37933. */
  37934. restoreStencilState(): void;
  37935. /**
  37936. * Directly set the WebGL Viewport
  37937. * @param x defines the x coordinate of the viewport (in screen space)
  37938. * @param y defines the y coordinate of the viewport (in screen space)
  37939. * @param width defines the width of the viewport (in screen space)
  37940. * @param height defines the height of the viewport (in screen space)
  37941. * @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
  37942. */
  37943. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37944. /**
  37945. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37946. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37947. * @param y defines the y-coordinate of the corner of the clear rectangle
  37948. * @param width defines the width of the clear rectangle
  37949. * @param height defines the height of the clear rectangle
  37950. * @param clearColor defines the clear color
  37951. */
  37952. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37953. /**
  37954. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37955. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37956. * @param y defines the y-coordinate of the corner of the clear rectangle
  37957. * @param width defines the width of the clear rectangle
  37958. * @param height defines the height of the clear rectangle
  37959. */
  37960. enableScissor(x: number, y: number, width: number, height: number): void;
  37961. /**
  37962. * Disable previously set scissor test rectangle
  37963. */
  37964. disableScissor(): void;
  37965. protected _reportDrawCall(): void;
  37966. /**
  37967. * Initializes a webVR display and starts listening to display change events
  37968. * The onVRDisplayChangedObservable will be notified upon these changes
  37969. * @returns The onVRDisplayChangedObservable
  37970. */
  37971. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37972. /** @hidden */
  37973. _prepareVRComponent(): void;
  37974. /** @hidden */
  37975. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37976. /** @hidden */
  37977. _submitVRFrame(): void;
  37978. /**
  37979. * Call this function to leave webVR mode
  37980. * Will do nothing if webVR is not supported or if there is no webVR device
  37981. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37982. */
  37983. disableVR(): void;
  37984. /**
  37985. * Gets a boolean indicating that the system is in VR mode and is presenting
  37986. * @returns true if VR mode is engaged
  37987. */
  37988. isVRPresenting(): boolean;
  37989. /** @hidden */
  37990. _requestVRFrame(): void;
  37991. /** @hidden */
  37992. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37993. /**
  37994. * Gets the source code of the vertex shader associated with a specific webGL program
  37995. * @param program defines the program to use
  37996. * @returns a string containing the source code of the vertex shader associated with the program
  37997. */
  37998. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37999. /**
  38000. * Gets the source code of the fragment shader associated with a specific webGL program
  38001. * @param program defines the program to use
  38002. * @returns a string containing the source code of the fragment shader associated with the program
  38003. */
  38004. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38005. /**
  38006. * Sets a depth stencil texture from a render target to the according uniform.
  38007. * @param channel The texture channel
  38008. * @param uniform The uniform to set
  38009. * @param texture The render target texture containing the depth stencil texture to apply
  38010. */
  38011. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38012. /**
  38013. * Sets a texture to the webGL context from a postprocess
  38014. * @param channel defines the channel to use
  38015. * @param postProcess defines the source postprocess
  38016. */
  38017. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38018. /**
  38019. * Binds the output of the passed in post process to the texture channel specified
  38020. * @param channel The channel the texture should be bound to
  38021. * @param postProcess The post process which's output should be bound
  38022. */
  38023. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38024. protected _rebuildBuffers(): void;
  38025. /** @hidden */
  38026. _renderFrame(): void;
  38027. _renderLoop(): void;
  38028. /** @hidden */
  38029. _renderViews(): boolean;
  38030. /**
  38031. * Toggle full screen mode
  38032. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38033. */
  38034. switchFullscreen(requestPointerLock: boolean): void;
  38035. /**
  38036. * Enters full screen mode
  38037. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38038. */
  38039. enterFullscreen(requestPointerLock: boolean): void;
  38040. /**
  38041. * Exits full screen mode
  38042. */
  38043. exitFullscreen(): void;
  38044. /**
  38045. * Enters Pointerlock mode
  38046. */
  38047. enterPointerlock(): void;
  38048. /**
  38049. * Exits Pointerlock mode
  38050. */
  38051. exitPointerlock(): void;
  38052. /**
  38053. * Begin a new frame
  38054. */
  38055. beginFrame(): void;
  38056. /**
  38057. * Enf the current frame
  38058. */
  38059. endFrame(): void;
  38060. resize(): void;
  38061. /**
  38062. * Force a specific size of the canvas
  38063. * @param width defines the new canvas' width
  38064. * @param height defines the new canvas' height
  38065. * @returns true if the size was changed
  38066. */
  38067. setSize(width: number, height: number): boolean;
  38068. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38069. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38070. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38071. _releaseTexture(texture: InternalTexture): void;
  38072. /**
  38073. * @hidden
  38074. * Rescales a texture
  38075. * @param source input texutre
  38076. * @param destination destination texture
  38077. * @param scene scene to use to render the resize
  38078. * @param internalFormat format to use when resizing
  38079. * @param onComplete callback to be called when resize has completed
  38080. */
  38081. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38082. /**
  38083. * Gets the current framerate
  38084. * @returns a number representing the framerate
  38085. */
  38086. getFps(): number;
  38087. /**
  38088. * Gets the time spent between current and previous frame
  38089. * @returns a number representing the delta time in ms
  38090. */
  38091. getDeltaTime(): number;
  38092. private _measureFps;
  38093. /** @hidden */
  38094. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38095. /**
  38096. * Updates the sample count of a render target texture
  38097. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38098. * @param texture defines the texture to update
  38099. * @param samples defines the sample count to set
  38100. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38101. */
  38102. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38103. /**
  38104. * Updates a depth texture Comparison Mode and Function.
  38105. * If the comparison Function is equal to 0, the mode will be set to none.
  38106. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38107. * @param texture The texture to set the comparison function for
  38108. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38109. */
  38110. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38111. /**
  38112. * Creates a webGL buffer to use with instanciation
  38113. * @param capacity defines the size of the buffer
  38114. * @returns the webGL buffer
  38115. */
  38116. createInstancesBuffer(capacity: number): DataBuffer;
  38117. /**
  38118. * Delete a webGL buffer used with instanciation
  38119. * @param buffer defines the webGL buffer to delete
  38120. */
  38121. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38122. private _clientWaitAsync;
  38123. /** @hidden */
  38124. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38125. dispose(): void;
  38126. private _disableTouchAction;
  38127. /**
  38128. * Display the loading screen
  38129. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38130. */
  38131. displayLoadingUI(): void;
  38132. /**
  38133. * Hide the loading screen
  38134. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38135. */
  38136. hideLoadingUI(): void;
  38137. /**
  38138. * Gets the current loading screen object
  38139. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38140. */
  38141. get loadingScreen(): ILoadingScreen;
  38142. /**
  38143. * Sets the current loading screen object
  38144. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38145. */
  38146. set loadingScreen(loadingScreen: ILoadingScreen);
  38147. /**
  38148. * Sets the current loading screen text
  38149. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38150. */
  38151. set loadingUIText(text: string);
  38152. /**
  38153. * Sets the current loading screen background color
  38154. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38155. */
  38156. set loadingUIBackgroundColor(color: string);
  38157. /** Pointerlock and fullscreen */
  38158. /**
  38159. * Ask the browser to promote the current element to pointerlock mode
  38160. * @param element defines the DOM element to promote
  38161. */
  38162. static _RequestPointerlock(element: HTMLElement): void;
  38163. /**
  38164. * Asks the browser to exit pointerlock mode
  38165. */
  38166. static _ExitPointerlock(): void;
  38167. /**
  38168. * Ask the browser to promote the current element to fullscreen rendering mode
  38169. * @param element defines the DOM element to promote
  38170. */
  38171. static _RequestFullscreen(element: HTMLElement): void;
  38172. /**
  38173. * Asks the browser to exit fullscreen mode
  38174. */
  38175. static _ExitFullscreen(): void;
  38176. }
  38177. }
  38178. declare module BABYLON {
  38179. /**
  38180. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38181. * during the life time of the application.
  38182. */
  38183. export class EngineStore {
  38184. /** Gets the list of created engines */
  38185. static Instances: Engine[];
  38186. /** @hidden */
  38187. static _LastCreatedScene: Nullable<Scene>;
  38188. /**
  38189. * Gets the latest created engine
  38190. */
  38191. static get LastCreatedEngine(): Nullable<Engine>;
  38192. /**
  38193. * Gets the latest created scene
  38194. */
  38195. static get LastCreatedScene(): Nullable<Scene>;
  38196. /**
  38197. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38198. * @ignorenaming
  38199. */
  38200. static UseFallbackTexture: boolean;
  38201. /**
  38202. * Texture content used if a texture cannot loaded
  38203. * @ignorenaming
  38204. */
  38205. static FallbackTexture: string;
  38206. }
  38207. }
  38208. declare module BABYLON {
  38209. /**
  38210. * Helper class that provides a small promise polyfill
  38211. */
  38212. export class PromisePolyfill {
  38213. /**
  38214. * Static function used to check if the polyfill is required
  38215. * If this is the case then the function will inject the polyfill to window.Promise
  38216. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38217. */
  38218. static Apply(force?: boolean): void;
  38219. }
  38220. }
  38221. declare module BABYLON {
  38222. /**
  38223. * Interface for screenshot methods with describe argument called `size` as object with options
  38224. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38225. */
  38226. export interface IScreenshotSize {
  38227. /**
  38228. * number in pixels for canvas height
  38229. */
  38230. height?: number;
  38231. /**
  38232. * multiplier allowing render at a higher or lower resolution
  38233. * If value is defined then height and width will be ignored and taken from camera
  38234. */
  38235. precision?: number;
  38236. /**
  38237. * number in pixels for canvas width
  38238. */
  38239. width?: number;
  38240. }
  38241. }
  38242. declare module BABYLON {
  38243. interface IColor4Like {
  38244. r: float;
  38245. g: float;
  38246. b: float;
  38247. a: float;
  38248. }
  38249. /**
  38250. * Class containing a set of static utilities functions
  38251. */
  38252. export class Tools {
  38253. /**
  38254. * Gets or sets the base URL to use to load assets
  38255. */
  38256. static get BaseUrl(): string;
  38257. static set BaseUrl(value: string);
  38258. /**
  38259. * Enable/Disable Custom HTTP Request Headers globally.
  38260. * default = false
  38261. * @see CustomRequestHeaders
  38262. */
  38263. static UseCustomRequestHeaders: boolean;
  38264. /**
  38265. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38266. * i.e. when loading files, where the server/service expects an Authorization header
  38267. */
  38268. static CustomRequestHeaders: {
  38269. [key: string]: string;
  38270. };
  38271. /**
  38272. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38273. */
  38274. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38275. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38276. /**
  38277. * Default behaviour for cors in the application.
  38278. * It can be a string if the expected behavior is identical in the entire app.
  38279. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38280. */
  38281. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38282. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38283. /**
  38284. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38285. * @ignorenaming
  38286. */
  38287. static get UseFallbackTexture(): boolean;
  38288. static set UseFallbackTexture(value: boolean);
  38289. /**
  38290. * Use this object to register external classes like custom textures or material
  38291. * to allow the laoders to instantiate them
  38292. */
  38293. static get RegisteredExternalClasses(): {
  38294. [key: string]: Object;
  38295. };
  38296. static set RegisteredExternalClasses(classes: {
  38297. [key: string]: Object;
  38298. });
  38299. /**
  38300. * Texture content used if a texture cannot loaded
  38301. * @ignorenaming
  38302. */
  38303. static get fallbackTexture(): string;
  38304. static set fallbackTexture(value: string);
  38305. /**
  38306. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38307. * @param u defines the coordinate on X axis
  38308. * @param v defines the coordinate on Y axis
  38309. * @param width defines the width of the source data
  38310. * @param height defines the height of the source data
  38311. * @param pixels defines the source byte array
  38312. * @param color defines the output color
  38313. */
  38314. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38315. /**
  38316. * Interpolates between a and b via alpha
  38317. * @param a The lower value (returned when alpha = 0)
  38318. * @param b The upper value (returned when alpha = 1)
  38319. * @param alpha The interpolation-factor
  38320. * @return The mixed value
  38321. */
  38322. static Mix(a: number, b: number, alpha: number): number;
  38323. /**
  38324. * Tries to instantiate a new object from a given class name
  38325. * @param className defines the class name to instantiate
  38326. * @returns the new object or null if the system was not able to do the instantiation
  38327. */
  38328. static Instantiate(className: string): any;
  38329. /**
  38330. * Provides a slice function that will work even on IE
  38331. * @param data defines the array to slice
  38332. * @param start defines the start of the data (optional)
  38333. * @param end defines the end of the data (optional)
  38334. * @returns the new sliced array
  38335. */
  38336. static Slice<T>(data: T, start?: number, end?: number): T;
  38337. /**
  38338. * Polyfill for setImmediate
  38339. * @param action defines the action to execute after the current execution block
  38340. */
  38341. static SetImmediate(action: () => void): void;
  38342. /**
  38343. * Function indicating if a number is an exponent of 2
  38344. * @param value defines the value to test
  38345. * @returns true if the value is an exponent of 2
  38346. */
  38347. static IsExponentOfTwo(value: number): boolean;
  38348. private static _tmpFloatArray;
  38349. /**
  38350. * Returns the nearest 32-bit single precision float representation of a Number
  38351. * @param value A Number. If the parameter is of a different type, it will get converted
  38352. * to a number or to NaN if it cannot be converted
  38353. * @returns number
  38354. */
  38355. static FloatRound(value: number): number;
  38356. /**
  38357. * Extracts the filename from a path
  38358. * @param path defines the path to use
  38359. * @returns the filename
  38360. */
  38361. static GetFilename(path: string): string;
  38362. /**
  38363. * Extracts the "folder" part of a path (everything before the filename).
  38364. * @param uri The URI to extract the info from
  38365. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38366. * @returns The "folder" part of the path
  38367. */
  38368. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38369. /**
  38370. * Extracts text content from a DOM element hierarchy
  38371. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38372. */
  38373. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38374. /**
  38375. * Convert an angle in radians to degrees
  38376. * @param angle defines the angle to convert
  38377. * @returns the angle in degrees
  38378. */
  38379. static ToDegrees(angle: number): number;
  38380. /**
  38381. * Convert an angle in degrees to radians
  38382. * @param angle defines the angle to convert
  38383. * @returns the angle in radians
  38384. */
  38385. static ToRadians(angle: number): number;
  38386. /**
  38387. * Returns an array if obj is not an array
  38388. * @param obj defines the object to evaluate as an array
  38389. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38390. * @returns either obj directly if obj is an array or a new array containing obj
  38391. */
  38392. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38393. /**
  38394. * Gets the pointer prefix to use
  38395. * @param engine defines the engine we are finding the prefix for
  38396. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38397. */
  38398. static GetPointerPrefix(engine: Engine): string;
  38399. /**
  38400. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38401. * @param url define the url we are trying
  38402. * @param element define the dom element where to configure the cors policy
  38403. */
  38404. static SetCorsBehavior(url: string | string[], element: {
  38405. crossOrigin: string | null;
  38406. }): void;
  38407. /**
  38408. * Removes unwanted characters from an url
  38409. * @param url defines the url to clean
  38410. * @returns the cleaned url
  38411. */
  38412. static CleanUrl(url: string): string;
  38413. /**
  38414. * Gets or sets a function used to pre-process url before using them to load assets
  38415. */
  38416. static get PreprocessUrl(): (url: string) => string;
  38417. static set PreprocessUrl(processor: (url: string) => string);
  38418. /**
  38419. * Loads an image as an HTMLImageElement.
  38420. * @param input url string, ArrayBuffer, or Blob to load
  38421. * @param onLoad callback called when the image successfully loads
  38422. * @param onError callback called when the image fails to load
  38423. * @param offlineProvider offline provider for caching
  38424. * @param mimeType optional mime type
  38425. * @returns the HTMLImageElement of the loaded image
  38426. */
  38427. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38428. /**
  38429. * Loads a file from a url
  38430. * @param url url string, ArrayBuffer, or Blob to load
  38431. * @param onSuccess callback called when the file successfully loads
  38432. * @param onProgress callback called while file is loading (if the server supports this mode)
  38433. * @param offlineProvider defines the offline provider for caching
  38434. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38435. * @param onError callback called when the file fails to load
  38436. * @returns a file request object
  38437. */
  38438. 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;
  38439. /**
  38440. * Loads a file from a url
  38441. * @param url the file url to load
  38442. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38443. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38444. */
  38445. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38446. /**
  38447. * Load a script (identified by an url). When the url returns, the
  38448. * content of this file is added into a new script element, attached to the DOM (body element)
  38449. * @param scriptUrl defines the url of the script to laod
  38450. * @param onSuccess defines the callback called when the script is loaded
  38451. * @param onError defines the callback to call if an error occurs
  38452. * @param scriptId defines the id of the script element
  38453. */
  38454. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38455. /**
  38456. * Load an asynchronous script (identified by an url). When the url returns, the
  38457. * content of this file is added into a new script element, attached to the DOM (body element)
  38458. * @param scriptUrl defines the url of the script to laod
  38459. * @param scriptId defines the id of the script element
  38460. * @returns a promise request object
  38461. */
  38462. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38463. /**
  38464. * Loads a file from a blob
  38465. * @param fileToLoad defines the blob to use
  38466. * @param callback defines the callback to call when data is loaded
  38467. * @param progressCallback defines the callback to call during loading process
  38468. * @returns a file request object
  38469. */
  38470. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38471. /**
  38472. * Reads a file from a File object
  38473. * @param file defines the file to load
  38474. * @param onSuccess defines the callback to call when data is loaded
  38475. * @param onProgress defines the callback to call during loading process
  38476. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38477. * @param onError defines the callback to call when an error occurs
  38478. * @returns a file request object
  38479. */
  38480. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38481. /**
  38482. * Creates a data url from a given string content
  38483. * @param content defines the content to convert
  38484. * @returns the new data url link
  38485. */
  38486. static FileAsURL(content: string): string;
  38487. /**
  38488. * Format the given number to a specific decimal format
  38489. * @param value defines the number to format
  38490. * @param decimals defines the number of decimals to use
  38491. * @returns the formatted string
  38492. */
  38493. static Format(value: number, decimals?: number): string;
  38494. /**
  38495. * Tries to copy an object by duplicating every property
  38496. * @param source defines the source object
  38497. * @param destination defines the target object
  38498. * @param doNotCopyList defines a list of properties to avoid
  38499. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38500. */
  38501. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38502. /**
  38503. * Gets a boolean indicating if the given object has no own property
  38504. * @param obj defines the object to test
  38505. * @returns true if object has no own property
  38506. */
  38507. static IsEmpty(obj: any): boolean;
  38508. /**
  38509. * Function used to register events at window level
  38510. * @param windowElement defines the Window object to use
  38511. * @param events defines the events to register
  38512. */
  38513. static RegisterTopRootEvents(windowElement: Window, events: {
  38514. name: string;
  38515. handler: Nullable<(e: FocusEvent) => any>;
  38516. }[]): void;
  38517. /**
  38518. * Function used to unregister events from window level
  38519. * @param windowElement defines the Window object to use
  38520. * @param events defines the events to unregister
  38521. */
  38522. static UnregisterTopRootEvents(windowElement: Window, events: {
  38523. name: string;
  38524. handler: Nullable<(e: FocusEvent) => any>;
  38525. }[]): void;
  38526. /**
  38527. * @ignore
  38528. */
  38529. static _ScreenshotCanvas: HTMLCanvasElement;
  38530. /**
  38531. * Dumps the current bound framebuffer
  38532. * @param width defines the rendering width
  38533. * @param height defines the rendering height
  38534. * @param engine defines the hosting engine
  38535. * @param successCallback defines the callback triggered once the data are available
  38536. * @param mimeType defines the mime type of the result
  38537. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38538. */
  38539. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38540. /**
  38541. * Converts the canvas data to blob.
  38542. * This acts as a polyfill for browsers not supporting the to blob function.
  38543. * @param canvas Defines the canvas to extract the data from
  38544. * @param successCallback Defines the callback triggered once the data are available
  38545. * @param mimeType Defines the mime type of the result
  38546. */
  38547. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38548. /**
  38549. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38550. * @param successCallback defines the callback triggered once the data are available
  38551. * @param mimeType defines the mime type of the result
  38552. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38553. */
  38554. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38555. /**
  38556. * Downloads a blob in the browser
  38557. * @param blob defines the blob to download
  38558. * @param fileName defines the name of the downloaded file
  38559. */
  38560. static Download(blob: Blob, fileName: string): void;
  38561. /**
  38562. * Captures a screenshot of the current rendering
  38563. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38564. * @param engine defines the rendering engine
  38565. * @param camera defines the source camera
  38566. * @param size This parameter can be set to a single number or to an object with the
  38567. * following (optional) properties: precision, width, height. If a single number is passed,
  38568. * it will be used for both width and height. If an object is passed, the screenshot size
  38569. * will be derived from the parameters. The precision property is a multiplier allowing
  38570. * rendering at a higher or lower resolution
  38571. * @param successCallback defines the callback receives a single parameter which contains the
  38572. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38573. * src parameter of an <img> to display it
  38574. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38575. * Check your browser for supported MIME types
  38576. */
  38577. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38578. /**
  38579. * Captures a screenshot of the current rendering
  38580. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38581. * @param engine defines the rendering engine
  38582. * @param camera defines the source camera
  38583. * @param size This parameter can be set to a single number or to an object with the
  38584. * following (optional) properties: precision, width, height. If a single number is passed,
  38585. * it will be used for both width and height. If an object is passed, the screenshot size
  38586. * will be derived from the parameters. The precision property is a multiplier allowing
  38587. * rendering at a higher or lower resolution
  38588. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38589. * Check your browser for supported MIME types
  38590. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38591. * to the src parameter of an <img> to display it
  38592. */
  38593. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38594. /**
  38595. * Generates an image screenshot from the specified camera.
  38596. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38597. * @param engine The engine to use for rendering
  38598. * @param camera The camera to use for rendering
  38599. * @param size This parameter can be set to a single number or to an object with the
  38600. * following (optional) properties: precision, width, height. If a single number is passed,
  38601. * it will be used for both width and height. If an object is passed, the screenshot size
  38602. * will be derived from the parameters. The precision property is a multiplier allowing
  38603. * rendering at a higher or lower resolution
  38604. * @param successCallback The callback receives a single parameter which contains the
  38605. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38606. * src parameter of an <img> to display it
  38607. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38608. * Check your browser for supported MIME types
  38609. * @param samples Texture samples (default: 1)
  38610. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38611. * @param fileName A name for for the downloaded file.
  38612. */
  38613. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38614. /**
  38615. * Generates an image screenshot from the specified camera.
  38616. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38617. * @param engine The engine to use for rendering
  38618. * @param camera The camera to use for rendering
  38619. * @param size This parameter can be set to a single number or to an object with the
  38620. * following (optional) properties: precision, width, height. If a single number is passed,
  38621. * it will be used for both width and height. If an object is passed, the screenshot size
  38622. * will be derived from the parameters. The precision property is a multiplier allowing
  38623. * rendering at a higher or lower resolution
  38624. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38625. * Check your browser for supported MIME types
  38626. * @param samples Texture samples (default: 1)
  38627. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38628. * @param fileName A name for for the downloaded file.
  38629. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38630. * to the src parameter of an <img> to display it
  38631. */
  38632. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38633. /**
  38634. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38635. * Be aware Math.random() could cause collisions, but:
  38636. * "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"
  38637. * @returns a pseudo random id
  38638. */
  38639. static RandomId(): string;
  38640. /**
  38641. * Test if the given uri is a base64 string
  38642. * @param uri The uri to test
  38643. * @return True if the uri is a base64 string or false otherwise
  38644. */
  38645. static IsBase64(uri: string): boolean;
  38646. /**
  38647. * Decode the given base64 uri.
  38648. * @param uri The uri to decode
  38649. * @return The decoded base64 data.
  38650. */
  38651. static DecodeBase64(uri: string): ArrayBuffer;
  38652. /**
  38653. * Gets the absolute url.
  38654. * @param url the input url
  38655. * @return the absolute url
  38656. */
  38657. static GetAbsoluteUrl(url: string): string;
  38658. /**
  38659. * No log
  38660. */
  38661. static readonly NoneLogLevel: number;
  38662. /**
  38663. * Only message logs
  38664. */
  38665. static readonly MessageLogLevel: number;
  38666. /**
  38667. * Only warning logs
  38668. */
  38669. static readonly WarningLogLevel: number;
  38670. /**
  38671. * Only error logs
  38672. */
  38673. static readonly ErrorLogLevel: number;
  38674. /**
  38675. * All logs
  38676. */
  38677. static readonly AllLogLevel: number;
  38678. /**
  38679. * Gets a value indicating the number of loading errors
  38680. * @ignorenaming
  38681. */
  38682. static get errorsCount(): number;
  38683. /**
  38684. * Callback called when a new log is added
  38685. */
  38686. static OnNewCacheEntry: (entry: string) => void;
  38687. /**
  38688. * Log a message to the console
  38689. * @param message defines the message to log
  38690. */
  38691. static Log(message: string): void;
  38692. /**
  38693. * Write a warning message to the console
  38694. * @param message defines the message to log
  38695. */
  38696. static Warn(message: string): void;
  38697. /**
  38698. * Write an error message to the console
  38699. * @param message defines the message to log
  38700. */
  38701. static Error(message: string): void;
  38702. /**
  38703. * Gets current log cache (list of logs)
  38704. */
  38705. static get LogCache(): string;
  38706. /**
  38707. * Clears the log cache
  38708. */
  38709. static ClearLogCache(): void;
  38710. /**
  38711. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38712. */
  38713. static set LogLevels(level: number);
  38714. /**
  38715. * Checks if the window object exists
  38716. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38717. */
  38718. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38719. /**
  38720. * No performance log
  38721. */
  38722. static readonly PerformanceNoneLogLevel: number;
  38723. /**
  38724. * Use user marks to log performance
  38725. */
  38726. static readonly PerformanceUserMarkLogLevel: number;
  38727. /**
  38728. * Log performance to the console
  38729. */
  38730. static readonly PerformanceConsoleLogLevel: number;
  38731. private static _performance;
  38732. /**
  38733. * Sets the current performance log level
  38734. */
  38735. static set PerformanceLogLevel(level: number);
  38736. private static _StartPerformanceCounterDisabled;
  38737. private static _EndPerformanceCounterDisabled;
  38738. private static _StartUserMark;
  38739. private static _EndUserMark;
  38740. private static _StartPerformanceConsole;
  38741. private static _EndPerformanceConsole;
  38742. /**
  38743. * Starts a performance counter
  38744. */
  38745. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38746. /**
  38747. * Ends a specific performance coutner
  38748. */
  38749. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38750. /**
  38751. * Gets either window.performance.now() if supported or Date.now() else
  38752. */
  38753. static get Now(): number;
  38754. /**
  38755. * This method will return the name of the class used to create the instance of the given object.
  38756. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38757. * @param object the object to get the class name from
  38758. * @param isType defines if the object is actually a type
  38759. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38760. */
  38761. static GetClassName(object: any, isType?: boolean): string;
  38762. /**
  38763. * Gets the first element of an array satisfying a given predicate
  38764. * @param array defines the array to browse
  38765. * @param predicate defines the predicate to use
  38766. * @returns null if not found or the element
  38767. */
  38768. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38769. /**
  38770. * This method will return the name of the full name of the class, including its owning module (if any).
  38771. * 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).
  38772. * @param object the object to get the class name from
  38773. * @param isType defines if the object is actually a type
  38774. * @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.
  38775. * @ignorenaming
  38776. */
  38777. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38778. /**
  38779. * Returns a promise that resolves after the given amount of time.
  38780. * @param delay Number of milliseconds to delay
  38781. * @returns Promise that resolves after the given amount of time
  38782. */
  38783. static DelayAsync(delay: number): Promise<void>;
  38784. /**
  38785. * Utility function to detect if the current user agent is Safari
  38786. * @returns whether or not the current user agent is safari
  38787. */
  38788. static IsSafari(): boolean;
  38789. }
  38790. /**
  38791. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38792. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38793. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38794. * @param name The name of the class, case should be preserved
  38795. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38796. */
  38797. export function className(name: string, module?: string): (target: Object) => void;
  38798. /**
  38799. * An implementation of a loop for asynchronous functions.
  38800. */
  38801. export class AsyncLoop {
  38802. /**
  38803. * Defines the number of iterations for the loop
  38804. */
  38805. iterations: number;
  38806. /**
  38807. * Defines the current index of the loop.
  38808. */
  38809. index: number;
  38810. private _done;
  38811. private _fn;
  38812. private _successCallback;
  38813. /**
  38814. * Constructor.
  38815. * @param iterations the number of iterations.
  38816. * @param func the function to run each iteration
  38817. * @param successCallback the callback that will be called upon succesful execution
  38818. * @param offset starting offset.
  38819. */
  38820. constructor(
  38821. /**
  38822. * Defines the number of iterations for the loop
  38823. */
  38824. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38825. /**
  38826. * Execute the next iteration. Must be called after the last iteration was finished.
  38827. */
  38828. executeNext(): void;
  38829. /**
  38830. * Break the loop and run the success callback.
  38831. */
  38832. breakLoop(): void;
  38833. /**
  38834. * Create and run an async loop.
  38835. * @param iterations the number of iterations.
  38836. * @param fn the function to run each iteration
  38837. * @param successCallback the callback that will be called upon succesful execution
  38838. * @param offset starting offset.
  38839. * @returns the created async loop object
  38840. */
  38841. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38842. /**
  38843. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38844. * @param iterations total number of iterations
  38845. * @param syncedIterations number of synchronous iterations in each async iteration.
  38846. * @param fn the function to call each iteration.
  38847. * @param callback a success call back that will be called when iterating stops.
  38848. * @param breakFunction a break condition (optional)
  38849. * @param timeout timeout settings for the setTimeout function. default - 0.
  38850. * @returns the created async loop object
  38851. */
  38852. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38853. }
  38854. }
  38855. declare module BABYLON {
  38856. /**
  38857. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38858. * The underlying implementation relies on an associative array to ensure the best performances.
  38859. * The value can be anything including 'null' but except 'undefined'
  38860. */
  38861. export class StringDictionary<T> {
  38862. /**
  38863. * This will clear this dictionary and copy the content from the 'source' one.
  38864. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38865. * @param source the dictionary to take the content from and copy to this dictionary
  38866. */
  38867. copyFrom(source: StringDictionary<T>): void;
  38868. /**
  38869. * Get a value based from its key
  38870. * @param key the given key to get the matching value from
  38871. * @return the value if found, otherwise undefined is returned
  38872. */
  38873. get(key: string): T | undefined;
  38874. /**
  38875. * Get a value from its key or add it if it doesn't exist.
  38876. * This method will ensure you that a given key/data will be present in the dictionary.
  38877. * @param key the given key to get the matching value from
  38878. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38879. * The factory will only be invoked if there's no data for the given key.
  38880. * @return the value corresponding to the key.
  38881. */
  38882. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38883. /**
  38884. * Get a value from its key if present in the dictionary otherwise add it
  38885. * @param key the key to get the value from
  38886. * @param val if there's no such key/value pair in the dictionary add it with this value
  38887. * @return the value corresponding to the key
  38888. */
  38889. getOrAdd(key: string, val: T): T;
  38890. /**
  38891. * Check if there's a given key in the dictionary
  38892. * @param key the key to check for
  38893. * @return true if the key is present, false otherwise
  38894. */
  38895. contains(key: string): boolean;
  38896. /**
  38897. * Add a new key and its corresponding value
  38898. * @param key the key to add
  38899. * @param value the value corresponding to the key
  38900. * @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
  38901. */
  38902. add(key: string, value: T): boolean;
  38903. /**
  38904. * Update a specific value associated to a key
  38905. * @param key defines the key to use
  38906. * @param value defines the value to store
  38907. * @returns true if the value was updated (or false if the key was not found)
  38908. */
  38909. set(key: string, value: T): boolean;
  38910. /**
  38911. * Get the element of the given key and remove it from the dictionary
  38912. * @param key defines the key to search
  38913. * @returns the value associated with the key or null if not found
  38914. */
  38915. getAndRemove(key: string): Nullable<T>;
  38916. /**
  38917. * Remove a key/value from the dictionary.
  38918. * @param key the key to remove
  38919. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38920. */
  38921. remove(key: string): boolean;
  38922. /**
  38923. * Clear the whole content of the dictionary
  38924. */
  38925. clear(): void;
  38926. /**
  38927. * Gets the current count
  38928. */
  38929. get count(): number;
  38930. /**
  38931. * Execute a callback on each key/val of the dictionary.
  38932. * Note that you can remove any element in this dictionary in the callback implementation
  38933. * @param callback the callback to execute on a given key/value pair
  38934. */
  38935. forEach(callback: (key: string, val: T) => void): void;
  38936. /**
  38937. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38938. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38939. * Note that you can remove any element in this dictionary in the callback implementation
  38940. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38941. * @returns the first item
  38942. */
  38943. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38944. private _count;
  38945. private _data;
  38946. }
  38947. }
  38948. declare module BABYLON {
  38949. /** @hidden */
  38950. export interface ICollisionCoordinator {
  38951. createCollider(): Collider;
  38952. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38953. init(scene: Scene): void;
  38954. }
  38955. /** @hidden */
  38956. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38957. private _scene;
  38958. private _scaledPosition;
  38959. private _scaledVelocity;
  38960. private _finalPosition;
  38961. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38962. createCollider(): Collider;
  38963. init(scene: Scene): void;
  38964. private _collideWithWorld;
  38965. }
  38966. }
  38967. declare module BABYLON {
  38968. /**
  38969. * Class used to manage all inputs for the scene.
  38970. */
  38971. export class InputManager {
  38972. /** The distance in pixel that you have to move to prevent some events */
  38973. static DragMovementThreshold: number;
  38974. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38975. static LongPressDelay: number;
  38976. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38977. static DoubleClickDelay: number;
  38978. /** If you need to check double click without raising a single click at first click, enable this flag */
  38979. static ExclusiveDoubleClickMode: boolean;
  38980. /** 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. */
  38981. private _alreadyAttached;
  38982. private _wheelEventName;
  38983. private _onPointerMove;
  38984. private _onPointerDown;
  38985. private _onPointerUp;
  38986. private _initClickEvent;
  38987. private _initActionManager;
  38988. private _delayedSimpleClick;
  38989. private _delayedSimpleClickTimeout;
  38990. private _previousDelayedSimpleClickTimeout;
  38991. private _meshPickProceed;
  38992. private _previousButtonPressed;
  38993. private _currentPickResult;
  38994. private _previousPickResult;
  38995. private _totalPointersPressed;
  38996. private _doubleClickOccured;
  38997. private _pointerOverMesh;
  38998. private _pickedDownMesh;
  38999. private _pickedUpMesh;
  39000. private _pointerX;
  39001. private _pointerY;
  39002. private _unTranslatedPointerX;
  39003. private _unTranslatedPointerY;
  39004. private _startingPointerPosition;
  39005. private _previousStartingPointerPosition;
  39006. private _startingPointerTime;
  39007. private _previousStartingPointerTime;
  39008. private _pointerCaptures;
  39009. private _meshUnderPointerId;
  39010. private _onKeyDown;
  39011. private _onKeyUp;
  39012. private _onCanvasFocusObserver;
  39013. private _onCanvasBlurObserver;
  39014. private _scene;
  39015. /**
  39016. * Creates a new InputManager
  39017. * @param scene defines the hosting scene
  39018. */
  39019. constructor(scene: Scene);
  39020. /**
  39021. * Gets the mesh that is currently under the pointer
  39022. */
  39023. get meshUnderPointer(): Nullable<AbstractMesh>;
  39024. /**
  39025. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  39026. * @param pointerId the pointer id to use
  39027. * @returns The mesh under this pointer id or null if not found
  39028. */
  39029. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  39030. /**
  39031. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39032. */
  39033. get unTranslatedPointer(): Vector2;
  39034. /**
  39035. * Gets or sets the current on-screen X position of the pointer
  39036. */
  39037. get pointerX(): number;
  39038. set pointerX(value: number);
  39039. /**
  39040. * Gets or sets the current on-screen Y position of the pointer
  39041. */
  39042. get pointerY(): number;
  39043. set pointerY(value: number);
  39044. private _updatePointerPosition;
  39045. private _processPointerMove;
  39046. private _setRayOnPointerInfo;
  39047. private _checkPrePointerObservable;
  39048. /**
  39049. * Use this method to simulate a pointer move on a mesh
  39050. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39051. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39052. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39053. */
  39054. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39055. /**
  39056. * Use this method to simulate a pointer down on a mesh
  39057. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39058. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39059. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39060. */
  39061. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39062. private _processPointerDown;
  39063. /** @hidden */
  39064. _isPointerSwiping(): boolean;
  39065. /**
  39066. * Use this method to simulate a pointer up on a mesh
  39067. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39068. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39069. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39070. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39071. */
  39072. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39073. private _processPointerUp;
  39074. /**
  39075. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39076. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39077. * @returns true if the pointer was captured
  39078. */
  39079. isPointerCaptured(pointerId?: number): boolean;
  39080. /**
  39081. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39082. * @param attachUp defines if you want to attach events to pointerup
  39083. * @param attachDown defines if you want to attach events to pointerdown
  39084. * @param attachMove defines if you want to attach events to pointermove
  39085. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39086. */
  39087. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39088. /**
  39089. * Detaches all event handlers
  39090. */
  39091. detachControl(): void;
  39092. /**
  39093. * Force the value of meshUnderPointer
  39094. * @param mesh defines the mesh to use
  39095. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39096. */
  39097. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39098. /**
  39099. * Gets the mesh under the pointer
  39100. * @returns a Mesh or null if no mesh is under the pointer
  39101. */
  39102. getPointerOverMesh(): Nullable<AbstractMesh>;
  39103. }
  39104. }
  39105. declare module BABYLON {
  39106. /**
  39107. * This class defines the direct association between an animation and a target
  39108. */
  39109. export class TargetedAnimation {
  39110. /**
  39111. * Animation to perform
  39112. */
  39113. animation: Animation;
  39114. /**
  39115. * Target to animate
  39116. */
  39117. target: any;
  39118. /**
  39119. * Returns the string "TargetedAnimation"
  39120. * @returns "TargetedAnimation"
  39121. */
  39122. getClassName(): string;
  39123. /**
  39124. * Serialize the object
  39125. * @returns the JSON object representing the current entity
  39126. */
  39127. serialize(): any;
  39128. }
  39129. /**
  39130. * Use this class to create coordinated animations on multiple targets
  39131. */
  39132. export class AnimationGroup implements IDisposable {
  39133. /** The name of the animation group */
  39134. name: string;
  39135. private _scene;
  39136. private _targetedAnimations;
  39137. private _animatables;
  39138. private _from;
  39139. private _to;
  39140. private _isStarted;
  39141. private _isPaused;
  39142. private _speedRatio;
  39143. private _loopAnimation;
  39144. private _isAdditive;
  39145. /**
  39146. * Gets or sets the unique id of the node
  39147. */
  39148. uniqueId: number;
  39149. /**
  39150. * This observable will notify when one animation have ended
  39151. */
  39152. onAnimationEndObservable: Observable<TargetedAnimation>;
  39153. /**
  39154. * Observer raised when one animation loops
  39155. */
  39156. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39157. /**
  39158. * Observer raised when all animations have looped
  39159. */
  39160. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39161. /**
  39162. * This observable will notify when all animations have ended.
  39163. */
  39164. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39165. /**
  39166. * This observable will notify when all animations have paused.
  39167. */
  39168. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39169. /**
  39170. * This observable will notify when all animations are playing.
  39171. */
  39172. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39173. /**
  39174. * Gets the first frame
  39175. */
  39176. get from(): number;
  39177. /**
  39178. * Gets the last frame
  39179. */
  39180. get to(): number;
  39181. /**
  39182. * Define if the animations are started
  39183. */
  39184. get isStarted(): boolean;
  39185. /**
  39186. * Gets a value indicating that the current group is playing
  39187. */
  39188. get isPlaying(): boolean;
  39189. /**
  39190. * Gets or sets the speed ratio to use for all animations
  39191. */
  39192. get speedRatio(): number;
  39193. /**
  39194. * Gets or sets the speed ratio to use for all animations
  39195. */
  39196. set speedRatio(value: number);
  39197. /**
  39198. * Gets or sets if all animations should loop or not
  39199. */
  39200. get loopAnimation(): boolean;
  39201. set loopAnimation(value: boolean);
  39202. /**
  39203. * Gets or sets if all animations should be evaluated additively
  39204. */
  39205. get isAdditive(): boolean;
  39206. set isAdditive(value: boolean);
  39207. /**
  39208. * Gets the targeted animations for this animation group
  39209. */
  39210. get targetedAnimations(): Array<TargetedAnimation>;
  39211. /**
  39212. * returning the list of animatables controlled by this animation group.
  39213. */
  39214. get animatables(): Array<Animatable>;
  39215. /**
  39216. * Gets the list of target animations
  39217. */
  39218. get children(): TargetedAnimation[];
  39219. /**
  39220. * Instantiates a new Animation Group.
  39221. * This helps managing several animations at once.
  39222. * @see https://doc.babylonjs.com/how_to/group
  39223. * @param name Defines the name of the group
  39224. * @param scene Defines the scene the group belongs to
  39225. */
  39226. constructor(
  39227. /** The name of the animation group */
  39228. name: string, scene?: Nullable<Scene>);
  39229. /**
  39230. * Add an animation (with its target) in the group
  39231. * @param animation defines the animation we want to add
  39232. * @param target defines the target of the animation
  39233. * @returns the TargetedAnimation object
  39234. */
  39235. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39236. /**
  39237. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39238. * It can add constant keys at begin or end
  39239. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39240. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39241. * @returns the animation group
  39242. */
  39243. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39244. private _animationLoopCount;
  39245. private _animationLoopFlags;
  39246. private _processLoop;
  39247. /**
  39248. * Start all animations on given targets
  39249. * @param loop defines if animations must loop
  39250. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39251. * @param from defines the from key (optional)
  39252. * @param to defines the to key (optional)
  39253. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39254. * @returns the current animation group
  39255. */
  39256. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39257. /**
  39258. * Pause all animations
  39259. * @returns the animation group
  39260. */
  39261. pause(): AnimationGroup;
  39262. /**
  39263. * Play all animations to initial state
  39264. * This function will start() the animations if they were not started or will restart() them if they were paused
  39265. * @param loop defines if animations must loop
  39266. * @returns the animation group
  39267. */
  39268. play(loop?: boolean): AnimationGroup;
  39269. /**
  39270. * Reset all animations to initial state
  39271. * @returns the animation group
  39272. */
  39273. reset(): AnimationGroup;
  39274. /**
  39275. * Restart animations from key 0
  39276. * @returns the animation group
  39277. */
  39278. restart(): AnimationGroup;
  39279. /**
  39280. * Stop all animations
  39281. * @returns the animation group
  39282. */
  39283. stop(): AnimationGroup;
  39284. /**
  39285. * Set animation weight for all animatables
  39286. * @param weight defines the weight to use
  39287. * @return the animationGroup
  39288. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39289. */
  39290. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39291. /**
  39292. * Synchronize and normalize all animatables with a source animatable
  39293. * @param root defines the root animatable to synchronize with
  39294. * @return the animationGroup
  39295. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39296. */
  39297. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39298. /**
  39299. * Goes to a specific frame in this animation group
  39300. * @param frame the frame number to go to
  39301. * @return the animationGroup
  39302. */
  39303. goToFrame(frame: number): AnimationGroup;
  39304. /**
  39305. * Dispose all associated resources
  39306. */
  39307. dispose(): void;
  39308. private _checkAnimationGroupEnded;
  39309. /**
  39310. * Clone the current animation group and returns a copy
  39311. * @param newName defines the name of the new group
  39312. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39313. * @returns the new aniamtion group
  39314. */
  39315. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39316. /**
  39317. * Serializes the animationGroup to an object
  39318. * @returns Serialized object
  39319. */
  39320. serialize(): any;
  39321. /**
  39322. * Returns a new AnimationGroup object parsed from the source provided.
  39323. * @param parsedAnimationGroup defines the source
  39324. * @param scene defines the scene that will receive the animationGroup
  39325. * @returns a new AnimationGroup
  39326. */
  39327. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39328. /**
  39329. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39330. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39331. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39332. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39333. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39334. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39335. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39336. */
  39337. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39338. /**
  39339. * Returns the string "AnimationGroup"
  39340. * @returns "AnimationGroup"
  39341. */
  39342. getClassName(): string;
  39343. /**
  39344. * Creates a detailled string about the object
  39345. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39346. * @returns a string representing the object
  39347. */
  39348. toString(fullDetails?: boolean): string;
  39349. }
  39350. }
  39351. declare module BABYLON {
  39352. /**
  39353. * Define an interface for all classes that will hold resources
  39354. */
  39355. export interface IDisposable {
  39356. /**
  39357. * Releases all held resources
  39358. */
  39359. dispose(): void;
  39360. }
  39361. /** Interface defining initialization parameters for Scene class */
  39362. export interface SceneOptions {
  39363. /**
  39364. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39365. * It will improve performance when the number of geometries becomes important.
  39366. */
  39367. useGeometryUniqueIdsMap?: boolean;
  39368. /**
  39369. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39370. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39371. */
  39372. useMaterialMeshMap?: boolean;
  39373. /**
  39374. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39375. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39376. */
  39377. useClonedMeshMap?: boolean;
  39378. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39379. virtual?: boolean;
  39380. }
  39381. /**
  39382. * Represents a scene to be rendered by the engine.
  39383. * @see https://doc.babylonjs.com/features/scene
  39384. */
  39385. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39386. /** The fog is deactivated */
  39387. static readonly FOGMODE_NONE: number;
  39388. /** The fog density is following an exponential function */
  39389. static readonly FOGMODE_EXP: number;
  39390. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39391. static readonly FOGMODE_EXP2: number;
  39392. /** The fog density is following a linear function. */
  39393. static readonly FOGMODE_LINEAR: number;
  39394. /**
  39395. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39396. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39397. */
  39398. static MinDeltaTime: number;
  39399. /**
  39400. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39401. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39402. */
  39403. static MaxDeltaTime: number;
  39404. /**
  39405. * Factory used to create the default material.
  39406. * @param name The name of the material to create
  39407. * @param scene The scene to create the material for
  39408. * @returns The default material
  39409. */
  39410. static DefaultMaterialFactory(scene: Scene): Material;
  39411. /**
  39412. * Factory used to create the a collision coordinator.
  39413. * @returns The collision coordinator
  39414. */
  39415. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39416. /** @hidden */
  39417. _inputManager: InputManager;
  39418. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39419. cameraToUseForPointers: Nullable<Camera>;
  39420. /** @hidden */
  39421. readonly _isScene: boolean;
  39422. /** @hidden */
  39423. _blockEntityCollection: boolean;
  39424. /**
  39425. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39426. */
  39427. autoClear: boolean;
  39428. /**
  39429. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39430. */
  39431. autoClearDepthAndStencil: boolean;
  39432. /**
  39433. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39434. */
  39435. clearColor: Color4;
  39436. /**
  39437. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39438. */
  39439. ambientColor: Color3;
  39440. /**
  39441. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39442. * It should only be one of the following (if not the default embedded one):
  39443. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39444. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39445. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39446. * The material properties need to be setup according to the type of texture in use.
  39447. */
  39448. environmentBRDFTexture: BaseTexture;
  39449. /**
  39450. * Texture used in all pbr material as the reflection texture.
  39451. * As in the majority of the scene they are the same (exception for multi room and so on),
  39452. * this is easier to reference from here than from all the materials.
  39453. */
  39454. get environmentTexture(): Nullable<BaseTexture>;
  39455. /**
  39456. * Texture used in all pbr material as the reflection texture.
  39457. * As in the majority of the scene they are the same (exception for multi room and so on),
  39458. * this is easier to set here than in all the materials.
  39459. */
  39460. set environmentTexture(value: Nullable<BaseTexture>);
  39461. /** @hidden */
  39462. protected _environmentIntensity: number;
  39463. /**
  39464. * Intensity of the environment in all pbr material.
  39465. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39466. * As in the majority of the scene they are the same (exception for multi room and so on),
  39467. * this is easier to reference from here than from all the materials.
  39468. */
  39469. get environmentIntensity(): number;
  39470. /**
  39471. * Intensity of the environment in all pbr material.
  39472. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39473. * As in the majority of the scene they are the same (exception for multi room and so on),
  39474. * this is easier to set here than in all the materials.
  39475. */
  39476. set environmentIntensity(value: number);
  39477. /** @hidden */
  39478. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39479. /**
  39480. * Default image processing configuration used either in the rendering
  39481. * Forward main pass or through the imageProcessingPostProcess if present.
  39482. * As in the majority of the scene they are the same (exception for multi camera),
  39483. * this is easier to reference from here than from all the materials and post process.
  39484. *
  39485. * No setter as we it is a shared configuration, you can set the values instead.
  39486. */
  39487. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39488. private _forceWireframe;
  39489. /**
  39490. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39491. */
  39492. set forceWireframe(value: boolean);
  39493. get forceWireframe(): boolean;
  39494. private _skipFrustumClipping;
  39495. /**
  39496. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39497. */
  39498. set skipFrustumClipping(value: boolean);
  39499. get skipFrustumClipping(): boolean;
  39500. private _forcePointsCloud;
  39501. /**
  39502. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39503. */
  39504. set forcePointsCloud(value: boolean);
  39505. get forcePointsCloud(): boolean;
  39506. /**
  39507. * Gets or sets the active clipplane 1
  39508. */
  39509. clipPlane: Nullable<Plane>;
  39510. /**
  39511. * Gets or sets the active clipplane 2
  39512. */
  39513. clipPlane2: Nullable<Plane>;
  39514. /**
  39515. * Gets or sets the active clipplane 3
  39516. */
  39517. clipPlane3: Nullable<Plane>;
  39518. /**
  39519. * Gets or sets the active clipplane 4
  39520. */
  39521. clipPlane4: Nullable<Plane>;
  39522. /**
  39523. * Gets or sets the active clipplane 5
  39524. */
  39525. clipPlane5: Nullable<Plane>;
  39526. /**
  39527. * Gets or sets the active clipplane 6
  39528. */
  39529. clipPlane6: Nullable<Plane>;
  39530. /**
  39531. * Gets or sets a boolean indicating if animations are enabled
  39532. */
  39533. animationsEnabled: boolean;
  39534. private _animationPropertiesOverride;
  39535. /**
  39536. * Gets or sets the animation properties override
  39537. */
  39538. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39539. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39540. /**
  39541. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39542. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39543. */
  39544. useConstantAnimationDeltaTime: boolean;
  39545. /**
  39546. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39547. * Please note that it requires to run a ray cast through the scene on every frame
  39548. */
  39549. constantlyUpdateMeshUnderPointer: boolean;
  39550. /**
  39551. * Defines the HTML cursor to use when hovering over interactive elements
  39552. */
  39553. hoverCursor: string;
  39554. /**
  39555. * Defines the HTML default cursor to use (empty by default)
  39556. */
  39557. defaultCursor: string;
  39558. /**
  39559. * Defines whether cursors are handled by the scene.
  39560. */
  39561. doNotHandleCursors: boolean;
  39562. /**
  39563. * This is used to call preventDefault() on pointer down
  39564. * in order to block unwanted artifacts like system double clicks
  39565. */
  39566. preventDefaultOnPointerDown: boolean;
  39567. /**
  39568. * This is used to call preventDefault() on pointer up
  39569. * in order to block unwanted artifacts like system double clicks
  39570. */
  39571. preventDefaultOnPointerUp: boolean;
  39572. /**
  39573. * Gets or sets user defined metadata
  39574. */
  39575. metadata: any;
  39576. /**
  39577. * For internal use only. Please do not use.
  39578. */
  39579. reservedDataStore: any;
  39580. /**
  39581. * Gets the name of the plugin used to load this scene (null by default)
  39582. */
  39583. loadingPluginName: string;
  39584. /**
  39585. * Use this array to add regular expressions used to disable offline support for specific urls
  39586. */
  39587. disableOfflineSupportExceptionRules: RegExp[];
  39588. /**
  39589. * An event triggered when the scene is disposed.
  39590. */
  39591. onDisposeObservable: Observable<Scene>;
  39592. private _onDisposeObserver;
  39593. /** Sets a function to be executed when this scene is disposed. */
  39594. set onDispose(callback: () => void);
  39595. /**
  39596. * An event triggered before rendering the scene (right after animations and physics)
  39597. */
  39598. onBeforeRenderObservable: Observable<Scene>;
  39599. private _onBeforeRenderObserver;
  39600. /** Sets a function to be executed before rendering this scene */
  39601. set beforeRender(callback: Nullable<() => void>);
  39602. /**
  39603. * An event triggered after rendering the scene
  39604. */
  39605. onAfterRenderObservable: Observable<Scene>;
  39606. /**
  39607. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39608. */
  39609. onAfterRenderCameraObservable: Observable<Camera>;
  39610. private _onAfterRenderObserver;
  39611. /** Sets a function to be executed after rendering this scene */
  39612. set afterRender(callback: Nullable<() => void>);
  39613. /**
  39614. * An event triggered before animating the scene
  39615. */
  39616. onBeforeAnimationsObservable: Observable<Scene>;
  39617. /**
  39618. * An event triggered after animations processing
  39619. */
  39620. onAfterAnimationsObservable: Observable<Scene>;
  39621. /**
  39622. * An event triggered before draw calls are ready to be sent
  39623. */
  39624. onBeforeDrawPhaseObservable: Observable<Scene>;
  39625. /**
  39626. * An event triggered after draw calls have been sent
  39627. */
  39628. onAfterDrawPhaseObservable: Observable<Scene>;
  39629. /**
  39630. * An event triggered when the scene is ready
  39631. */
  39632. onReadyObservable: Observable<Scene>;
  39633. /**
  39634. * An event triggered before rendering a camera
  39635. */
  39636. onBeforeCameraRenderObservable: Observable<Camera>;
  39637. private _onBeforeCameraRenderObserver;
  39638. /** Sets a function to be executed before rendering a camera*/
  39639. set beforeCameraRender(callback: () => void);
  39640. /**
  39641. * An event triggered after rendering a camera
  39642. */
  39643. onAfterCameraRenderObservable: Observable<Camera>;
  39644. private _onAfterCameraRenderObserver;
  39645. /** Sets a function to be executed after rendering a camera*/
  39646. set afterCameraRender(callback: () => void);
  39647. /**
  39648. * An event triggered when active meshes evaluation is about to start
  39649. */
  39650. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39651. /**
  39652. * An event triggered when active meshes evaluation is done
  39653. */
  39654. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39655. /**
  39656. * An event triggered when particles rendering is about to start
  39657. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39658. */
  39659. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39660. /**
  39661. * An event triggered when particles rendering is done
  39662. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39663. */
  39664. onAfterParticlesRenderingObservable: Observable<Scene>;
  39665. /**
  39666. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39667. */
  39668. onDataLoadedObservable: Observable<Scene>;
  39669. /**
  39670. * An event triggered when a camera is created
  39671. */
  39672. onNewCameraAddedObservable: Observable<Camera>;
  39673. /**
  39674. * An event triggered when a camera is removed
  39675. */
  39676. onCameraRemovedObservable: Observable<Camera>;
  39677. /**
  39678. * An event triggered when a light is created
  39679. */
  39680. onNewLightAddedObservable: Observable<Light>;
  39681. /**
  39682. * An event triggered when a light is removed
  39683. */
  39684. onLightRemovedObservable: Observable<Light>;
  39685. /**
  39686. * An event triggered when a geometry is created
  39687. */
  39688. onNewGeometryAddedObservable: Observable<Geometry>;
  39689. /**
  39690. * An event triggered when a geometry is removed
  39691. */
  39692. onGeometryRemovedObservable: Observable<Geometry>;
  39693. /**
  39694. * An event triggered when a transform node is created
  39695. */
  39696. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39697. /**
  39698. * An event triggered when a transform node is removed
  39699. */
  39700. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39701. /**
  39702. * An event triggered when a mesh is created
  39703. */
  39704. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39705. /**
  39706. * An event triggered when a mesh is removed
  39707. */
  39708. onMeshRemovedObservable: Observable<AbstractMesh>;
  39709. /**
  39710. * An event triggered when a skeleton is created
  39711. */
  39712. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39713. /**
  39714. * An event triggered when a skeleton is removed
  39715. */
  39716. onSkeletonRemovedObservable: Observable<Skeleton>;
  39717. /**
  39718. * An event triggered when a material is created
  39719. */
  39720. onNewMaterialAddedObservable: Observable<Material>;
  39721. /**
  39722. * An event triggered when a material is removed
  39723. */
  39724. onMaterialRemovedObservable: Observable<Material>;
  39725. /**
  39726. * An event triggered when a texture is created
  39727. */
  39728. onNewTextureAddedObservable: Observable<BaseTexture>;
  39729. /**
  39730. * An event triggered when a texture is removed
  39731. */
  39732. onTextureRemovedObservable: Observable<BaseTexture>;
  39733. /**
  39734. * An event triggered when render targets are about to be rendered
  39735. * Can happen multiple times per frame.
  39736. */
  39737. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39738. /**
  39739. * An event triggered when render targets were rendered.
  39740. * Can happen multiple times per frame.
  39741. */
  39742. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39743. /**
  39744. * An event triggered before calculating deterministic simulation step
  39745. */
  39746. onBeforeStepObservable: Observable<Scene>;
  39747. /**
  39748. * An event triggered after calculating deterministic simulation step
  39749. */
  39750. onAfterStepObservable: Observable<Scene>;
  39751. /**
  39752. * An event triggered when the activeCamera property is updated
  39753. */
  39754. onActiveCameraChanged: Observable<Scene>;
  39755. /**
  39756. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39757. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39758. * 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)
  39759. */
  39760. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39761. /**
  39762. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39763. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39764. * 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)
  39765. */
  39766. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39767. /**
  39768. * This Observable will when a mesh has been imported into the scene.
  39769. */
  39770. onMeshImportedObservable: Observable<AbstractMesh>;
  39771. /**
  39772. * This Observable will when an animation file has been imported into the scene.
  39773. */
  39774. onAnimationFileImportedObservable: Observable<Scene>;
  39775. /**
  39776. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39777. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39778. */
  39779. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39780. /** @hidden */
  39781. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39782. /**
  39783. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39784. */
  39785. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39786. /**
  39787. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39788. */
  39789. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39790. /**
  39791. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39792. */
  39793. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39794. /** Callback called when a pointer move is detected */
  39795. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39796. /** Callback called when a pointer down is detected */
  39797. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39798. /** Callback called when a pointer up is detected */
  39799. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39800. /** Callback called when a pointer pick is detected */
  39801. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39802. /**
  39803. * 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).
  39804. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39805. */
  39806. onPrePointerObservable: Observable<PointerInfoPre>;
  39807. /**
  39808. * Observable event triggered each time an input event is received from the rendering canvas
  39809. */
  39810. onPointerObservable: Observable<PointerInfo>;
  39811. /**
  39812. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39813. */
  39814. get unTranslatedPointer(): Vector2;
  39815. /**
  39816. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39817. */
  39818. static get DragMovementThreshold(): number;
  39819. static set DragMovementThreshold(value: number);
  39820. /**
  39821. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39822. */
  39823. static get LongPressDelay(): number;
  39824. static set LongPressDelay(value: number);
  39825. /**
  39826. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39827. */
  39828. static get DoubleClickDelay(): number;
  39829. static set DoubleClickDelay(value: number);
  39830. /** If you need to check double click without raising a single click at first click, enable this flag */
  39831. static get ExclusiveDoubleClickMode(): boolean;
  39832. static set ExclusiveDoubleClickMode(value: boolean);
  39833. /** @hidden */
  39834. _mirroredCameraPosition: Nullable<Vector3>;
  39835. /**
  39836. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39837. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39838. */
  39839. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39840. /**
  39841. * Observable event triggered each time an keyboard event is received from the hosting window
  39842. */
  39843. onKeyboardObservable: Observable<KeyboardInfo>;
  39844. private _useRightHandedSystem;
  39845. /**
  39846. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39847. */
  39848. set useRightHandedSystem(value: boolean);
  39849. get useRightHandedSystem(): boolean;
  39850. private _timeAccumulator;
  39851. private _currentStepId;
  39852. private _currentInternalStep;
  39853. /**
  39854. * Sets the step Id used by deterministic lock step
  39855. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39856. * @param newStepId defines the step Id
  39857. */
  39858. setStepId(newStepId: number): void;
  39859. /**
  39860. * Gets the step Id used by deterministic lock step
  39861. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39862. * @returns the step Id
  39863. */
  39864. getStepId(): number;
  39865. /**
  39866. * Gets the internal step used by deterministic lock step
  39867. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39868. * @returns the internal step
  39869. */
  39870. getInternalStep(): number;
  39871. private _fogEnabled;
  39872. /**
  39873. * Gets or sets a boolean indicating if fog is enabled on this scene
  39874. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39875. * (Default is true)
  39876. */
  39877. set fogEnabled(value: boolean);
  39878. get fogEnabled(): boolean;
  39879. private _fogMode;
  39880. /**
  39881. * Gets or sets the fog mode to use
  39882. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39883. * | mode | value |
  39884. * | --- | --- |
  39885. * | FOGMODE_NONE | 0 |
  39886. * | FOGMODE_EXP | 1 |
  39887. * | FOGMODE_EXP2 | 2 |
  39888. * | FOGMODE_LINEAR | 3 |
  39889. */
  39890. set fogMode(value: number);
  39891. get fogMode(): number;
  39892. /**
  39893. * Gets or sets the fog color to use
  39894. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39895. * (Default is Color3(0.2, 0.2, 0.3))
  39896. */
  39897. fogColor: Color3;
  39898. /**
  39899. * Gets or sets the fog density to use
  39900. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39901. * (Default is 0.1)
  39902. */
  39903. fogDensity: number;
  39904. /**
  39905. * Gets or sets the fog start distance to use
  39906. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39907. * (Default is 0)
  39908. */
  39909. fogStart: number;
  39910. /**
  39911. * Gets or sets the fog end distance to use
  39912. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39913. * (Default is 1000)
  39914. */
  39915. fogEnd: number;
  39916. /**
  39917. * Flag indicating that the frame buffer binding is handled by another component
  39918. */
  39919. prePass: boolean;
  39920. private _shadowsEnabled;
  39921. /**
  39922. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39923. */
  39924. set shadowsEnabled(value: boolean);
  39925. get shadowsEnabled(): boolean;
  39926. private _lightsEnabled;
  39927. /**
  39928. * Gets or sets a boolean indicating if lights are enabled on this scene
  39929. */
  39930. set lightsEnabled(value: boolean);
  39931. get lightsEnabled(): boolean;
  39932. /** All of the active cameras added to this scene. */
  39933. activeCameras: Camera[];
  39934. /** @hidden */
  39935. _activeCamera: Nullable<Camera>;
  39936. /** Gets or sets the current active camera */
  39937. get activeCamera(): Nullable<Camera>;
  39938. set activeCamera(value: Nullable<Camera>);
  39939. private _defaultMaterial;
  39940. /** The default material used on meshes when no material is affected */
  39941. get defaultMaterial(): Material;
  39942. /** The default material used on meshes when no material is affected */
  39943. set defaultMaterial(value: Material);
  39944. private _texturesEnabled;
  39945. /**
  39946. * Gets or sets a boolean indicating if textures are enabled on this scene
  39947. */
  39948. set texturesEnabled(value: boolean);
  39949. get texturesEnabled(): boolean;
  39950. /**
  39951. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39952. */
  39953. physicsEnabled: boolean;
  39954. /**
  39955. * Gets or sets a boolean indicating if particles are enabled on this scene
  39956. */
  39957. particlesEnabled: boolean;
  39958. /**
  39959. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39960. */
  39961. spritesEnabled: boolean;
  39962. private _skeletonsEnabled;
  39963. /**
  39964. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39965. */
  39966. set skeletonsEnabled(value: boolean);
  39967. get skeletonsEnabled(): boolean;
  39968. /**
  39969. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39970. */
  39971. lensFlaresEnabled: boolean;
  39972. /**
  39973. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39974. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39975. */
  39976. collisionsEnabled: boolean;
  39977. private _collisionCoordinator;
  39978. /** @hidden */
  39979. get collisionCoordinator(): ICollisionCoordinator;
  39980. /**
  39981. * Defines the gravity applied to this scene (used only for collisions)
  39982. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39983. */
  39984. gravity: Vector3;
  39985. /**
  39986. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39987. */
  39988. postProcessesEnabled: boolean;
  39989. /**
  39990. * Gets the current postprocess manager
  39991. */
  39992. postProcessManager: PostProcessManager;
  39993. /**
  39994. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39995. */
  39996. renderTargetsEnabled: boolean;
  39997. /**
  39998. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39999. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40000. */
  40001. dumpNextRenderTargets: boolean;
  40002. /**
  40003. * The list of user defined render targets added to the scene
  40004. */
  40005. customRenderTargets: RenderTargetTexture[];
  40006. /**
  40007. * Defines if texture loading must be delayed
  40008. * If true, textures will only be loaded when they need to be rendered
  40009. */
  40010. useDelayedTextureLoading: boolean;
  40011. /**
  40012. * Gets the list of meshes imported to the scene through SceneLoader
  40013. */
  40014. importedMeshesFiles: String[];
  40015. /**
  40016. * Gets or sets a boolean indicating if probes are enabled on this scene
  40017. */
  40018. probesEnabled: boolean;
  40019. /**
  40020. * Gets or sets the current offline provider to use to store scene data
  40021. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40022. */
  40023. offlineProvider: IOfflineProvider;
  40024. /**
  40025. * Gets or sets the action manager associated with the scene
  40026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40027. */
  40028. actionManager: AbstractActionManager;
  40029. private _meshesForIntersections;
  40030. /**
  40031. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40032. */
  40033. proceduralTexturesEnabled: boolean;
  40034. private _engine;
  40035. private _totalVertices;
  40036. /** @hidden */
  40037. _activeIndices: PerfCounter;
  40038. /** @hidden */
  40039. _activeParticles: PerfCounter;
  40040. /** @hidden */
  40041. _activeBones: PerfCounter;
  40042. private _animationRatio;
  40043. /** @hidden */
  40044. _animationTimeLast: number;
  40045. /** @hidden */
  40046. _animationTime: number;
  40047. /**
  40048. * Gets or sets a general scale for animation speed
  40049. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40050. */
  40051. animationTimeScale: number;
  40052. /** @hidden */
  40053. _cachedMaterial: Nullable<Material>;
  40054. /** @hidden */
  40055. _cachedEffect: Nullable<Effect>;
  40056. /** @hidden */
  40057. _cachedVisibility: Nullable<number>;
  40058. private _renderId;
  40059. private _frameId;
  40060. private _executeWhenReadyTimeoutId;
  40061. private _intermediateRendering;
  40062. private _viewUpdateFlag;
  40063. private _projectionUpdateFlag;
  40064. /** @hidden */
  40065. _toBeDisposed: Nullable<IDisposable>[];
  40066. private _activeRequests;
  40067. /** @hidden */
  40068. _pendingData: any[];
  40069. private _isDisposed;
  40070. /**
  40071. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40072. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40073. */
  40074. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40075. private _activeMeshes;
  40076. private _processedMaterials;
  40077. private _renderTargets;
  40078. /** @hidden */
  40079. _activeParticleSystems: SmartArray<IParticleSystem>;
  40080. private _activeSkeletons;
  40081. private _softwareSkinnedMeshes;
  40082. private _renderingManager;
  40083. /** @hidden */
  40084. _activeAnimatables: Animatable[];
  40085. private _transformMatrix;
  40086. private _sceneUbo;
  40087. /** @hidden */
  40088. _viewMatrix: Matrix;
  40089. private _projectionMatrix;
  40090. /** @hidden */
  40091. _forcedViewPosition: Nullable<Vector3>;
  40092. /** @hidden */
  40093. _frustumPlanes: Plane[];
  40094. /**
  40095. * Gets the list of frustum planes (built from the active camera)
  40096. */
  40097. get frustumPlanes(): Plane[];
  40098. /**
  40099. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40100. * This is useful if there are more lights that the maximum simulteanous authorized
  40101. */
  40102. requireLightSorting: boolean;
  40103. /** @hidden */
  40104. readonly useMaterialMeshMap: boolean;
  40105. /** @hidden */
  40106. readonly useClonedMeshMap: boolean;
  40107. private _externalData;
  40108. private _uid;
  40109. /**
  40110. * @hidden
  40111. * Backing store of defined scene components.
  40112. */
  40113. _components: ISceneComponent[];
  40114. /**
  40115. * @hidden
  40116. * Backing store of defined scene components.
  40117. */
  40118. _serializableComponents: ISceneSerializableComponent[];
  40119. /**
  40120. * List of components to register on the next registration step.
  40121. */
  40122. private _transientComponents;
  40123. /**
  40124. * Registers the transient components if needed.
  40125. */
  40126. private _registerTransientComponents;
  40127. /**
  40128. * @hidden
  40129. * Add a component to the scene.
  40130. * Note that the ccomponent could be registered on th next frame if this is called after
  40131. * the register component stage.
  40132. * @param component Defines the component to add to the scene
  40133. */
  40134. _addComponent(component: ISceneComponent): void;
  40135. /**
  40136. * @hidden
  40137. * Gets a component from the scene.
  40138. * @param name defines the name of the component to retrieve
  40139. * @returns the component or null if not present
  40140. */
  40141. _getComponent(name: string): Nullable<ISceneComponent>;
  40142. /**
  40143. * @hidden
  40144. * Defines the actions happening before camera updates.
  40145. */
  40146. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40147. /**
  40148. * @hidden
  40149. * Defines the actions happening before clear the canvas.
  40150. */
  40151. _beforeClearStage: Stage<SimpleStageAction>;
  40152. /**
  40153. * @hidden
  40154. * Defines the actions when collecting render targets for the frame.
  40155. */
  40156. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40157. /**
  40158. * @hidden
  40159. * Defines the actions happening for one camera in the frame.
  40160. */
  40161. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40162. /**
  40163. * @hidden
  40164. * Defines the actions happening during the per mesh ready checks.
  40165. */
  40166. _isReadyForMeshStage: Stage<MeshStageAction>;
  40167. /**
  40168. * @hidden
  40169. * Defines the actions happening before evaluate active mesh checks.
  40170. */
  40171. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40172. /**
  40173. * @hidden
  40174. * Defines the actions happening during the evaluate sub mesh checks.
  40175. */
  40176. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40177. /**
  40178. * @hidden
  40179. * Defines the actions happening during the active mesh stage.
  40180. */
  40181. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40182. /**
  40183. * @hidden
  40184. * Defines the actions happening during the per camera render target step.
  40185. */
  40186. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40187. /**
  40188. * @hidden
  40189. * Defines the actions happening just before the active camera is drawing.
  40190. */
  40191. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40192. /**
  40193. * @hidden
  40194. * Defines the actions happening just before a render target is drawing.
  40195. */
  40196. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40197. /**
  40198. * @hidden
  40199. * Defines the actions happening just before a rendering group is drawing.
  40200. */
  40201. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40202. /**
  40203. * @hidden
  40204. * Defines the actions happening just before a mesh is drawing.
  40205. */
  40206. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40207. /**
  40208. * @hidden
  40209. * Defines the actions happening just after a mesh has been drawn.
  40210. */
  40211. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40212. /**
  40213. * @hidden
  40214. * Defines the actions happening just after a rendering group has been drawn.
  40215. */
  40216. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40217. /**
  40218. * @hidden
  40219. * Defines the actions happening just after the active camera has been drawn.
  40220. */
  40221. _afterCameraDrawStage: Stage<CameraStageAction>;
  40222. /**
  40223. * @hidden
  40224. * Defines the actions happening just after a render target has been drawn.
  40225. */
  40226. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40227. /**
  40228. * @hidden
  40229. * Defines the actions happening just after rendering all cameras and computing intersections.
  40230. */
  40231. _afterRenderStage: Stage<SimpleStageAction>;
  40232. /**
  40233. * @hidden
  40234. * Defines the actions happening when a pointer move event happens.
  40235. */
  40236. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40237. /**
  40238. * @hidden
  40239. * Defines the actions happening when a pointer down event happens.
  40240. */
  40241. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40242. /**
  40243. * @hidden
  40244. * Defines the actions happening when a pointer up event happens.
  40245. */
  40246. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40247. /**
  40248. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40249. */
  40250. private geometriesByUniqueId;
  40251. /**
  40252. * Creates a new Scene
  40253. * @param engine defines the engine to use to render this scene
  40254. * @param options defines the scene options
  40255. */
  40256. constructor(engine: Engine, options?: SceneOptions);
  40257. /**
  40258. * Gets a string identifying the name of the class
  40259. * @returns "Scene" string
  40260. */
  40261. getClassName(): string;
  40262. private _defaultMeshCandidates;
  40263. /**
  40264. * @hidden
  40265. */
  40266. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40267. private _defaultSubMeshCandidates;
  40268. /**
  40269. * @hidden
  40270. */
  40271. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40272. /**
  40273. * Sets the default candidate providers for the scene.
  40274. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40275. * and getCollidingSubMeshCandidates to their default function
  40276. */
  40277. setDefaultCandidateProviders(): void;
  40278. /**
  40279. * Gets the mesh that is currently under the pointer
  40280. */
  40281. get meshUnderPointer(): Nullable<AbstractMesh>;
  40282. /**
  40283. * Gets or sets the current on-screen X position of the pointer
  40284. */
  40285. get pointerX(): number;
  40286. set pointerX(value: number);
  40287. /**
  40288. * Gets or sets the current on-screen Y position of the pointer
  40289. */
  40290. get pointerY(): number;
  40291. set pointerY(value: number);
  40292. /**
  40293. * Gets the cached material (ie. the latest rendered one)
  40294. * @returns the cached material
  40295. */
  40296. getCachedMaterial(): Nullable<Material>;
  40297. /**
  40298. * Gets the cached effect (ie. the latest rendered one)
  40299. * @returns the cached effect
  40300. */
  40301. getCachedEffect(): Nullable<Effect>;
  40302. /**
  40303. * Gets the cached visibility state (ie. the latest rendered one)
  40304. * @returns the cached visibility state
  40305. */
  40306. getCachedVisibility(): Nullable<number>;
  40307. /**
  40308. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40309. * @param material defines the current material
  40310. * @param effect defines the current effect
  40311. * @param visibility defines the current visibility state
  40312. * @returns true if one parameter is not cached
  40313. */
  40314. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40315. /**
  40316. * Gets the engine associated with the scene
  40317. * @returns an Engine
  40318. */
  40319. getEngine(): Engine;
  40320. /**
  40321. * Gets the total number of vertices rendered per frame
  40322. * @returns the total number of vertices rendered per frame
  40323. */
  40324. getTotalVertices(): number;
  40325. /**
  40326. * Gets the performance counter for total vertices
  40327. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40328. */
  40329. get totalVerticesPerfCounter(): PerfCounter;
  40330. /**
  40331. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40332. * @returns the total number of active indices rendered per frame
  40333. */
  40334. getActiveIndices(): number;
  40335. /**
  40336. * Gets the performance counter for active indices
  40337. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40338. */
  40339. get totalActiveIndicesPerfCounter(): PerfCounter;
  40340. /**
  40341. * Gets the total number of active particles rendered per frame
  40342. * @returns the total number of active particles rendered per frame
  40343. */
  40344. getActiveParticles(): number;
  40345. /**
  40346. * Gets the performance counter for active particles
  40347. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40348. */
  40349. get activeParticlesPerfCounter(): PerfCounter;
  40350. /**
  40351. * Gets the total number of active bones rendered per frame
  40352. * @returns the total number of active bones rendered per frame
  40353. */
  40354. getActiveBones(): number;
  40355. /**
  40356. * Gets the performance counter for active bones
  40357. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40358. */
  40359. get activeBonesPerfCounter(): PerfCounter;
  40360. /**
  40361. * Gets the array of active meshes
  40362. * @returns an array of AbstractMesh
  40363. */
  40364. getActiveMeshes(): SmartArray<AbstractMesh>;
  40365. /**
  40366. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40367. * @returns a number
  40368. */
  40369. getAnimationRatio(): number;
  40370. /**
  40371. * Gets an unique Id for the current render phase
  40372. * @returns a number
  40373. */
  40374. getRenderId(): number;
  40375. /**
  40376. * Gets an unique Id for the current frame
  40377. * @returns a number
  40378. */
  40379. getFrameId(): number;
  40380. /** Call this function if you want to manually increment the render Id*/
  40381. incrementRenderId(): void;
  40382. private _createUbo;
  40383. /**
  40384. * Use this method to simulate a pointer move on a mesh
  40385. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40386. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40387. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40388. * @returns the current scene
  40389. */
  40390. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40391. /**
  40392. * Use this method to simulate a pointer down on a mesh
  40393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40396. * @returns the current scene
  40397. */
  40398. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40399. /**
  40400. * Use this method to simulate a pointer up on a mesh
  40401. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40402. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40403. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40404. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40405. * @returns the current scene
  40406. */
  40407. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40408. /**
  40409. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40410. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40411. * @returns true if the pointer was captured
  40412. */
  40413. isPointerCaptured(pointerId?: number): boolean;
  40414. /**
  40415. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40416. * @param attachUp defines if you want to attach events to pointerup
  40417. * @param attachDown defines if you want to attach events to pointerdown
  40418. * @param attachMove defines if you want to attach events to pointermove
  40419. */
  40420. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40421. /** Detaches all event handlers*/
  40422. detachControl(): void;
  40423. /**
  40424. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40425. * Delay loaded resources are not taking in account
  40426. * @return true if all required resources are ready
  40427. */
  40428. isReady(): boolean;
  40429. /** Resets all cached information relative to material (including effect and visibility) */
  40430. resetCachedMaterial(): void;
  40431. /**
  40432. * Registers a function to be called before every frame render
  40433. * @param func defines the function to register
  40434. */
  40435. registerBeforeRender(func: () => void): void;
  40436. /**
  40437. * Unregisters a function called before every frame render
  40438. * @param func defines the function to unregister
  40439. */
  40440. unregisterBeforeRender(func: () => void): void;
  40441. /**
  40442. * Registers a function to be called after every frame render
  40443. * @param func defines the function to register
  40444. */
  40445. registerAfterRender(func: () => void): void;
  40446. /**
  40447. * Unregisters a function called after every frame render
  40448. * @param func defines the function to unregister
  40449. */
  40450. unregisterAfterRender(func: () => void): void;
  40451. private _executeOnceBeforeRender;
  40452. /**
  40453. * The provided function will run before render once and will be disposed afterwards.
  40454. * A timeout delay can be provided so that the function will be executed in N ms.
  40455. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40456. * @param func The function to be executed.
  40457. * @param timeout optional delay in ms
  40458. */
  40459. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40460. /** @hidden */
  40461. _addPendingData(data: any): void;
  40462. /** @hidden */
  40463. _removePendingData(data: any): void;
  40464. /**
  40465. * Returns the number of items waiting to be loaded
  40466. * @returns the number of items waiting to be loaded
  40467. */
  40468. getWaitingItemsCount(): number;
  40469. /**
  40470. * Returns a boolean indicating if the scene is still loading data
  40471. */
  40472. get isLoading(): boolean;
  40473. /**
  40474. * Registers a function to be executed when the scene is ready
  40475. * @param {Function} func - the function to be executed
  40476. */
  40477. executeWhenReady(func: () => void): void;
  40478. /**
  40479. * Returns a promise that resolves when the scene is ready
  40480. * @returns A promise that resolves when the scene is ready
  40481. */
  40482. whenReadyAsync(): Promise<void>;
  40483. /** @hidden */
  40484. _checkIsReady(): void;
  40485. /**
  40486. * Gets all animatable attached to the scene
  40487. */
  40488. get animatables(): Animatable[];
  40489. /**
  40490. * Resets the last animation time frame.
  40491. * Useful to override when animations start running when loading a scene for the first time.
  40492. */
  40493. resetLastAnimationTimeFrame(): void;
  40494. /**
  40495. * Gets the current view matrix
  40496. * @returns a Matrix
  40497. */
  40498. getViewMatrix(): Matrix;
  40499. /**
  40500. * Gets the current projection matrix
  40501. * @returns a Matrix
  40502. */
  40503. getProjectionMatrix(): Matrix;
  40504. /**
  40505. * Gets the current transform matrix
  40506. * @returns a Matrix made of View * Projection
  40507. */
  40508. getTransformMatrix(): Matrix;
  40509. /**
  40510. * Sets the current transform matrix
  40511. * @param viewL defines the View matrix to use
  40512. * @param projectionL defines the Projection matrix to use
  40513. * @param viewR defines the right View matrix to use (if provided)
  40514. * @param projectionR defines the right Projection matrix to use (if provided)
  40515. */
  40516. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40517. /**
  40518. * Gets the uniform buffer used to store scene data
  40519. * @returns a UniformBuffer
  40520. */
  40521. getSceneUniformBuffer(): UniformBuffer;
  40522. /**
  40523. * Gets an unique (relatively to the current scene) Id
  40524. * @returns an unique number for the scene
  40525. */
  40526. getUniqueId(): number;
  40527. /**
  40528. * Add a mesh to the list of scene's meshes
  40529. * @param newMesh defines the mesh to add
  40530. * @param recursive if all child meshes should also be added to the scene
  40531. */
  40532. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40533. /**
  40534. * Remove a mesh for the list of scene's meshes
  40535. * @param toRemove defines the mesh to remove
  40536. * @param recursive if all child meshes should also be removed from the scene
  40537. * @returns the index where the mesh was in the mesh list
  40538. */
  40539. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40540. /**
  40541. * Add a transform node to the list of scene's transform nodes
  40542. * @param newTransformNode defines the transform node to add
  40543. */
  40544. addTransformNode(newTransformNode: TransformNode): void;
  40545. /**
  40546. * Remove a transform node for the list of scene's transform nodes
  40547. * @param toRemove defines the transform node to remove
  40548. * @returns the index where the transform node was in the transform node list
  40549. */
  40550. removeTransformNode(toRemove: TransformNode): number;
  40551. /**
  40552. * Remove a skeleton for the list of scene's skeletons
  40553. * @param toRemove defines the skeleton to remove
  40554. * @returns the index where the skeleton was in the skeleton list
  40555. */
  40556. removeSkeleton(toRemove: Skeleton): number;
  40557. /**
  40558. * Remove a morph target for the list of scene's morph targets
  40559. * @param toRemove defines the morph target to remove
  40560. * @returns the index where the morph target was in the morph target list
  40561. */
  40562. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40563. /**
  40564. * Remove a light for the list of scene's lights
  40565. * @param toRemove defines the light to remove
  40566. * @returns the index where the light was in the light list
  40567. */
  40568. removeLight(toRemove: Light): number;
  40569. /**
  40570. * Remove a camera for the list of scene's cameras
  40571. * @param toRemove defines the camera to remove
  40572. * @returns the index where the camera was in the camera list
  40573. */
  40574. removeCamera(toRemove: Camera): number;
  40575. /**
  40576. * Remove a particle system for the list of scene's particle systems
  40577. * @param toRemove defines the particle system to remove
  40578. * @returns the index where the particle system was in the particle system list
  40579. */
  40580. removeParticleSystem(toRemove: IParticleSystem): number;
  40581. /**
  40582. * Remove a animation for the list of scene's animations
  40583. * @param toRemove defines the animation to remove
  40584. * @returns the index where the animation was in the animation list
  40585. */
  40586. removeAnimation(toRemove: Animation): number;
  40587. /**
  40588. * Will stop the animation of the given target
  40589. * @param target - the target
  40590. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40591. * @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)
  40592. */
  40593. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40594. /**
  40595. * Removes the given animation group from this scene.
  40596. * @param toRemove The animation group to remove
  40597. * @returns The index of the removed animation group
  40598. */
  40599. removeAnimationGroup(toRemove: AnimationGroup): number;
  40600. /**
  40601. * Removes the given multi-material from this scene.
  40602. * @param toRemove The multi-material to remove
  40603. * @returns The index of the removed multi-material
  40604. */
  40605. removeMultiMaterial(toRemove: MultiMaterial): number;
  40606. /**
  40607. * Removes the given material from this scene.
  40608. * @param toRemove The material to remove
  40609. * @returns The index of the removed material
  40610. */
  40611. removeMaterial(toRemove: Material): number;
  40612. /**
  40613. * Removes the given action manager from this scene.
  40614. * @param toRemove The action manager to remove
  40615. * @returns The index of the removed action manager
  40616. */
  40617. removeActionManager(toRemove: AbstractActionManager): number;
  40618. /**
  40619. * Removes the given texture from this scene.
  40620. * @param toRemove The texture to remove
  40621. * @returns The index of the removed texture
  40622. */
  40623. removeTexture(toRemove: BaseTexture): number;
  40624. /**
  40625. * Adds the given light to this scene
  40626. * @param newLight The light to add
  40627. */
  40628. addLight(newLight: Light): void;
  40629. /**
  40630. * Sorts the list list based on light priorities
  40631. */
  40632. sortLightsByPriority(): void;
  40633. /**
  40634. * Adds the given camera to this scene
  40635. * @param newCamera The camera to add
  40636. */
  40637. addCamera(newCamera: Camera): void;
  40638. /**
  40639. * Adds the given skeleton to this scene
  40640. * @param newSkeleton The skeleton to add
  40641. */
  40642. addSkeleton(newSkeleton: Skeleton): void;
  40643. /**
  40644. * Adds the given particle system to this scene
  40645. * @param newParticleSystem The particle system to add
  40646. */
  40647. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40648. /**
  40649. * Adds the given animation to this scene
  40650. * @param newAnimation The animation to add
  40651. */
  40652. addAnimation(newAnimation: Animation): void;
  40653. /**
  40654. * Adds the given animation group to this scene.
  40655. * @param newAnimationGroup The animation group to add
  40656. */
  40657. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40658. /**
  40659. * Adds the given multi-material to this scene
  40660. * @param newMultiMaterial The multi-material to add
  40661. */
  40662. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40663. /**
  40664. * Adds the given material to this scene
  40665. * @param newMaterial The material to add
  40666. */
  40667. addMaterial(newMaterial: Material): void;
  40668. /**
  40669. * Adds the given morph target to this scene
  40670. * @param newMorphTargetManager The morph target to add
  40671. */
  40672. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40673. /**
  40674. * Adds the given geometry to this scene
  40675. * @param newGeometry The geometry to add
  40676. */
  40677. addGeometry(newGeometry: Geometry): void;
  40678. /**
  40679. * Adds the given action manager to this scene
  40680. * @param newActionManager The action manager to add
  40681. */
  40682. addActionManager(newActionManager: AbstractActionManager): void;
  40683. /**
  40684. * Adds the given texture to this scene.
  40685. * @param newTexture The texture to add
  40686. */
  40687. addTexture(newTexture: BaseTexture): void;
  40688. /**
  40689. * Switch active camera
  40690. * @param newCamera defines the new active camera
  40691. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40692. */
  40693. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40694. /**
  40695. * sets the active camera of the scene using its ID
  40696. * @param id defines the camera's ID
  40697. * @return the new active camera or null if none found.
  40698. */
  40699. setActiveCameraByID(id: string): Nullable<Camera>;
  40700. /**
  40701. * sets the active camera of the scene using its name
  40702. * @param name defines the camera's name
  40703. * @returns the new active camera or null if none found.
  40704. */
  40705. setActiveCameraByName(name: string): Nullable<Camera>;
  40706. /**
  40707. * get an animation group using its name
  40708. * @param name defines the material's name
  40709. * @return the animation group or null if none found.
  40710. */
  40711. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40712. /**
  40713. * Get a material using its unique id
  40714. * @param uniqueId defines the material's unique id
  40715. * @return the material or null if none found.
  40716. */
  40717. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40718. /**
  40719. * get a material using its id
  40720. * @param id defines the material's ID
  40721. * @return the material or null if none found.
  40722. */
  40723. getMaterialByID(id: string): Nullable<Material>;
  40724. /**
  40725. * Gets a the last added material using a given id
  40726. * @param id defines the material's ID
  40727. * @return the last material with the given id or null if none found.
  40728. */
  40729. getLastMaterialByID(id: string): Nullable<Material>;
  40730. /**
  40731. * Gets a material using its name
  40732. * @param name defines the material's name
  40733. * @return the material or null if none found.
  40734. */
  40735. getMaterialByName(name: string): Nullable<Material>;
  40736. /**
  40737. * Get a texture using its unique id
  40738. * @param uniqueId defines the texture's unique id
  40739. * @return the texture or null if none found.
  40740. */
  40741. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40742. /**
  40743. * Gets a camera using its id
  40744. * @param id defines the id to look for
  40745. * @returns the camera or null if not found
  40746. */
  40747. getCameraByID(id: string): Nullable<Camera>;
  40748. /**
  40749. * Gets a camera using its unique id
  40750. * @param uniqueId defines the unique id to look for
  40751. * @returns the camera or null if not found
  40752. */
  40753. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40754. /**
  40755. * Gets a camera using its name
  40756. * @param name defines the camera's name
  40757. * @return the camera or null if none found.
  40758. */
  40759. getCameraByName(name: string): Nullable<Camera>;
  40760. /**
  40761. * Gets a bone using its id
  40762. * @param id defines the bone's id
  40763. * @return the bone or null if not found
  40764. */
  40765. getBoneByID(id: string): Nullable<Bone>;
  40766. /**
  40767. * Gets a bone using its id
  40768. * @param name defines the bone's name
  40769. * @return the bone or null if not found
  40770. */
  40771. getBoneByName(name: string): Nullable<Bone>;
  40772. /**
  40773. * Gets a light node using its name
  40774. * @param name defines the the light's name
  40775. * @return the light or null if none found.
  40776. */
  40777. getLightByName(name: string): Nullable<Light>;
  40778. /**
  40779. * Gets a light node using its id
  40780. * @param id defines the light's id
  40781. * @return the light or null if none found.
  40782. */
  40783. getLightByID(id: string): Nullable<Light>;
  40784. /**
  40785. * Gets a light node using its scene-generated unique ID
  40786. * @param uniqueId defines the light's unique id
  40787. * @return the light or null if none found.
  40788. */
  40789. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40790. /**
  40791. * Gets a particle system by id
  40792. * @param id defines the particle system id
  40793. * @return the corresponding system or null if none found
  40794. */
  40795. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40796. /**
  40797. * Gets a geometry using its ID
  40798. * @param id defines the geometry's id
  40799. * @return the geometry or null if none found.
  40800. */
  40801. getGeometryByID(id: string): Nullable<Geometry>;
  40802. private _getGeometryByUniqueID;
  40803. /**
  40804. * Add a new geometry to this scene
  40805. * @param geometry defines the geometry to be added to the scene.
  40806. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40807. * @return a boolean defining if the geometry was added or not
  40808. */
  40809. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40810. /**
  40811. * Removes an existing geometry
  40812. * @param geometry defines the geometry to be removed from the scene
  40813. * @return a boolean defining if the geometry was removed or not
  40814. */
  40815. removeGeometry(geometry: Geometry): boolean;
  40816. /**
  40817. * Gets the list of geometries attached to the scene
  40818. * @returns an array of Geometry
  40819. */
  40820. getGeometries(): Geometry[];
  40821. /**
  40822. * Gets the first added mesh found of a given ID
  40823. * @param id defines the id to search for
  40824. * @return the mesh found or null if not found at all
  40825. */
  40826. getMeshByID(id: string): Nullable<AbstractMesh>;
  40827. /**
  40828. * Gets a list of meshes using their id
  40829. * @param id defines the id to search for
  40830. * @returns a list of meshes
  40831. */
  40832. getMeshesByID(id: string): Array<AbstractMesh>;
  40833. /**
  40834. * Gets the first added transform node found of a given ID
  40835. * @param id defines the id to search for
  40836. * @return the found transform node or null if not found at all.
  40837. */
  40838. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40839. /**
  40840. * Gets a transform node with its auto-generated unique id
  40841. * @param uniqueId efines the unique id to search for
  40842. * @return the found transform node or null if not found at all.
  40843. */
  40844. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40845. /**
  40846. * Gets a list of transform nodes using their id
  40847. * @param id defines the id to search for
  40848. * @returns a list of transform nodes
  40849. */
  40850. getTransformNodesByID(id: string): Array<TransformNode>;
  40851. /**
  40852. * Gets a mesh with its auto-generated unique id
  40853. * @param uniqueId defines the unique id to search for
  40854. * @return the found mesh or null if not found at all.
  40855. */
  40856. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40857. /**
  40858. * Gets a the last added mesh using a given id
  40859. * @param id defines the id to search for
  40860. * @return the found mesh or null if not found at all.
  40861. */
  40862. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40863. /**
  40864. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40865. * @param id defines the id to search for
  40866. * @return the found node or null if not found at all
  40867. */
  40868. getLastEntryByID(id: string): Nullable<Node>;
  40869. /**
  40870. * Gets a node (Mesh, Camera, Light) using a given id
  40871. * @param id defines the id to search for
  40872. * @return the found node or null if not found at all
  40873. */
  40874. getNodeByID(id: string): Nullable<Node>;
  40875. /**
  40876. * Gets a node (Mesh, Camera, Light) using a given name
  40877. * @param name defines the name to search for
  40878. * @return the found node or null if not found at all.
  40879. */
  40880. getNodeByName(name: string): Nullable<Node>;
  40881. /**
  40882. * Gets a mesh using a given name
  40883. * @param name defines the name to search for
  40884. * @return the found mesh or null if not found at all.
  40885. */
  40886. getMeshByName(name: string): Nullable<AbstractMesh>;
  40887. /**
  40888. * Gets a transform node using a given name
  40889. * @param name defines the name to search for
  40890. * @return the found transform node or null if not found at all.
  40891. */
  40892. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40893. /**
  40894. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40895. * @param id defines the id to search for
  40896. * @return the found skeleton or null if not found at all.
  40897. */
  40898. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40899. /**
  40900. * Gets a skeleton using a given auto generated unique id
  40901. * @param uniqueId defines the unique id to search for
  40902. * @return the found skeleton or null if not found at all.
  40903. */
  40904. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40905. /**
  40906. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40907. * @param id defines the id to search for
  40908. * @return the found skeleton or null if not found at all.
  40909. */
  40910. getSkeletonById(id: string): Nullable<Skeleton>;
  40911. /**
  40912. * Gets a skeleton using a given name
  40913. * @param name defines the name to search for
  40914. * @return the found skeleton or null if not found at all.
  40915. */
  40916. getSkeletonByName(name: string): Nullable<Skeleton>;
  40917. /**
  40918. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40919. * @param id defines the id to search for
  40920. * @return the found morph target manager or null if not found at all.
  40921. */
  40922. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40923. /**
  40924. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40925. * @param id defines the id to search for
  40926. * @return the found morph target or null if not found at all.
  40927. */
  40928. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40929. /**
  40930. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40931. * @param name defines the name to search for
  40932. * @return the found morph target or null if not found at all.
  40933. */
  40934. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40935. /**
  40936. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40937. * @param name defines the name to search for
  40938. * @return the found post process or null if not found at all.
  40939. */
  40940. getPostProcessByName(name: string): Nullable<PostProcess>;
  40941. /**
  40942. * Gets a boolean indicating if the given mesh is active
  40943. * @param mesh defines the mesh to look for
  40944. * @returns true if the mesh is in the active list
  40945. */
  40946. isActiveMesh(mesh: AbstractMesh): boolean;
  40947. /**
  40948. * Return a unique id as a string which can serve as an identifier for the scene
  40949. */
  40950. get uid(): string;
  40951. /**
  40952. * Add an externaly attached data from its key.
  40953. * This method call will fail and return false, if such key already exists.
  40954. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40955. * @param key the unique key that identifies the data
  40956. * @param data the data object to associate to the key for this Engine instance
  40957. * @return true if no such key were already present and the data was added successfully, false otherwise
  40958. */
  40959. addExternalData<T>(key: string, data: T): boolean;
  40960. /**
  40961. * Get an externaly attached data from its key
  40962. * @param key the unique key that identifies the data
  40963. * @return the associated data, if present (can be null), or undefined if not present
  40964. */
  40965. getExternalData<T>(key: string): Nullable<T>;
  40966. /**
  40967. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40968. * @param key the unique key that identifies the data
  40969. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40970. * @return the associated data, can be null if the factory returned null.
  40971. */
  40972. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40973. /**
  40974. * Remove an externaly attached data from the Engine instance
  40975. * @param key the unique key that identifies the data
  40976. * @return true if the data was successfully removed, false if it doesn't exist
  40977. */
  40978. removeExternalData(key: string): boolean;
  40979. private _evaluateSubMesh;
  40980. /**
  40981. * Clear the processed materials smart array preventing retention point in material dispose.
  40982. */
  40983. freeProcessedMaterials(): void;
  40984. private _preventFreeActiveMeshesAndRenderingGroups;
  40985. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40986. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40987. * when disposing several meshes in a row or a hierarchy of meshes.
  40988. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40989. */
  40990. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40991. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40992. /**
  40993. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40994. */
  40995. freeActiveMeshes(): void;
  40996. /**
  40997. * Clear the info related to rendering groups preventing retention points during dispose.
  40998. */
  40999. freeRenderingGroups(): void;
  41000. /** @hidden */
  41001. _isInIntermediateRendering(): boolean;
  41002. /**
  41003. * Lambda returning the list of potentially active meshes.
  41004. */
  41005. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41006. /**
  41007. * Lambda returning the list of potentially active sub meshes.
  41008. */
  41009. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41010. /**
  41011. * Lambda returning the list of potentially intersecting sub meshes.
  41012. */
  41013. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41014. /**
  41015. * Lambda returning the list of potentially colliding sub meshes.
  41016. */
  41017. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41018. private _activeMeshesFrozen;
  41019. private _skipEvaluateActiveMeshesCompletely;
  41020. /**
  41021. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41022. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41023. * @returns the current scene
  41024. */
  41025. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41026. /**
  41027. * Use this function to restart evaluating active meshes on every frame
  41028. * @returns the current scene
  41029. */
  41030. unfreezeActiveMeshes(): Scene;
  41031. private _evaluateActiveMeshes;
  41032. private _activeMesh;
  41033. /**
  41034. * Update the transform matrix to update from the current active camera
  41035. * @param force defines a boolean used to force the update even if cache is up to date
  41036. */
  41037. updateTransformMatrix(force?: boolean): void;
  41038. private _bindFrameBuffer;
  41039. /** @hidden */
  41040. _allowPostProcessClearColor: boolean;
  41041. /** @hidden */
  41042. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41043. private _processSubCameras;
  41044. private _checkIntersections;
  41045. /** @hidden */
  41046. _advancePhysicsEngineStep(step: number): void;
  41047. /**
  41048. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41049. */
  41050. getDeterministicFrameTime: () => number;
  41051. /** @hidden */
  41052. _animate(): void;
  41053. /** Execute all animations (for a frame) */
  41054. animate(): void;
  41055. /**
  41056. * Render the scene
  41057. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41058. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41059. */
  41060. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41061. /**
  41062. * Freeze all materials
  41063. * A frozen material will not be updatable but should be faster to render
  41064. */
  41065. freezeMaterials(): void;
  41066. /**
  41067. * Unfreeze all materials
  41068. * A frozen material will not be updatable but should be faster to render
  41069. */
  41070. unfreezeMaterials(): void;
  41071. /**
  41072. * Releases all held ressources
  41073. */
  41074. dispose(): void;
  41075. /**
  41076. * Gets if the scene is already disposed
  41077. */
  41078. get isDisposed(): boolean;
  41079. /**
  41080. * Call this function to reduce memory footprint of the scene.
  41081. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41082. */
  41083. clearCachedVertexData(): void;
  41084. /**
  41085. * This function will remove the local cached buffer data from texture.
  41086. * It will save memory but will prevent the texture from being rebuilt
  41087. */
  41088. cleanCachedTextureBuffer(): void;
  41089. /**
  41090. * Get the world extend vectors with an optional filter
  41091. *
  41092. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41093. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41094. */
  41095. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41096. min: Vector3;
  41097. max: Vector3;
  41098. };
  41099. /**
  41100. * Creates a ray that can be used to pick in the scene
  41101. * @param x defines the x coordinate of the origin (on-screen)
  41102. * @param y defines the y coordinate of the origin (on-screen)
  41103. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41104. * @param camera defines the camera to use for the picking
  41105. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41106. * @returns a Ray
  41107. */
  41108. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41109. /**
  41110. * Creates a ray that can be used to pick in the scene
  41111. * @param x defines the x coordinate of the origin (on-screen)
  41112. * @param y defines the y coordinate of the origin (on-screen)
  41113. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41114. * @param result defines the ray where to store the picking ray
  41115. * @param camera defines the camera to use for the picking
  41116. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41117. * @returns the current scene
  41118. */
  41119. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41120. /**
  41121. * Creates a ray that can be used to pick in the scene
  41122. * @param x defines the x coordinate of the origin (on-screen)
  41123. * @param y defines the y coordinate of the origin (on-screen)
  41124. * @param camera defines the camera to use for the picking
  41125. * @returns a Ray
  41126. */
  41127. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41128. /**
  41129. * Creates a ray that can be used to pick in the scene
  41130. * @param x defines the x coordinate of the origin (on-screen)
  41131. * @param y defines the y coordinate of the origin (on-screen)
  41132. * @param result defines the ray where to store the picking ray
  41133. * @param camera defines the camera to use for the picking
  41134. * @returns the current scene
  41135. */
  41136. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41137. /** Launch a ray to try to pick a mesh in the scene
  41138. * @param x position on screen
  41139. * @param y position on screen
  41140. * @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
  41141. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41142. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41143. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41144. * @returns a PickingInfo
  41145. */
  41146. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41147. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41148. * @param x position on screen
  41149. * @param y position on screen
  41150. * @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
  41151. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41152. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41153. * @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)
  41154. */
  41155. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41156. /** Use the given ray to pick a mesh in the scene
  41157. * @param ray The ray to use to pick meshes
  41158. * @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
  41159. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41160. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41161. * @returns a PickingInfo
  41162. */
  41163. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41164. /**
  41165. * Launch a ray to try to pick a mesh in the scene
  41166. * @param x X position on screen
  41167. * @param y Y position on screen
  41168. * @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
  41169. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41170. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41171. * @returns an array of PickingInfo
  41172. */
  41173. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41174. /**
  41175. * Launch a ray to try to pick a mesh in the scene
  41176. * @param ray Ray to use
  41177. * @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
  41178. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41179. * @returns an array of PickingInfo
  41180. */
  41181. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41182. /**
  41183. * Force the value of meshUnderPointer
  41184. * @param mesh defines the mesh to use
  41185. * @param pointerId optional pointer id when using more than one pointer
  41186. */
  41187. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41188. /**
  41189. * Gets the mesh under the pointer
  41190. * @returns a Mesh or null if no mesh is under the pointer
  41191. */
  41192. getPointerOverMesh(): Nullable<AbstractMesh>;
  41193. /** @hidden */
  41194. _rebuildGeometries(): void;
  41195. /** @hidden */
  41196. _rebuildTextures(): void;
  41197. private _getByTags;
  41198. /**
  41199. * Get a list of meshes by tags
  41200. * @param tagsQuery defines the tags query to use
  41201. * @param forEach defines a predicate used to filter results
  41202. * @returns an array of Mesh
  41203. */
  41204. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41205. /**
  41206. * Get a list of cameras by tags
  41207. * @param tagsQuery defines the tags query to use
  41208. * @param forEach defines a predicate used to filter results
  41209. * @returns an array of Camera
  41210. */
  41211. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41212. /**
  41213. * Get a list of lights by tags
  41214. * @param tagsQuery defines the tags query to use
  41215. * @param forEach defines a predicate used to filter results
  41216. * @returns an array of Light
  41217. */
  41218. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41219. /**
  41220. * Get a list of materials by tags
  41221. * @param tagsQuery defines the tags query to use
  41222. * @param forEach defines a predicate used to filter results
  41223. * @returns an array of Material
  41224. */
  41225. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41226. /**
  41227. * Get a list of transform nodes by tags
  41228. * @param tagsQuery defines the tags query to use
  41229. * @param forEach defines a predicate used to filter results
  41230. * @returns an array of TransformNode
  41231. */
  41232. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41233. /**
  41234. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41235. * This allowed control for front to back rendering or reversly depending of the special needs.
  41236. *
  41237. * @param renderingGroupId The rendering group id corresponding to its index
  41238. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41239. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41240. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41241. */
  41242. 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;
  41243. /**
  41244. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41245. *
  41246. * @param renderingGroupId The rendering group id corresponding to its index
  41247. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41248. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41249. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41250. */
  41251. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41252. /**
  41253. * Gets the current auto clear configuration for one rendering group of the rendering
  41254. * manager.
  41255. * @param index the rendering group index to get the information for
  41256. * @returns The auto clear setup for the requested rendering group
  41257. */
  41258. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41259. private _blockMaterialDirtyMechanism;
  41260. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41261. get blockMaterialDirtyMechanism(): boolean;
  41262. set blockMaterialDirtyMechanism(value: boolean);
  41263. /**
  41264. * Will flag all materials as dirty to trigger new shader compilation
  41265. * @param flag defines the flag used to specify which material part must be marked as dirty
  41266. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41267. */
  41268. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41269. /** @hidden */
  41270. _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;
  41271. /** @hidden */
  41272. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41273. /** @hidden */
  41274. _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;
  41275. /** @hidden */
  41276. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41277. /** @hidden */
  41278. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41279. /** @hidden */
  41280. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41281. }
  41282. }
  41283. declare module BABYLON {
  41284. /**
  41285. * Set of assets to keep when moving a scene into an asset container.
  41286. */
  41287. export class KeepAssets extends AbstractScene {
  41288. }
  41289. /**
  41290. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41291. */
  41292. export class InstantiatedEntries {
  41293. /**
  41294. * List of new root nodes (eg. nodes with no parent)
  41295. */
  41296. rootNodes: TransformNode[];
  41297. /**
  41298. * List of new skeletons
  41299. */
  41300. skeletons: Skeleton[];
  41301. /**
  41302. * List of new animation groups
  41303. */
  41304. animationGroups: AnimationGroup[];
  41305. }
  41306. /**
  41307. * Container with a set of assets that can be added or removed from a scene.
  41308. */
  41309. export class AssetContainer extends AbstractScene {
  41310. private _wasAddedToScene;
  41311. /**
  41312. * The scene the AssetContainer belongs to.
  41313. */
  41314. scene: Scene;
  41315. /**
  41316. * Instantiates an AssetContainer.
  41317. * @param scene The scene the AssetContainer belongs to.
  41318. */
  41319. constructor(scene: Scene);
  41320. /**
  41321. * Instantiate or clone all meshes and add the new ones to the scene.
  41322. * Skeletons and animation groups will all be cloned
  41323. * @param nameFunction defines an optional function used to get new names for clones
  41324. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41325. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41326. */
  41327. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41328. /**
  41329. * Adds all the assets from the container to the scene.
  41330. */
  41331. addAllToScene(): void;
  41332. /**
  41333. * Removes all the assets in the container from the scene
  41334. */
  41335. removeAllFromScene(): void;
  41336. /**
  41337. * Disposes all the assets in the container
  41338. */
  41339. dispose(): void;
  41340. private _moveAssets;
  41341. /**
  41342. * Removes all the assets contained in the scene and adds them to the container.
  41343. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41344. */
  41345. moveAllFromScene(keepAssets?: KeepAssets): void;
  41346. /**
  41347. * 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.
  41348. * @returns the root mesh
  41349. */
  41350. createRootMesh(): Mesh;
  41351. /**
  41352. * Merge animations (direct and animation groups) from this asset container into a scene
  41353. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41354. * @param animatables set of animatables to retarget to a node from the scene
  41355. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41356. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41357. */
  41358. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41359. }
  41360. }
  41361. declare module BABYLON {
  41362. /**
  41363. * Defines how the parser contract is defined.
  41364. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41365. */
  41366. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41367. /**
  41368. * Defines how the individual parser contract is defined.
  41369. * These parser can parse an individual asset
  41370. */
  41371. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41372. /**
  41373. * Base class of the scene acting as a container for the different elements composing a scene.
  41374. * This class is dynamically extended by the different components of the scene increasing
  41375. * flexibility and reducing coupling
  41376. */
  41377. export abstract class AbstractScene {
  41378. /**
  41379. * Stores the list of available parsers in the application.
  41380. */
  41381. private static _BabylonFileParsers;
  41382. /**
  41383. * Stores the list of available individual parsers in the application.
  41384. */
  41385. private static _IndividualBabylonFileParsers;
  41386. /**
  41387. * Adds a parser in the list of available ones
  41388. * @param name Defines the name of the parser
  41389. * @param parser Defines the parser to add
  41390. */
  41391. static AddParser(name: string, parser: BabylonFileParser): void;
  41392. /**
  41393. * Gets a general parser from the list of avaialble ones
  41394. * @param name Defines the name of the parser
  41395. * @returns the requested parser or null
  41396. */
  41397. static GetParser(name: string): Nullable<BabylonFileParser>;
  41398. /**
  41399. * Adds n individual parser in the list of available ones
  41400. * @param name Defines the name of the parser
  41401. * @param parser Defines the parser to add
  41402. */
  41403. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41404. /**
  41405. * Gets an individual parser from the list of avaialble ones
  41406. * @param name Defines the name of the parser
  41407. * @returns the requested parser or null
  41408. */
  41409. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41410. /**
  41411. * Parser json data and populate both a scene and its associated container object
  41412. * @param jsonData Defines the data to parse
  41413. * @param scene Defines the scene to parse the data for
  41414. * @param container Defines the container attached to the parsing sequence
  41415. * @param rootUrl Defines the root url of the data
  41416. */
  41417. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41418. /**
  41419. * Gets the list of root nodes (ie. nodes with no parent)
  41420. */
  41421. rootNodes: Node[];
  41422. /** All of the cameras added to this scene
  41423. * @see https://doc.babylonjs.com/babylon101/cameras
  41424. */
  41425. cameras: Camera[];
  41426. /**
  41427. * All of the lights added to this scene
  41428. * @see https://doc.babylonjs.com/babylon101/lights
  41429. */
  41430. lights: Light[];
  41431. /**
  41432. * All of the (abstract) meshes added to this scene
  41433. */
  41434. meshes: AbstractMesh[];
  41435. /**
  41436. * The list of skeletons added to the scene
  41437. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41438. */
  41439. skeletons: Skeleton[];
  41440. /**
  41441. * All of the particle systems added to this scene
  41442. * @see https://doc.babylonjs.com/babylon101/particles
  41443. */
  41444. particleSystems: IParticleSystem[];
  41445. /**
  41446. * Gets a list of Animations associated with the scene
  41447. */
  41448. animations: Animation[];
  41449. /**
  41450. * All of the animation groups added to this scene
  41451. * @see https://doc.babylonjs.com/how_to/group
  41452. */
  41453. animationGroups: AnimationGroup[];
  41454. /**
  41455. * All of the multi-materials added to this scene
  41456. * @see https://doc.babylonjs.com/how_to/multi_materials
  41457. */
  41458. multiMaterials: MultiMaterial[];
  41459. /**
  41460. * All of the materials added to this scene
  41461. * In the context of a Scene, it is not supposed to be modified manually.
  41462. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41463. * Note also that the order of the Material within the array is not significant and might change.
  41464. * @see https://doc.babylonjs.com/babylon101/materials
  41465. */
  41466. materials: Material[];
  41467. /**
  41468. * The list of morph target managers added to the scene
  41469. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41470. */
  41471. morphTargetManagers: MorphTargetManager[];
  41472. /**
  41473. * The list of geometries used in the scene.
  41474. */
  41475. geometries: Geometry[];
  41476. /**
  41477. * All of the tranform nodes added to this scene
  41478. * In the context of a Scene, it is not supposed to be modified manually.
  41479. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41480. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41481. * @see https://doc.babylonjs.com/how_to/transformnode
  41482. */
  41483. transformNodes: TransformNode[];
  41484. /**
  41485. * ActionManagers available on the scene.
  41486. */
  41487. actionManagers: AbstractActionManager[];
  41488. /**
  41489. * Textures to keep.
  41490. */
  41491. textures: BaseTexture[];
  41492. /** @hidden */
  41493. protected _environmentTexture: Nullable<BaseTexture>;
  41494. /**
  41495. * Texture used in all pbr material as the reflection texture.
  41496. * As in the majority of the scene they are the same (exception for multi room and so on),
  41497. * this is easier to reference from here than from all the materials.
  41498. */
  41499. get environmentTexture(): Nullable<BaseTexture>;
  41500. set environmentTexture(value: Nullable<BaseTexture>);
  41501. /**
  41502. * The list of postprocesses added to the scene
  41503. */
  41504. postProcesses: PostProcess[];
  41505. /**
  41506. * @returns all meshes, lights, cameras, transformNodes and bones
  41507. */
  41508. getNodes(): Array<Node>;
  41509. }
  41510. }
  41511. declare module BABYLON {
  41512. /**
  41513. * Interface used to define options for Sound class
  41514. */
  41515. export interface ISoundOptions {
  41516. /**
  41517. * Does the sound autoplay once loaded.
  41518. */
  41519. autoplay?: boolean;
  41520. /**
  41521. * Does the sound loop after it finishes playing once.
  41522. */
  41523. loop?: boolean;
  41524. /**
  41525. * Sound's volume
  41526. */
  41527. volume?: number;
  41528. /**
  41529. * Is it a spatial sound?
  41530. */
  41531. spatialSound?: boolean;
  41532. /**
  41533. * Maximum distance to hear that sound
  41534. */
  41535. maxDistance?: number;
  41536. /**
  41537. * Uses user defined attenuation function
  41538. */
  41539. useCustomAttenuation?: boolean;
  41540. /**
  41541. * Define the roll off factor of spatial sounds.
  41542. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41543. */
  41544. rolloffFactor?: number;
  41545. /**
  41546. * Define the reference distance the sound should be heard perfectly.
  41547. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41548. */
  41549. refDistance?: number;
  41550. /**
  41551. * Define the distance attenuation model the sound will follow.
  41552. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41553. */
  41554. distanceModel?: string;
  41555. /**
  41556. * Defines the playback speed (1 by default)
  41557. */
  41558. playbackRate?: number;
  41559. /**
  41560. * Defines if the sound is from a streaming source
  41561. */
  41562. streaming?: boolean;
  41563. /**
  41564. * Defines an optional length (in seconds) inside the sound file
  41565. */
  41566. length?: number;
  41567. /**
  41568. * Defines an optional offset (in seconds) inside the sound file
  41569. */
  41570. offset?: number;
  41571. /**
  41572. * If true, URLs will not be required to state the audio file codec to use.
  41573. */
  41574. skipCodecCheck?: boolean;
  41575. }
  41576. /**
  41577. * Defines a sound that can be played in the application.
  41578. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41579. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41580. */
  41581. export class Sound {
  41582. /**
  41583. * The name of the sound in the scene.
  41584. */
  41585. name: string;
  41586. /**
  41587. * Does the sound autoplay once loaded.
  41588. */
  41589. autoplay: boolean;
  41590. /**
  41591. * Does the sound loop after it finishes playing once.
  41592. */
  41593. loop: boolean;
  41594. /**
  41595. * Does the sound use a custom attenuation curve to simulate the falloff
  41596. * happening when the source gets further away from the camera.
  41597. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41598. */
  41599. useCustomAttenuation: boolean;
  41600. /**
  41601. * The sound track id this sound belongs to.
  41602. */
  41603. soundTrackId: number;
  41604. /**
  41605. * Is this sound currently played.
  41606. */
  41607. isPlaying: boolean;
  41608. /**
  41609. * Is this sound currently paused.
  41610. */
  41611. isPaused: boolean;
  41612. /**
  41613. * Does this sound enables spatial sound.
  41614. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41615. */
  41616. spatialSound: boolean;
  41617. /**
  41618. * Define the reference distance the sound should be heard perfectly.
  41619. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41620. */
  41621. refDistance: number;
  41622. /**
  41623. * Define the roll off factor of spatial sounds.
  41624. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41625. */
  41626. rolloffFactor: number;
  41627. /**
  41628. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41629. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41630. */
  41631. maxDistance: number;
  41632. /**
  41633. * Define the distance attenuation model the sound will follow.
  41634. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41635. */
  41636. distanceModel: string;
  41637. /**
  41638. * @hidden
  41639. * Back Compat
  41640. **/
  41641. onended: () => any;
  41642. /**
  41643. * Gets or sets an object used to store user defined information for the sound.
  41644. */
  41645. metadata: any;
  41646. /**
  41647. * Observable event when the current playing sound finishes.
  41648. */
  41649. onEndedObservable: Observable<Sound>;
  41650. private _panningModel;
  41651. private _playbackRate;
  41652. private _streaming;
  41653. private _startTime;
  41654. private _startOffset;
  41655. private _position;
  41656. /** @hidden */
  41657. _positionInEmitterSpace: boolean;
  41658. private _localDirection;
  41659. private _volume;
  41660. private _isReadyToPlay;
  41661. private _isDirectional;
  41662. private _readyToPlayCallback;
  41663. private _audioBuffer;
  41664. private _soundSource;
  41665. private _streamingSource;
  41666. private _soundPanner;
  41667. private _soundGain;
  41668. private _inputAudioNode;
  41669. private _outputAudioNode;
  41670. private _coneInnerAngle;
  41671. private _coneOuterAngle;
  41672. private _coneOuterGain;
  41673. private _scene;
  41674. private _connectedTransformNode;
  41675. private _customAttenuationFunction;
  41676. private _registerFunc;
  41677. private _isOutputConnected;
  41678. private _htmlAudioElement;
  41679. private _urlType;
  41680. private _length?;
  41681. private _offset?;
  41682. /** @hidden */
  41683. static _SceneComponentInitialization: (scene: Scene) => void;
  41684. /**
  41685. * Create a sound and attach it to a scene
  41686. * @param name Name of your sound
  41687. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41688. * @param scene defines the scene the sound belongs to
  41689. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41690. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41691. */
  41692. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41693. /**
  41694. * Release the sound and its associated resources
  41695. */
  41696. dispose(): void;
  41697. /**
  41698. * Gets if the sounds is ready to be played or not.
  41699. * @returns true if ready, otherwise false
  41700. */
  41701. isReady(): boolean;
  41702. private _soundLoaded;
  41703. /**
  41704. * Sets the data of the sound from an audiobuffer
  41705. * @param audioBuffer The audioBuffer containing the data
  41706. */
  41707. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41708. /**
  41709. * Updates the current sounds options such as maxdistance, loop...
  41710. * @param options A JSON object containing values named as the object properties
  41711. */
  41712. updateOptions(options: ISoundOptions): void;
  41713. private _createSpatialParameters;
  41714. private _updateSpatialParameters;
  41715. /**
  41716. * Switch the panning model to HRTF:
  41717. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41718. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41719. */
  41720. switchPanningModelToHRTF(): void;
  41721. /**
  41722. * Switch the panning model to Equal Power:
  41723. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41724. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41725. */
  41726. switchPanningModelToEqualPower(): void;
  41727. private _switchPanningModel;
  41728. /**
  41729. * Connect this sound to a sound track audio node like gain...
  41730. * @param soundTrackAudioNode the sound track audio node to connect to
  41731. */
  41732. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41733. /**
  41734. * Transform this sound into a directional source
  41735. * @param coneInnerAngle Size of the inner cone in degree
  41736. * @param coneOuterAngle Size of the outer cone in degree
  41737. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41738. */
  41739. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41740. /**
  41741. * Gets or sets the inner angle for the directional cone.
  41742. */
  41743. get directionalConeInnerAngle(): number;
  41744. /**
  41745. * Gets or sets the inner angle for the directional cone.
  41746. */
  41747. set directionalConeInnerAngle(value: number);
  41748. /**
  41749. * Gets or sets the outer angle for the directional cone.
  41750. */
  41751. get directionalConeOuterAngle(): number;
  41752. /**
  41753. * Gets or sets the outer angle for the directional cone.
  41754. */
  41755. set directionalConeOuterAngle(value: number);
  41756. /**
  41757. * Sets the position of the emitter if spatial sound is enabled
  41758. * @param newPosition Defines the new posisiton
  41759. */
  41760. setPosition(newPosition: Vector3): void;
  41761. /**
  41762. * Sets the local direction of the emitter if spatial sound is enabled
  41763. * @param newLocalDirection Defines the new local direction
  41764. */
  41765. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41766. private _updateDirection;
  41767. /** @hidden */
  41768. updateDistanceFromListener(): void;
  41769. /**
  41770. * Sets a new custom attenuation function for the sound.
  41771. * @param callback Defines the function used for the attenuation
  41772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41773. */
  41774. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41775. /**
  41776. * Play the sound
  41777. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41778. * @param offset (optional) Start the sound at a specific time in seconds
  41779. * @param length (optional) Sound duration (in seconds)
  41780. */
  41781. play(time?: number, offset?: number, length?: number): void;
  41782. private _onended;
  41783. /**
  41784. * Stop the sound
  41785. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41786. */
  41787. stop(time?: number): void;
  41788. /**
  41789. * Put the sound in pause
  41790. */
  41791. pause(): void;
  41792. /**
  41793. * Sets a dedicated volume for this sounds
  41794. * @param newVolume Define the new volume of the sound
  41795. * @param time Define time for gradual change to new volume
  41796. */
  41797. setVolume(newVolume: number, time?: number): void;
  41798. /**
  41799. * Set the sound play back rate
  41800. * @param newPlaybackRate Define the playback rate the sound should be played at
  41801. */
  41802. setPlaybackRate(newPlaybackRate: number): void;
  41803. /**
  41804. * Gets the volume of the sound.
  41805. * @returns the volume of the sound
  41806. */
  41807. getVolume(): number;
  41808. /**
  41809. * Attach the sound to a dedicated mesh
  41810. * @param transformNode The transform node to connect the sound with
  41811. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41812. */
  41813. attachToMesh(transformNode: TransformNode): void;
  41814. /**
  41815. * Detach the sound from the previously attached mesh
  41816. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41817. */
  41818. detachFromMesh(): void;
  41819. private _onRegisterAfterWorldMatrixUpdate;
  41820. /**
  41821. * Clone the current sound in the scene.
  41822. * @returns the new sound clone
  41823. */
  41824. clone(): Nullable<Sound>;
  41825. /**
  41826. * Gets the current underlying audio buffer containing the data
  41827. * @returns the audio buffer
  41828. */
  41829. getAudioBuffer(): Nullable<AudioBuffer>;
  41830. /**
  41831. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41832. * @returns the source node
  41833. */
  41834. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41835. /**
  41836. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41837. * @returns the gain node
  41838. */
  41839. getSoundGain(): Nullable<GainNode>;
  41840. /**
  41841. * Serializes the Sound in a JSON representation
  41842. * @returns the JSON representation of the sound
  41843. */
  41844. serialize(): any;
  41845. /**
  41846. * Parse a JSON representation of a sound to innstantiate in a given scene
  41847. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41848. * @param scene Define the scene the new parsed sound should be created in
  41849. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41850. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41851. * @returns the newly parsed sound
  41852. */
  41853. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41854. }
  41855. }
  41856. declare module BABYLON {
  41857. /**
  41858. * This defines an action helpful to play a defined sound on a triggered action.
  41859. */
  41860. export class PlaySoundAction extends Action {
  41861. private _sound;
  41862. /**
  41863. * Instantiate the action
  41864. * @param triggerOptions defines the trigger options
  41865. * @param sound defines the sound to play
  41866. * @param condition defines the trigger related conditions
  41867. */
  41868. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41869. /** @hidden */
  41870. _prepare(): void;
  41871. /**
  41872. * Execute the action and play the sound.
  41873. */
  41874. execute(): void;
  41875. /**
  41876. * Serializes the actions and its related information.
  41877. * @param parent defines the object to serialize in
  41878. * @returns the serialized object
  41879. */
  41880. serialize(parent: any): any;
  41881. }
  41882. /**
  41883. * This defines an action helpful to stop a defined sound on a triggered action.
  41884. */
  41885. export class StopSoundAction extends Action {
  41886. private _sound;
  41887. /**
  41888. * Instantiate the action
  41889. * @param triggerOptions defines the trigger options
  41890. * @param sound defines the sound to stop
  41891. * @param condition defines the trigger related conditions
  41892. */
  41893. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41894. /** @hidden */
  41895. _prepare(): void;
  41896. /**
  41897. * Execute the action and stop the sound.
  41898. */
  41899. execute(): void;
  41900. /**
  41901. * Serializes the actions and its related information.
  41902. * @param parent defines the object to serialize in
  41903. * @returns the serialized object
  41904. */
  41905. serialize(parent: any): any;
  41906. }
  41907. }
  41908. declare module BABYLON {
  41909. /**
  41910. * This defines an action responsible to change the value of a property
  41911. * by interpolating between its current value and the newly set one once triggered.
  41912. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41913. */
  41914. export class InterpolateValueAction extends Action {
  41915. /**
  41916. * Defines the path of the property where the value should be interpolated
  41917. */
  41918. propertyPath: string;
  41919. /**
  41920. * Defines the target value at the end of the interpolation.
  41921. */
  41922. value: any;
  41923. /**
  41924. * Defines the time it will take for the property to interpolate to the value.
  41925. */
  41926. duration: number;
  41927. /**
  41928. * Defines if the other scene animations should be stopped when the action has been triggered
  41929. */
  41930. stopOtherAnimations?: boolean;
  41931. /**
  41932. * Defines a callback raised once the interpolation animation has been done.
  41933. */
  41934. onInterpolationDone?: () => void;
  41935. /**
  41936. * Observable triggered once the interpolation animation has been done.
  41937. */
  41938. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41939. private _target;
  41940. private _effectiveTarget;
  41941. private _property;
  41942. /**
  41943. * Instantiate the action
  41944. * @param triggerOptions defines the trigger options
  41945. * @param target defines the object containing the value to interpolate
  41946. * @param propertyPath defines the path to the property in the target object
  41947. * @param value defines the target value at the end of the interpolation
  41948. * @param duration deines the time it will take for the property to interpolate to the value.
  41949. * @param condition defines the trigger related conditions
  41950. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41951. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41952. */
  41953. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41954. /** @hidden */
  41955. _prepare(): void;
  41956. /**
  41957. * Execute the action starts the value interpolation.
  41958. */
  41959. execute(): void;
  41960. /**
  41961. * Serializes the actions and its related information.
  41962. * @param parent defines the object to serialize in
  41963. * @returns the serialized object
  41964. */
  41965. serialize(parent: any): any;
  41966. }
  41967. }
  41968. declare module BABYLON {
  41969. /**
  41970. * Options allowed during the creation of a sound track.
  41971. */
  41972. export interface ISoundTrackOptions {
  41973. /**
  41974. * The volume the sound track should take during creation
  41975. */
  41976. volume?: number;
  41977. /**
  41978. * Define if the sound track is the main sound track of the scene
  41979. */
  41980. mainTrack?: boolean;
  41981. }
  41982. /**
  41983. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41984. * It will be also used in a future release to apply effects on a specific track.
  41985. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41986. */
  41987. export class SoundTrack {
  41988. /**
  41989. * The unique identifier of the sound track in the scene.
  41990. */
  41991. id: number;
  41992. /**
  41993. * The list of sounds included in the sound track.
  41994. */
  41995. soundCollection: Array<Sound>;
  41996. private _outputAudioNode;
  41997. private _scene;
  41998. private _connectedAnalyser;
  41999. private _options;
  42000. private _isInitialized;
  42001. /**
  42002. * Creates a new sound track.
  42003. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42004. * @param scene Define the scene the sound track belongs to
  42005. * @param options
  42006. */
  42007. constructor(scene: Scene, options?: ISoundTrackOptions);
  42008. private _initializeSoundTrackAudioGraph;
  42009. /**
  42010. * Release the sound track and its associated resources
  42011. */
  42012. dispose(): void;
  42013. /**
  42014. * Adds a sound to this sound track
  42015. * @param sound define the cound to add
  42016. * @ignoreNaming
  42017. */
  42018. AddSound(sound: Sound): void;
  42019. /**
  42020. * Removes a sound to this sound track
  42021. * @param sound define the cound to remove
  42022. * @ignoreNaming
  42023. */
  42024. RemoveSound(sound: Sound): void;
  42025. /**
  42026. * Set a global volume for the full sound track.
  42027. * @param newVolume Define the new volume of the sound track
  42028. */
  42029. setVolume(newVolume: number): void;
  42030. /**
  42031. * Switch the panning model to HRTF:
  42032. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42033. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42034. */
  42035. switchPanningModelToHRTF(): void;
  42036. /**
  42037. * Switch the panning model to Equal Power:
  42038. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42039. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42040. */
  42041. switchPanningModelToEqualPower(): void;
  42042. /**
  42043. * Connect the sound track to an audio analyser allowing some amazing
  42044. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42045. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42046. * @param analyser The analyser to connect to the engine
  42047. */
  42048. connectToAnalyser(analyser: Analyser): void;
  42049. }
  42050. }
  42051. declare module BABYLON {
  42052. interface AbstractScene {
  42053. /**
  42054. * The list of sounds used in the scene.
  42055. */
  42056. sounds: Nullable<Array<Sound>>;
  42057. }
  42058. interface Scene {
  42059. /**
  42060. * @hidden
  42061. * Backing field
  42062. */
  42063. _mainSoundTrack: SoundTrack;
  42064. /**
  42065. * The main sound track played by the scene.
  42066. * It cotains your primary collection of sounds.
  42067. */
  42068. mainSoundTrack: SoundTrack;
  42069. /**
  42070. * The list of sound tracks added to the scene
  42071. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42072. */
  42073. soundTracks: Nullable<Array<SoundTrack>>;
  42074. /**
  42075. * Gets a sound using a given name
  42076. * @param name defines the name to search for
  42077. * @return the found sound or null if not found at all.
  42078. */
  42079. getSoundByName(name: string): Nullable<Sound>;
  42080. /**
  42081. * Gets or sets if audio support is enabled
  42082. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42083. */
  42084. audioEnabled: boolean;
  42085. /**
  42086. * Gets or sets if audio will be output to headphones
  42087. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42088. */
  42089. headphone: boolean;
  42090. /**
  42091. * Gets or sets custom audio listener position provider
  42092. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42093. */
  42094. audioListenerPositionProvider: Nullable<() => Vector3>;
  42095. /**
  42096. * Gets or sets a refresh rate when using 3D audio positioning
  42097. */
  42098. audioPositioningRefreshRate: number;
  42099. }
  42100. /**
  42101. * Defines the sound scene component responsible to manage any sounds
  42102. * in a given scene.
  42103. */
  42104. export class AudioSceneComponent implements ISceneSerializableComponent {
  42105. private static _CameraDirectionLH;
  42106. private static _CameraDirectionRH;
  42107. /**
  42108. * The component name helpfull to identify the component in the list of scene components.
  42109. */
  42110. readonly name: string;
  42111. /**
  42112. * The scene the component belongs to.
  42113. */
  42114. scene: Scene;
  42115. private _audioEnabled;
  42116. /**
  42117. * Gets whether audio is enabled or not.
  42118. * Please use related enable/disable method to switch state.
  42119. */
  42120. get audioEnabled(): boolean;
  42121. private _headphone;
  42122. /**
  42123. * Gets whether audio is outputing to headphone or not.
  42124. * Please use the according Switch methods to change output.
  42125. */
  42126. get headphone(): boolean;
  42127. /**
  42128. * Gets or sets a refresh rate when using 3D audio positioning
  42129. */
  42130. audioPositioningRefreshRate: number;
  42131. private _audioListenerPositionProvider;
  42132. /**
  42133. * Gets the current audio listener position provider
  42134. */
  42135. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42136. /**
  42137. * Sets a custom listener position for all sounds in the scene
  42138. * By default, this is the position of the first active camera
  42139. */
  42140. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42141. /**
  42142. * Creates a new instance of the component for the given scene
  42143. * @param scene Defines the scene to register the component in
  42144. */
  42145. constructor(scene: Scene);
  42146. /**
  42147. * Registers the component in a given scene
  42148. */
  42149. register(): void;
  42150. /**
  42151. * Rebuilds the elements related to this component in case of
  42152. * context lost for instance.
  42153. */
  42154. rebuild(): void;
  42155. /**
  42156. * Serializes the component data to the specified json object
  42157. * @param serializationObject The object to serialize to
  42158. */
  42159. serialize(serializationObject: any): void;
  42160. /**
  42161. * Adds all the elements from the container to the scene
  42162. * @param container the container holding the elements
  42163. */
  42164. addFromContainer(container: AbstractScene): void;
  42165. /**
  42166. * Removes all the elements in the container from the scene
  42167. * @param container contains the elements to remove
  42168. * @param dispose if the removed element should be disposed (default: false)
  42169. */
  42170. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42171. /**
  42172. * Disposes the component and the associated ressources.
  42173. */
  42174. dispose(): void;
  42175. /**
  42176. * Disables audio in the associated scene.
  42177. */
  42178. disableAudio(): void;
  42179. /**
  42180. * Enables audio in the associated scene.
  42181. */
  42182. enableAudio(): void;
  42183. /**
  42184. * Switch audio to headphone output.
  42185. */
  42186. switchAudioModeForHeadphones(): void;
  42187. /**
  42188. * Switch audio to normal speakers.
  42189. */
  42190. switchAudioModeForNormalSpeakers(): void;
  42191. private _cachedCameraDirection;
  42192. private _cachedCameraPosition;
  42193. private _lastCheck;
  42194. private _afterRender;
  42195. }
  42196. }
  42197. declare module BABYLON {
  42198. /**
  42199. * Wraps one or more Sound objects and selects one with random weight for playback.
  42200. */
  42201. export class WeightedSound {
  42202. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42203. loop: boolean;
  42204. private _coneInnerAngle;
  42205. private _coneOuterAngle;
  42206. private _volume;
  42207. /** A Sound is currently playing. */
  42208. isPlaying: boolean;
  42209. /** A Sound is currently paused. */
  42210. isPaused: boolean;
  42211. private _sounds;
  42212. private _weights;
  42213. private _currentIndex?;
  42214. /**
  42215. * Creates a new WeightedSound from the list of sounds given.
  42216. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42217. * @param sounds Array of Sounds that will be selected from.
  42218. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42219. */
  42220. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42221. /**
  42222. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42223. */
  42224. get directionalConeInnerAngle(): number;
  42225. /**
  42226. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42227. */
  42228. set directionalConeInnerAngle(value: number);
  42229. /**
  42230. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42231. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42232. */
  42233. get directionalConeOuterAngle(): number;
  42234. /**
  42235. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42236. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42237. */
  42238. set directionalConeOuterAngle(value: number);
  42239. /**
  42240. * Playback volume.
  42241. */
  42242. get volume(): number;
  42243. /**
  42244. * Playback volume.
  42245. */
  42246. set volume(value: number);
  42247. private _onended;
  42248. /**
  42249. * Suspend playback
  42250. */
  42251. pause(): void;
  42252. /**
  42253. * Stop playback
  42254. */
  42255. stop(): void;
  42256. /**
  42257. * Start playback.
  42258. * @param startOffset Position the clip head at a specific time in seconds.
  42259. */
  42260. play(startOffset?: number): void;
  42261. }
  42262. }
  42263. declare module BABYLON {
  42264. /**
  42265. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42266. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42267. */
  42268. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42269. /**
  42270. * Gets the name of the behavior.
  42271. */
  42272. get name(): string;
  42273. /**
  42274. * The easing function used by animations
  42275. */
  42276. static EasingFunction: BackEase;
  42277. /**
  42278. * The easing mode used by animations
  42279. */
  42280. static EasingMode: number;
  42281. /**
  42282. * The duration of the animation, in milliseconds
  42283. */
  42284. transitionDuration: number;
  42285. /**
  42286. * Length of the distance animated by the transition when lower radius is reached
  42287. */
  42288. lowerRadiusTransitionRange: number;
  42289. /**
  42290. * Length of the distance animated by the transition when upper radius is reached
  42291. */
  42292. upperRadiusTransitionRange: number;
  42293. private _autoTransitionRange;
  42294. /**
  42295. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42296. */
  42297. get autoTransitionRange(): boolean;
  42298. /**
  42299. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42300. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42301. */
  42302. set autoTransitionRange(value: boolean);
  42303. private _attachedCamera;
  42304. private _onAfterCheckInputsObserver;
  42305. private _onMeshTargetChangedObserver;
  42306. /**
  42307. * Initializes the behavior.
  42308. */
  42309. init(): void;
  42310. /**
  42311. * Attaches the behavior to its arc rotate camera.
  42312. * @param camera Defines the camera to attach the behavior to
  42313. */
  42314. attach(camera: ArcRotateCamera): void;
  42315. /**
  42316. * Detaches the behavior from its current arc rotate camera.
  42317. */
  42318. detach(): void;
  42319. private _radiusIsAnimating;
  42320. private _radiusBounceTransition;
  42321. private _animatables;
  42322. private _cachedWheelPrecision;
  42323. /**
  42324. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42325. * @param radiusLimit The limit to check against.
  42326. * @return Bool to indicate if at limit.
  42327. */
  42328. private _isRadiusAtLimit;
  42329. /**
  42330. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42331. * @param radiusDelta The delta by which to animate to. Can be negative.
  42332. */
  42333. private _applyBoundRadiusAnimation;
  42334. /**
  42335. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42336. */
  42337. protected _clearAnimationLocks(): void;
  42338. /**
  42339. * Stops and removes all animations that have been applied to the camera
  42340. */
  42341. stopAllAnimations(): void;
  42342. }
  42343. }
  42344. declare module BABYLON {
  42345. /**
  42346. * 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.
  42347. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42348. */
  42349. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42350. /**
  42351. * Gets the name of the behavior.
  42352. */
  42353. get name(): string;
  42354. private _mode;
  42355. private _radiusScale;
  42356. private _positionScale;
  42357. private _defaultElevation;
  42358. private _elevationReturnTime;
  42359. private _elevationReturnWaitTime;
  42360. private _zoomStopsAnimation;
  42361. private _framingTime;
  42362. /**
  42363. * The easing function used by animations
  42364. */
  42365. static EasingFunction: ExponentialEase;
  42366. /**
  42367. * The easing mode used by animations
  42368. */
  42369. static EasingMode: number;
  42370. /**
  42371. * Sets the current mode used by the behavior
  42372. */
  42373. set mode(mode: number);
  42374. /**
  42375. * Gets current mode used by the behavior.
  42376. */
  42377. get mode(): number;
  42378. /**
  42379. * Sets the scale applied to the radius (1 by default)
  42380. */
  42381. set radiusScale(radius: number);
  42382. /**
  42383. * Gets the scale applied to the radius
  42384. */
  42385. get radiusScale(): number;
  42386. /**
  42387. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42388. */
  42389. set positionScale(scale: number);
  42390. /**
  42391. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42392. */
  42393. get positionScale(): number;
  42394. /**
  42395. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42396. * behaviour is triggered, in radians.
  42397. */
  42398. set defaultElevation(elevation: number);
  42399. /**
  42400. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42401. * behaviour is triggered, in radians.
  42402. */
  42403. get defaultElevation(): number;
  42404. /**
  42405. * Sets the time (in milliseconds) taken to return to the default beta position.
  42406. * Negative value indicates camera should not return to default.
  42407. */
  42408. set elevationReturnTime(speed: number);
  42409. /**
  42410. * Gets the time (in milliseconds) taken to return to the default beta position.
  42411. * Negative value indicates camera should not return to default.
  42412. */
  42413. get elevationReturnTime(): number;
  42414. /**
  42415. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42416. */
  42417. set elevationReturnWaitTime(time: number);
  42418. /**
  42419. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42420. */
  42421. get elevationReturnWaitTime(): number;
  42422. /**
  42423. * Sets the flag that indicates if user zooming should stop animation.
  42424. */
  42425. set zoomStopsAnimation(flag: boolean);
  42426. /**
  42427. * Gets the flag that indicates if user zooming should stop animation.
  42428. */
  42429. get zoomStopsAnimation(): boolean;
  42430. /**
  42431. * Sets the transition time when framing the mesh, in milliseconds
  42432. */
  42433. set framingTime(time: number);
  42434. /**
  42435. * Gets the transition time when framing the mesh, in milliseconds
  42436. */
  42437. get framingTime(): number;
  42438. /**
  42439. * Define if the behavior should automatically change the configured
  42440. * camera limits and sensibilities.
  42441. */
  42442. autoCorrectCameraLimitsAndSensibility: boolean;
  42443. private _onPrePointerObservableObserver;
  42444. private _onAfterCheckInputsObserver;
  42445. private _onMeshTargetChangedObserver;
  42446. private _attachedCamera;
  42447. private _isPointerDown;
  42448. private _lastInteractionTime;
  42449. /**
  42450. * Initializes the behavior.
  42451. */
  42452. init(): void;
  42453. /**
  42454. * Attaches the behavior to its arc rotate camera.
  42455. * @param camera Defines the camera to attach the behavior to
  42456. */
  42457. attach(camera: ArcRotateCamera): void;
  42458. /**
  42459. * Detaches the behavior from its current arc rotate camera.
  42460. */
  42461. detach(): void;
  42462. private _animatables;
  42463. private _betaIsAnimating;
  42464. private _betaTransition;
  42465. private _radiusTransition;
  42466. private _vectorTransition;
  42467. /**
  42468. * Targets the given mesh and updates zoom level accordingly.
  42469. * @param mesh The mesh to target.
  42470. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42471. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42472. */
  42473. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42474. /**
  42475. * Targets the given mesh with its children and updates zoom level accordingly.
  42476. * @param mesh The mesh to target.
  42477. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42478. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42479. */
  42480. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42481. /**
  42482. * Targets the given meshes with their children and updates zoom level accordingly.
  42483. * @param meshes The mesh to target.
  42484. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42485. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42486. */
  42487. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42488. /**
  42489. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42490. * @param minimumWorld Determines the smaller position of the bounding box extend
  42491. * @param maximumWorld Determines the bigger position of the bounding box extend
  42492. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42493. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42494. */
  42495. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42496. /**
  42497. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42498. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42499. * frustum width.
  42500. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42501. * to fully enclose the mesh in the viewing frustum.
  42502. */
  42503. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42504. /**
  42505. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42506. * is automatically returned to its default position (expected to be above ground plane).
  42507. */
  42508. private _maintainCameraAboveGround;
  42509. /**
  42510. * Returns the frustum slope based on the canvas ratio and camera FOV
  42511. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42512. */
  42513. private _getFrustumSlope;
  42514. /**
  42515. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42516. */
  42517. private _clearAnimationLocks;
  42518. /**
  42519. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42520. */
  42521. private _applyUserInteraction;
  42522. /**
  42523. * Stops and removes all animations that have been applied to the camera
  42524. */
  42525. stopAllAnimations(): void;
  42526. /**
  42527. * Gets a value indicating if the user is moving the camera
  42528. */
  42529. get isUserIsMoving(): boolean;
  42530. /**
  42531. * The camera can move all the way towards the mesh.
  42532. */
  42533. static IgnoreBoundsSizeMode: number;
  42534. /**
  42535. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42536. */
  42537. static FitFrustumSidesMode: number;
  42538. }
  42539. }
  42540. declare module BABYLON {
  42541. /**
  42542. * Base class for Camera Pointer Inputs.
  42543. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42544. * for example usage.
  42545. */
  42546. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42547. /**
  42548. * Defines the camera the input is attached to.
  42549. */
  42550. abstract camera: Camera;
  42551. /**
  42552. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42553. */
  42554. protected _altKey: boolean;
  42555. protected _ctrlKey: boolean;
  42556. protected _metaKey: boolean;
  42557. protected _shiftKey: boolean;
  42558. /**
  42559. * Which mouse buttons were pressed at time of last mouse event.
  42560. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42561. */
  42562. protected _buttonsPressed: number;
  42563. /**
  42564. * Defines the buttons associated with the input to handle camera move.
  42565. */
  42566. buttons: number[];
  42567. /**
  42568. * Attach the input controls to a specific dom element to get the input from.
  42569. * @param element Defines the element the controls should be listened from
  42570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42571. */
  42572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42573. /**
  42574. * Detach the current controls from the specified dom element.
  42575. * @param element Defines the element to stop listening the inputs from
  42576. */
  42577. detachControl(element: Nullable<HTMLElement>): void;
  42578. /**
  42579. * Gets the class name of the current input.
  42580. * @returns the class name
  42581. */
  42582. getClassName(): string;
  42583. /**
  42584. * Get the friendly name associated with the input class.
  42585. * @returns the input friendly name
  42586. */
  42587. getSimpleName(): string;
  42588. /**
  42589. * Called on pointer POINTERDOUBLETAP event.
  42590. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42591. */
  42592. protected onDoubleTap(type: string): void;
  42593. /**
  42594. * Called on pointer POINTERMOVE event if only a single touch is active.
  42595. * Override this method to provide functionality.
  42596. */
  42597. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42598. /**
  42599. * Called on pointer POINTERMOVE event if multiple touches are active.
  42600. * Override this method to provide functionality.
  42601. */
  42602. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42603. /**
  42604. * Called on JS contextmenu event.
  42605. * Override this method to provide functionality.
  42606. */
  42607. protected onContextMenu(evt: PointerEvent): void;
  42608. /**
  42609. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42610. * press.
  42611. * Override this method to provide functionality.
  42612. */
  42613. protected onButtonDown(evt: PointerEvent): void;
  42614. /**
  42615. * Called each time a new POINTERUP event occurs. Ie, for each button
  42616. * release.
  42617. * Override this method to provide functionality.
  42618. */
  42619. protected onButtonUp(evt: PointerEvent): void;
  42620. /**
  42621. * Called when window becomes inactive.
  42622. * Override this method to provide functionality.
  42623. */
  42624. protected onLostFocus(): void;
  42625. private _pointerInput;
  42626. private _observer;
  42627. private _onLostFocus;
  42628. private pointA;
  42629. private pointB;
  42630. }
  42631. }
  42632. declare module BABYLON {
  42633. /**
  42634. * Manage the pointers inputs to control an arc rotate camera.
  42635. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42636. */
  42637. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42638. /**
  42639. * Defines the camera the input is attached to.
  42640. */
  42641. camera: ArcRotateCamera;
  42642. /**
  42643. * Gets the class name of the current input.
  42644. * @returns the class name
  42645. */
  42646. getClassName(): string;
  42647. /**
  42648. * Defines the buttons associated with the input to handle camera move.
  42649. */
  42650. buttons: number[];
  42651. /**
  42652. * Defines the pointer angular sensibility along the X axis or how fast is
  42653. * the camera rotating.
  42654. */
  42655. angularSensibilityX: number;
  42656. /**
  42657. * Defines the pointer angular sensibility along the Y axis or how fast is
  42658. * the camera rotating.
  42659. */
  42660. angularSensibilityY: number;
  42661. /**
  42662. * Defines the pointer pinch precision or how fast is the camera zooming.
  42663. */
  42664. pinchPrecision: number;
  42665. /**
  42666. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42667. * from 0.
  42668. * It defines the percentage of current camera.radius to use as delta when
  42669. * pinch zoom is used.
  42670. */
  42671. pinchDeltaPercentage: number;
  42672. /**
  42673. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42674. * that any object in the plane at the camera's target point will scale
  42675. * perfectly with finger motion.
  42676. * Overrides pinchDeltaPercentage and pinchPrecision.
  42677. */
  42678. useNaturalPinchZoom: boolean;
  42679. /**
  42680. * Defines the pointer panning sensibility or how fast is the camera moving.
  42681. */
  42682. panningSensibility: number;
  42683. /**
  42684. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42685. */
  42686. multiTouchPanning: boolean;
  42687. /**
  42688. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42689. * zoom (pinch) through multitouch.
  42690. */
  42691. multiTouchPanAndZoom: boolean;
  42692. /**
  42693. * Revers pinch action direction.
  42694. */
  42695. pinchInwards: boolean;
  42696. private _isPanClick;
  42697. private _twoFingerActivityCount;
  42698. private _isPinching;
  42699. /**
  42700. * Called on pointer POINTERMOVE event if only a single touch is active.
  42701. */
  42702. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42703. /**
  42704. * Called on pointer POINTERDOUBLETAP event.
  42705. */
  42706. protected onDoubleTap(type: string): void;
  42707. /**
  42708. * Called on pointer POINTERMOVE event if multiple touches are active.
  42709. */
  42710. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42711. /**
  42712. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42713. * press.
  42714. */
  42715. protected onButtonDown(evt: PointerEvent): void;
  42716. /**
  42717. * Called each time a new POINTERUP event occurs. Ie, for each button
  42718. * release.
  42719. */
  42720. protected onButtonUp(evt: PointerEvent): void;
  42721. /**
  42722. * Called when window becomes inactive.
  42723. */
  42724. protected onLostFocus(): void;
  42725. }
  42726. }
  42727. declare module BABYLON {
  42728. /**
  42729. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42730. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42731. */
  42732. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42733. /**
  42734. * Defines the camera the input is attached to.
  42735. */
  42736. camera: ArcRotateCamera;
  42737. /**
  42738. * Defines the list of key codes associated with the up action (increase alpha)
  42739. */
  42740. keysUp: number[];
  42741. /**
  42742. * Defines the list of key codes associated with the down action (decrease alpha)
  42743. */
  42744. keysDown: number[];
  42745. /**
  42746. * Defines the list of key codes associated with the left action (increase beta)
  42747. */
  42748. keysLeft: number[];
  42749. /**
  42750. * Defines the list of key codes associated with the right action (decrease beta)
  42751. */
  42752. keysRight: number[];
  42753. /**
  42754. * Defines the list of key codes associated with the reset action.
  42755. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42756. */
  42757. keysReset: number[];
  42758. /**
  42759. * Defines the panning sensibility of the inputs.
  42760. * (How fast is the camera panning)
  42761. */
  42762. panningSensibility: number;
  42763. /**
  42764. * Defines the zooming sensibility of the inputs.
  42765. * (How fast is the camera zooming)
  42766. */
  42767. zoomingSensibility: number;
  42768. /**
  42769. * Defines whether maintaining the alt key down switch the movement mode from
  42770. * orientation to zoom.
  42771. */
  42772. useAltToZoom: boolean;
  42773. /**
  42774. * Rotation speed of the camera
  42775. */
  42776. angularSpeed: number;
  42777. private _keys;
  42778. private _ctrlPressed;
  42779. private _altPressed;
  42780. private _onCanvasBlurObserver;
  42781. private _onKeyboardObserver;
  42782. private _engine;
  42783. private _scene;
  42784. /**
  42785. * Attach the input controls to a specific dom element to get the input from.
  42786. * @param element Defines the element the controls should be listened from
  42787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42788. */
  42789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42790. /**
  42791. * Detach the current controls from the specified dom element.
  42792. * @param element Defines the element to stop listening the inputs from
  42793. */
  42794. detachControl(element: Nullable<HTMLElement>): void;
  42795. /**
  42796. * Update the current camera state depending on the inputs that have been used this frame.
  42797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42798. */
  42799. checkInputs(): void;
  42800. /**
  42801. * Gets the class name of the current intput.
  42802. * @returns the class name
  42803. */
  42804. getClassName(): string;
  42805. /**
  42806. * Get the friendly name associated with the input class.
  42807. * @returns the input friendly name
  42808. */
  42809. getSimpleName(): string;
  42810. }
  42811. }
  42812. declare module BABYLON {
  42813. /**
  42814. * Manage the mouse wheel inputs to control an arc rotate camera.
  42815. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42816. */
  42817. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42818. /**
  42819. * Defines the camera the input is attached to.
  42820. */
  42821. camera: ArcRotateCamera;
  42822. /**
  42823. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42824. */
  42825. wheelPrecision: number;
  42826. /**
  42827. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42828. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42829. */
  42830. wheelDeltaPercentage: number;
  42831. private _wheel;
  42832. private _observer;
  42833. private computeDeltaFromMouseWheelLegacyEvent;
  42834. /**
  42835. * Attach the input controls to a specific dom element to get the input from.
  42836. * @param element Defines the element the controls should be listened from
  42837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42838. */
  42839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42840. /**
  42841. * Detach the current controls from the specified dom element.
  42842. * @param element Defines the element to stop listening the inputs from
  42843. */
  42844. detachControl(element: Nullable<HTMLElement>): void;
  42845. /**
  42846. * Gets the class name of the current intput.
  42847. * @returns the class name
  42848. */
  42849. getClassName(): string;
  42850. /**
  42851. * Get the friendly name associated with the input class.
  42852. * @returns the input friendly name
  42853. */
  42854. getSimpleName(): string;
  42855. }
  42856. }
  42857. declare module BABYLON {
  42858. /**
  42859. * Default Inputs manager for the ArcRotateCamera.
  42860. * It groups all the default supported inputs for ease of use.
  42861. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42862. */
  42863. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42864. /**
  42865. * Instantiates a new ArcRotateCameraInputsManager.
  42866. * @param camera Defines the camera the inputs belong to
  42867. */
  42868. constructor(camera: ArcRotateCamera);
  42869. /**
  42870. * Add mouse wheel input support to the input manager.
  42871. * @returns the current input manager
  42872. */
  42873. addMouseWheel(): ArcRotateCameraInputsManager;
  42874. /**
  42875. * Add pointers input support to the input manager.
  42876. * @returns the current input manager
  42877. */
  42878. addPointers(): ArcRotateCameraInputsManager;
  42879. /**
  42880. * Add keyboard input support to the input manager.
  42881. * @returns the current input manager
  42882. */
  42883. addKeyboard(): ArcRotateCameraInputsManager;
  42884. }
  42885. }
  42886. declare module BABYLON {
  42887. /**
  42888. * This represents an orbital type of camera.
  42889. *
  42890. * 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.
  42891. * 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.
  42892. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42893. */
  42894. export class ArcRotateCamera extends TargetCamera {
  42895. /**
  42896. * Defines the rotation angle of the camera along the longitudinal axis.
  42897. */
  42898. alpha: number;
  42899. /**
  42900. * Defines the rotation angle of the camera along the latitudinal axis.
  42901. */
  42902. beta: number;
  42903. /**
  42904. * Defines the radius of the camera from it s target point.
  42905. */
  42906. radius: number;
  42907. protected _target: Vector3;
  42908. protected _targetHost: Nullable<AbstractMesh>;
  42909. /**
  42910. * Defines the target point of the camera.
  42911. * The camera looks towards it form the radius distance.
  42912. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42913. */
  42914. get target(): Vector3;
  42915. set target(value: Vector3);
  42916. /**
  42917. * Define the current local position of the camera in the scene
  42918. */
  42919. get position(): Vector3;
  42920. set position(newPosition: Vector3);
  42921. protected _upToYMatrix: Matrix;
  42922. protected _YToUpMatrix: Matrix;
  42923. /**
  42924. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42925. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42926. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42927. */
  42928. set upVector(vec: Vector3);
  42929. get upVector(): Vector3;
  42930. /**
  42931. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42932. */
  42933. setMatUp(): void;
  42934. /**
  42935. * Current inertia value on the longitudinal axis.
  42936. * The bigger this number the longer it will take for the camera to stop.
  42937. */
  42938. inertialAlphaOffset: number;
  42939. /**
  42940. * Current inertia value on the latitudinal axis.
  42941. * The bigger this number the longer it will take for the camera to stop.
  42942. */
  42943. inertialBetaOffset: number;
  42944. /**
  42945. * Current inertia value on the radius axis.
  42946. * The bigger this number the longer it will take for the camera to stop.
  42947. */
  42948. inertialRadiusOffset: number;
  42949. /**
  42950. * Minimum allowed angle on the longitudinal axis.
  42951. * This can help limiting how the Camera is able to move in the scene.
  42952. */
  42953. lowerAlphaLimit: Nullable<number>;
  42954. /**
  42955. * Maximum allowed angle on the longitudinal axis.
  42956. * This can help limiting how the Camera is able to move in the scene.
  42957. */
  42958. upperAlphaLimit: Nullable<number>;
  42959. /**
  42960. * Minimum allowed angle on the latitudinal axis.
  42961. * This can help limiting how the Camera is able to move in the scene.
  42962. */
  42963. lowerBetaLimit: number;
  42964. /**
  42965. * Maximum allowed angle on the latitudinal axis.
  42966. * This can help limiting how the Camera is able to move in the scene.
  42967. */
  42968. upperBetaLimit: number;
  42969. /**
  42970. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42971. * This can help limiting how the Camera is able to move in the scene.
  42972. */
  42973. lowerRadiusLimit: Nullable<number>;
  42974. /**
  42975. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42976. * This can help limiting how the Camera is able to move in the scene.
  42977. */
  42978. upperRadiusLimit: Nullable<number>;
  42979. /**
  42980. * Defines the current inertia value used during panning of the camera along the X axis.
  42981. */
  42982. inertialPanningX: number;
  42983. /**
  42984. * Defines the current inertia value used during panning of the camera along the Y axis.
  42985. */
  42986. inertialPanningY: number;
  42987. /**
  42988. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42989. * Basically if your fingers moves away from more than this distance you will be considered
  42990. * in pinch mode.
  42991. */
  42992. pinchToPanMaxDistance: number;
  42993. /**
  42994. * Defines the maximum distance the camera can pan.
  42995. * This could help keeping the cammera always in your scene.
  42996. */
  42997. panningDistanceLimit: Nullable<number>;
  42998. /**
  42999. * Defines the target of the camera before paning.
  43000. */
  43001. panningOriginTarget: Vector3;
  43002. /**
  43003. * Defines the value of the inertia used during panning.
  43004. * 0 would mean stop inertia and one would mean no decelleration at all.
  43005. */
  43006. panningInertia: number;
  43007. /**
  43008. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43009. */
  43010. get angularSensibilityX(): number;
  43011. set angularSensibilityX(value: number);
  43012. /**
  43013. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43014. */
  43015. get angularSensibilityY(): number;
  43016. set angularSensibilityY(value: number);
  43017. /**
  43018. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43019. */
  43020. get pinchPrecision(): number;
  43021. set pinchPrecision(value: number);
  43022. /**
  43023. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43024. * It will be used instead of pinchDeltaPrecision if different from 0.
  43025. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43026. */
  43027. get pinchDeltaPercentage(): number;
  43028. set pinchDeltaPercentage(value: number);
  43029. /**
  43030. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43031. * and pinch delta percentage.
  43032. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43033. * that any object in the plane at the camera's target point will scale
  43034. * perfectly with finger motion.
  43035. */
  43036. get useNaturalPinchZoom(): boolean;
  43037. set useNaturalPinchZoom(value: boolean);
  43038. /**
  43039. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43040. */
  43041. get panningSensibility(): number;
  43042. set panningSensibility(value: number);
  43043. /**
  43044. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43045. */
  43046. get keysUp(): number[];
  43047. set keysUp(value: number[]);
  43048. /**
  43049. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43050. */
  43051. get keysDown(): number[];
  43052. set keysDown(value: number[]);
  43053. /**
  43054. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43055. */
  43056. get keysLeft(): number[];
  43057. set keysLeft(value: number[]);
  43058. /**
  43059. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43060. */
  43061. get keysRight(): number[];
  43062. set keysRight(value: number[]);
  43063. /**
  43064. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43065. */
  43066. get wheelPrecision(): number;
  43067. set wheelPrecision(value: number);
  43068. /**
  43069. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43070. * It will be used instead of pinchDeltaPrecision if different from 0.
  43071. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43072. */
  43073. get wheelDeltaPercentage(): number;
  43074. set wheelDeltaPercentage(value: number);
  43075. /**
  43076. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43077. */
  43078. zoomOnFactor: number;
  43079. /**
  43080. * Defines a screen offset for the camera position.
  43081. */
  43082. targetScreenOffset: Vector2;
  43083. /**
  43084. * Allows the camera to be completely reversed.
  43085. * If false the camera can not arrive upside down.
  43086. */
  43087. allowUpsideDown: boolean;
  43088. /**
  43089. * Define if double tap/click is used to restore the previously saved state of the camera.
  43090. */
  43091. useInputToRestoreState: boolean;
  43092. /** @hidden */
  43093. _viewMatrix: Matrix;
  43094. /** @hidden */
  43095. _useCtrlForPanning: boolean;
  43096. /** @hidden */
  43097. _panningMouseButton: number;
  43098. /**
  43099. * Defines the input associated to the camera.
  43100. */
  43101. inputs: ArcRotateCameraInputsManager;
  43102. /** @hidden */
  43103. _reset: () => void;
  43104. /**
  43105. * Defines the allowed panning axis.
  43106. */
  43107. panningAxis: Vector3;
  43108. protected _localDirection: Vector3;
  43109. protected _transformedDirection: Vector3;
  43110. private _bouncingBehavior;
  43111. /**
  43112. * Gets the bouncing behavior of the camera if it has been enabled.
  43113. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43114. */
  43115. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43116. /**
  43117. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43118. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43119. */
  43120. get useBouncingBehavior(): boolean;
  43121. set useBouncingBehavior(value: boolean);
  43122. private _framingBehavior;
  43123. /**
  43124. * Gets the framing behavior of the camera if it has been enabled.
  43125. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43126. */
  43127. get framingBehavior(): Nullable<FramingBehavior>;
  43128. /**
  43129. * Defines if the framing behavior of the camera is enabled on the camera.
  43130. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43131. */
  43132. get useFramingBehavior(): boolean;
  43133. set useFramingBehavior(value: boolean);
  43134. private _autoRotationBehavior;
  43135. /**
  43136. * Gets the auto rotation behavior of the camera if it has been enabled.
  43137. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43138. */
  43139. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43140. /**
  43141. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43142. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43143. */
  43144. get useAutoRotationBehavior(): boolean;
  43145. set useAutoRotationBehavior(value: boolean);
  43146. /**
  43147. * Observable triggered when the mesh target has been changed on the camera.
  43148. */
  43149. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43150. /**
  43151. * Event raised when the camera is colliding with a mesh.
  43152. */
  43153. onCollide: (collidedMesh: AbstractMesh) => void;
  43154. /**
  43155. * Defines whether the camera should check collision with the objects oh the scene.
  43156. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43157. */
  43158. checkCollisions: boolean;
  43159. /**
  43160. * Defines the collision radius of the camera.
  43161. * This simulates a sphere around the camera.
  43162. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43163. */
  43164. collisionRadius: Vector3;
  43165. protected _collider: Collider;
  43166. protected _previousPosition: Vector3;
  43167. protected _collisionVelocity: Vector3;
  43168. protected _newPosition: Vector3;
  43169. protected _previousAlpha: number;
  43170. protected _previousBeta: number;
  43171. protected _previousRadius: number;
  43172. protected _collisionTriggered: boolean;
  43173. protected _targetBoundingCenter: Nullable<Vector3>;
  43174. private _computationVector;
  43175. /**
  43176. * Instantiates a new ArcRotateCamera in a given scene
  43177. * @param name Defines the name of the camera
  43178. * @param alpha Defines the camera rotation along the logitudinal axis
  43179. * @param beta Defines the camera rotation along the latitudinal axis
  43180. * @param radius Defines the camera distance from its target
  43181. * @param target Defines the camera target
  43182. * @param scene Defines the scene the camera belongs to
  43183. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43184. */
  43185. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43186. /** @hidden */
  43187. _initCache(): void;
  43188. /** @hidden */
  43189. _updateCache(ignoreParentClass?: boolean): void;
  43190. protected _getTargetPosition(): Vector3;
  43191. private _storedAlpha;
  43192. private _storedBeta;
  43193. private _storedRadius;
  43194. private _storedTarget;
  43195. private _storedTargetScreenOffset;
  43196. /**
  43197. * Stores the current state of the camera (alpha, beta, radius and target)
  43198. * @returns the camera itself
  43199. */
  43200. storeState(): Camera;
  43201. /**
  43202. * @hidden
  43203. * Restored camera state. You must call storeState() first
  43204. */
  43205. _restoreStateValues(): boolean;
  43206. /** @hidden */
  43207. _isSynchronizedViewMatrix(): boolean;
  43208. /**
  43209. * Attached controls to the current camera.
  43210. * @param element Defines the element the controls should be listened from
  43211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43212. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43213. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43214. */
  43215. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43216. /**
  43217. * Detach the current controls from the camera.
  43218. * The camera will stop reacting to inputs.
  43219. * @param element Defines the element to stop listening the inputs from
  43220. */
  43221. detachControl(element: HTMLElement): void;
  43222. /** @hidden */
  43223. _checkInputs(): void;
  43224. protected _checkLimits(): void;
  43225. /**
  43226. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43227. */
  43228. rebuildAnglesAndRadius(): void;
  43229. /**
  43230. * Use a position to define the current camera related information like alpha, beta and radius
  43231. * @param position Defines the position to set the camera at
  43232. */
  43233. setPosition(position: Vector3): void;
  43234. /**
  43235. * Defines the target the camera should look at.
  43236. * This will automatically adapt alpha beta and radius to fit within the new target.
  43237. * @param target Defines the new target as a Vector or a mesh
  43238. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43239. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43240. */
  43241. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43242. /** @hidden */
  43243. _getViewMatrix(): Matrix;
  43244. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43245. /**
  43246. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43247. * @param meshes Defines the mesh to zoom on
  43248. * @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)
  43249. */
  43250. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43251. /**
  43252. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43253. * The target will be changed but the radius
  43254. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43255. * @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)
  43256. */
  43257. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43258. min: Vector3;
  43259. max: Vector3;
  43260. distance: number;
  43261. }, doNotUpdateMaxZ?: boolean): void;
  43262. /**
  43263. * @override
  43264. * Override Camera.createRigCamera
  43265. */
  43266. createRigCamera(name: string, cameraIndex: number): Camera;
  43267. /**
  43268. * @hidden
  43269. * @override
  43270. * Override Camera._updateRigCameras
  43271. */
  43272. _updateRigCameras(): void;
  43273. /**
  43274. * Destroy the camera and release the current resources hold by it.
  43275. */
  43276. dispose(): void;
  43277. /**
  43278. * Gets the current object class name.
  43279. * @return the class name
  43280. */
  43281. getClassName(): string;
  43282. }
  43283. }
  43284. declare module BABYLON {
  43285. /**
  43286. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43287. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43288. */
  43289. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43290. /**
  43291. * Gets the name of the behavior.
  43292. */
  43293. get name(): string;
  43294. private _zoomStopsAnimation;
  43295. private _idleRotationSpeed;
  43296. private _idleRotationWaitTime;
  43297. private _idleRotationSpinupTime;
  43298. /**
  43299. * Sets the flag that indicates if user zooming should stop animation.
  43300. */
  43301. set zoomStopsAnimation(flag: boolean);
  43302. /**
  43303. * Gets the flag that indicates if user zooming should stop animation.
  43304. */
  43305. get zoomStopsAnimation(): boolean;
  43306. /**
  43307. * Sets the default speed at which the camera rotates around the model.
  43308. */
  43309. set idleRotationSpeed(speed: number);
  43310. /**
  43311. * Gets the default speed at which the camera rotates around the model.
  43312. */
  43313. get idleRotationSpeed(): number;
  43314. /**
  43315. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43316. */
  43317. set idleRotationWaitTime(time: number);
  43318. /**
  43319. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43320. */
  43321. get idleRotationWaitTime(): number;
  43322. /**
  43323. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43324. */
  43325. set idleRotationSpinupTime(time: number);
  43326. /**
  43327. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43328. */
  43329. get idleRotationSpinupTime(): number;
  43330. /**
  43331. * Gets a value indicating if the camera is currently rotating because of this behavior
  43332. */
  43333. get rotationInProgress(): boolean;
  43334. private _onPrePointerObservableObserver;
  43335. private _onAfterCheckInputsObserver;
  43336. private _attachedCamera;
  43337. private _isPointerDown;
  43338. private _lastFrameTime;
  43339. private _lastInteractionTime;
  43340. private _cameraRotationSpeed;
  43341. /**
  43342. * Initializes the behavior.
  43343. */
  43344. init(): void;
  43345. /**
  43346. * Attaches the behavior to its arc rotate camera.
  43347. * @param camera Defines the camera to attach the behavior to
  43348. */
  43349. attach(camera: ArcRotateCamera): void;
  43350. /**
  43351. * Detaches the behavior from its current arc rotate camera.
  43352. */
  43353. detach(): void;
  43354. /**
  43355. * Returns true if user is scrolling.
  43356. * @return true if user is scrolling.
  43357. */
  43358. private _userIsZooming;
  43359. private _lastFrameRadius;
  43360. private _shouldAnimationStopForInteraction;
  43361. /**
  43362. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43363. */
  43364. private _applyUserInteraction;
  43365. private _userIsMoving;
  43366. }
  43367. }
  43368. declare module BABYLON {
  43369. /**
  43370. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43371. */
  43372. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43373. private ui;
  43374. /**
  43375. * The name of the behavior
  43376. */
  43377. name: string;
  43378. /**
  43379. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43380. */
  43381. distanceAwayFromFace: number;
  43382. /**
  43383. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43384. */
  43385. distanceAwayFromBottomOfFace: number;
  43386. private _faceVectors;
  43387. private _target;
  43388. private _scene;
  43389. private _onRenderObserver;
  43390. private _tmpMatrix;
  43391. private _tmpVector;
  43392. /**
  43393. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43394. * @param ui The transform node that should be attched to the mesh
  43395. */
  43396. constructor(ui: TransformNode);
  43397. /**
  43398. * Initializes the behavior
  43399. */
  43400. init(): void;
  43401. private _closestFace;
  43402. private _zeroVector;
  43403. private _lookAtTmpMatrix;
  43404. private _lookAtToRef;
  43405. /**
  43406. * Attaches the AttachToBoxBehavior to the passed in mesh
  43407. * @param target The mesh that the specified node will be attached to
  43408. */
  43409. attach(target: Mesh): void;
  43410. /**
  43411. * Detaches the behavior from the mesh
  43412. */
  43413. detach(): void;
  43414. }
  43415. }
  43416. declare module BABYLON {
  43417. /**
  43418. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43419. */
  43420. export class FadeInOutBehavior implements Behavior<Mesh> {
  43421. /**
  43422. * Time in milliseconds to delay before fading in (Default: 0)
  43423. */
  43424. delay: number;
  43425. /**
  43426. * Time in milliseconds for the mesh to fade in (Default: 300)
  43427. */
  43428. fadeInTime: number;
  43429. private _millisecondsPerFrame;
  43430. private _hovered;
  43431. private _hoverValue;
  43432. private _ownerNode;
  43433. /**
  43434. * Instatiates the FadeInOutBehavior
  43435. */
  43436. constructor();
  43437. /**
  43438. * The name of the behavior
  43439. */
  43440. get name(): string;
  43441. /**
  43442. * Initializes the behavior
  43443. */
  43444. init(): void;
  43445. /**
  43446. * Attaches the fade behavior on the passed in mesh
  43447. * @param ownerNode The mesh that will be faded in/out once attached
  43448. */
  43449. attach(ownerNode: Mesh): void;
  43450. /**
  43451. * Detaches the behavior from the mesh
  43452. */
  43453. detach(): void;
  43454. /**
  43455. * Triggers the mesh to begin fading in or out
  43456. * @param value if the object should fade in or out (true to fade in)
  43457. */
  43458. fadeIn(value: boolean): void;
  43459. private _update;
  43460. private _setAllVisibility;
  43461. }
  43462. }
  43463. declare module BABYLON {
  43464. /**
  43465. * Class containing a set of static utilities functions for managing Pivots
  43466. * @hidden
  43467. */
  43468. export class PivotTools {
  43469. private static _PivotCached;
  43470. private static _OldPivotPoint;
  43471. private static _PivotTranslation;
  43472. private static _PivotTmpVector;
  43473. private static _PivotPostMultiplyPivotMatrix;
  43474. /** @hidden */
  43475. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43476. /** @hidden */
  43477. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43478. }
  43479. }
  43480. declare module BABYLON {
  43481. /**
  43482. * Class containing static functions to help procedurally build meshes
  43483. */
  43484. export class PlaneBuilder {
  43485. /**
  43486. * Creates a plane mesh
  43487. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43488. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43489. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43491. * * 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
  43492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43493. * @param name defines the name of the mesh
  43494. * @param options defines the options used to create the mesh
  43495. * @param scene defines the hosting scene
  43496. * @returns the plane mesh
  43497. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43498. */
  43499. static CreatePlane(name: string, options: {
  43500. size?: number;
  43501. width?: number;
  43502. height?: number;
  43503. sideOrientation?: number;
  43504. frontUVs?: Vector4;
  43505. backUVs?: Vector4;
  43506. updatable?: boolean;
  43507. sourcePlane?: Plane;
  43508. }, scene?: Nullable<Scene>): Mesh;
  43509. }
  43510. }
  43511. declare module BABYLON {
  43512. /**
  43513. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43514. */
  43515. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43516. private static _AnyMouseID;
  43517. /**
  43518. * Abstract mesh the behavior is set on
  43519. */
  43520. attachedNode: AbstractMesh;
  43521. private _dragPlane;
  43522. private _scene;
  43523. private _pointerObserver;
  43524. private _beforeRenderObserver;
  43525. private static _planeScene;
  43526. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43527. /**
  43528. * 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)
  43529. */
  43530. maxDragAngle: number;
  43531. /**
  43532. * @hidden
  43533. */
  43534. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43535. /**
  43536. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43537. */
  43538. currentDraggingPointerID: number;
  43539. /**
  43540. * The last position where the pointer hit the drag plane in world space
  43541. */
  43542. lastDragPosition: Vector3;
  43543. /**
  43544. * If the behavior is currently in a dragging state
  43545. */
  43546. dragging: boolean;
  43547. /**
  43548. * 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)
  43549. */
  43550. dragDeltaRatio: number;
  43551. /**
  43552. * If the drag plane orientation should be updated during the dragging (Default: true)
  43553. */
  43554. updateDragPlane: boolean;
  43555. private _debugMode;
  43556. private _moving;
  43557. /**
  43558. * Fires each time the attached mesh is dragged with the pointer
  43559. * * delta between last drag position and current drag position in world space
  43560. * * dragDistance along the drag axis
  43561. * * dragPlaneNormal normal of the current drag plane used during the drag
  43562. * * dragPlanePoint in world space where the drag intersects the drag plane
  43563. */
  43564. onDragObservable: Observable<{
  43565. delta: Vector3;
  43566. dragPlanePoint: Vector3;
  43567. dragPlaneNormal: Vector3;
  43568. dragDistance: number;
  43569. pointerId: number;
  43570. }>;
  43571. /**
  43572. * Fires each time a drag begins (eg. mouse down on mesh)
  43573. */
  43574. onDragStartObservable: Observable<{
  43575. dragPlanePoint: Vector3;
  43576. pointerId: number;
  43577. }>;
  43578. /**
  43579. * Fires each time a drag ends (eg. mouse release after drag)
  43580. */
  43581. onDragEndObservable: Observable<{
  43582. dragPlanePoint: Vector3;
  43583. pointerId: number;
  43584. }>;
  43585. /**
  43586. * If the attached mesh should be moved when dragged
  43587. */
  43588. moveAttached: boolean;
  43589. /**
  43590. * If the drag behavior will react to drag events (Default: true)
  43591. */
  43592. enabled: boolean;
  43593. /**
  43594. * If pointer events should start and release the drag (Default: true)
  43595. */
  43596. startAndReleaseDragOnPointerEvents: boolean;
  43597. /**
  43598. * If camera controls should be detached during the drag
  43599. */
  43600. detachCameraControls: boolean;
  43601. /**
  43602. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43603. */
  43604. useObjectOrientationForDragging: boolean;
  43605. private _options;
  43606. /**
  43607. * Gets the options used by the behavior
  43608. */
  43609. get options(): {
  43610. dragAxis?: Vector3;
  43611. dragPlaneNormal?: Vector3;
  43612. };
  43613. /**
  43614. * Sets the options used by the behavior
  43615. */
  43616. set options(options: {
  43617. dragAxis?: Vector3;
  43618. dragPlaneNormal?: Vector3;
  43619. });
  43620. /**
  43621. * Creates a pointer drag behavior that can be attached to a mesh
  43622. * @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)
  43623. */
  43624. constructor(options?: {
  43625. dragAxis?: Vector3;
  43626. dragPlaneNormal?: Vector3;
  43627. });
  43628. /**
  43629. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43630. */
  43631. validateDrag: (targetPosition: Vector3) => boolean;
  43632. /**
  43633. * The name of the behavior
  43634. */
  43635. get name(): string;
  43636. /**
  43637. * Initializes the behavior
  43638. */
  43639. init(): void;
  43640. private _tmpVector;
  43641. private _alternatePickedPoint;
  43642. private _worldDragAxis;
  43643. private _targetPosition;
  43644. private _attachedElement;
  43645. /**
  43646. * Attaches the drag behavior the passed in mesh
  43647. * @param ownerNode The mesh that will be dragged around once attached
  43648. * @param predicate Predicate to use for pick filtering
  43649. */
  43650. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43651. /**
  43652. * Force relase the drag action by code.
  43653. */
  43654. releaseDrag(): void;
  43655. private _startDragRay;
  43656. private _lastPointerRay;
  43657. /**
  43658. * Simulates the start of a pointer drag event on the behavior
  43659. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43660. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43661. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43662. */
  43663. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43664. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43665. private _dragDelta;
  43666. protected _moveDrag(ray: Ray): void;
  43667. private _pickWithRayOnDragPlane;
  43668. private _pointA;
  43669. private _pointC;
  43670. private _localAxis;
  43671. private _lookAt;
  43672. private _updateDragPlanePosition;
  43673. /**
  43674. * Detaches the behavior from the mesh
  43675. */
  43676. detach(): void;
  43677. }
  43678. }
  43679. declare module BABYLON {
  43680. /**
  43681. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43682. */
  43683. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43684. private _dragBehaviorA;
  43685. private _dragBehaviorB;
  43686. private _startDistance;
  43687. private _initialScale;
  43688. private _targetScale;
  43689. private _ownerNode;
  43690. private _sceneRenderObserver;
  43691. /**
  43692. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43693. */
  43694. constructor();
  43695. /**
  43696. * The name of the behavior
  43697. */
  43698. get name(): string;
  43699. /**
  43700. * Initializes the behavior
  43701. */
  43702. init(): void;
  43703. private _getCurrentDistance;
  43704. /**
  43705. * Attaches the scale behavior the passed in mesh
  43706. * @param ownerNode The mesh that will be scaled around once attached
  43707. */
  43708. attach(ownerNode: Mesh): void;
  43709. /**
  43710. * Detaches the behavior from the mesh
  43711. */
  43712. detach(): void;
  43713. }
  43714. }
  43715. declare module BABYLON {
  43716. /**
  43717. * 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
  43718. */
  43719. export class SixDofDragBehavior implements Behavior<Mesh> {
  43720. private static _virtualScene;
  43721. private _ownerNode;
  43722. private _sceneRenderObserver;
  43723. private _scene;
  43724. private _targetPosition;
  43725. private _virtualOriginMesh;
  43726. private _virtualDragMesh;
  43727. private _pointerObserver;
  43728. private _moving;
  43729. private _startingOrientation;
  43730. private _attachedElement;
  43731. /**
  43732. * 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)
  43733. */
  43734. private zDragFactor;
  43735. /**
  43736. * If the object should rotate to face the drag origin
  43737. */
  43738. rotateDraggedObject: boolean;
  43739. /**
  43740. * If the behavior is currently in a dragging state
  43741. */
  43742. dragging: boolean;
  43743. /**
  43744. * 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)
  43745. */
  43746. dragDeltaRatio: number;
  43747. /**
  43748. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43749. */
  43750. currentDraggingPointerID: number;
  43751. /**
  43752. * If camera controls should be detached during the drag
  43753. */
  43754. detachCameraControls: boolean;
  43755. /**
  43756. * Fires each time a drag starts
  43757. */
  43758. onDragStartObservable: Observable<{}>;
  43759. /**
  43760. * Fires each time a drag ends (eg. mouse release after drag)
  43761. */
  43762. onDragEndObservable: Observable<{}>;
  43763. /**
  43764. * 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
  43765. */
  43766. constructor();
  43767. /**
  43768. * The name of the behavior
  43769. */
  43770. get name(): string;
  43771. /**
  43772. * Initializes the behavior
  43773. */
  43774. init(): void;
  43775. /**
  43776. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43777. */
  43778. private get _pointerCamera();
  43779. /**
  43780. * Attaches the scale behavior the passed in mesh
  43781. * @param ownerNode The mesh that will be scaled around once attached
  43782. */
  43783. attach(ownerNode: Mesh): void;
  43784. /**
  43785. * Detaches the behavior from the mesh
  43786. */
  43787. detach(): void;
  43788. }
  43789. }
  43790. declare module BABYLON {
  43791. /**
  43792. * Class used to apply inverse kinematics to bones
  43793. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43794. */
  43795. export class BoneIKController {
  43796. private static _tmpVecs;
  43797. private static _tmpQuat;
  43798. private static _tmpMats;
  43799. /**
  43800. * Gets or sets the target mesh
  43801. */
  43802. targetMesh: AbstractMesh;
  43803. /** Gets or sets the mesh used as pole */
  43804. poleTargetMesh: AbstractMesh;
  43805. /**
  43806. * Gets or sets the bone used as pole
  43807. */
  43808. poleTargetBone: Nullable<Bone>;
  43809. /**
  43810. * Gets or sets the target position
  43811. */
  43812. targetPosition: Vector3;
  43813. /**
  43814. * Gets or sets the pole target position
  43815. */
  43816. poleTargetPosition: Vector3;
  43817. /**
  43818. * Gets or sets the pole target local offset
  43819. */
  43820. poleTargetLocalOffset: Vector3;
  43821. /**
  43822. * Gets or sets the pole angle
  43823. */
  43824. poleAngle: number;
  43825. /**
  43826. * Gets or sets the mesh associated with the controller
  43827. */
  43828. mesh: AbstractMesh;
  43829. /**
  43830. * 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)
  43831. */
  43832. slerpAmount: number;
  43833. private _bone1Quat;
  43834. private _bone1Mat;
  43835. private _bone2Ang;
  43836. private _bone1;
  43837. private _bone2;
  43838. private _bone1Length;
  43839. private _bone2Length;
  43840. private _maxAngle;
  43841. private _maxReach;
  43842. private _rightHandedSystem;
  43843. private _bendAxis;
  43844. private _slerping;
  43845. private _adjustRoll;
  43846. /**
  43847. * Gets or sets maximum allowed angle
  43848. */
  43849. get maxAngle(): number;
  43850. set maxAngle(value: number);
  43851. /**
  43852. * Creates a new BoneIKController
  43853. * @param mesh defines the mesh to control
  43854. * @param bone defines the bone to control
  43855. * @param options defines options to set up the controller
  43856. */
  43857. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43858. targetMesh?: AbstractMesh;
  43859. poleTargetMesh?: AbstractMesh;
  43860. poleTargetBone?: Bone;
  43861. poleTargetLocalOffset?: Vector3;
  43862. poleAngle?: number;
  43863. bendAxis?: Vector3;
  43864. maxAngle?: number;
  43865. slerpAmount?: number;
  43866. });
  43867. private _setMaxAngle;
  43868. /**
  43869. * Force the controller to update the bones
  43870. */
  43871. update(): void;
  43872. }
  43873. }
  43874. declare module BABYLON {
  43875. /**
  43876. * Class used to make a bone look toward a point in space
  43877. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43878. */
  43879. export class BoneLookController {
  43880. private static _tmpVecs;
  43881. private static _tmpQuat;
  43882. private static _tmpMats;
  43883. /**
  43884. * The target Vector3 that the bone will look at
  43885. */
  43886. target: Vector3;
  43887. /**
  43888. * The mesh that the bone is attached to
  43889. */
  43890. mesh: AbstractMesh;
  43891. /**
  43892. * The bone that will be looking to the target
  43893. */
  43894. bone: Bone;
  43895. /**
  43896. * The up axis of the coordinate system that is used when the bone is rotated
  43897. */
  43898. upAxis: Vector3;
  43899. /**
  43900. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43901. */
  43902. upAxisSpace: Space;
  43903. /**
  43904. * Used to make an adjustment to the yaw of the bone
  43905. */
  43906. adjustYaw: number;
  43907. /**
  43908. * Used to make an adjustment to the pitch of the bone
  43909. */
  43910. adjustPitch: number;
  43911. /**
  43912. * Used to make an adjustment to the roll of the bone
  43913. */
  43914. adjustRoll: number;
  43915. /**
  43916. * 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)
  43917. */
  43918. slerpAmount: number;
  43919. private _minYaw;
  43920. private _maxYaw;
  43921. private _minPitch;
  43922. private _maxPitch;
  43923. private _minYawSin;
  43924. private _minYawCos;
  43925. private _maxYawSin;
  43926. private _maxYawCos;
  43927. private _midYawConstraint;
  43928. private _minPitchTan;
  43929. private _maxPitchTan;
  43930. private _boneQuat;
  43931. private _slerping;
  43932. private _transformYawPitch;
  43933. private _transformYawPitchInv;
  43934. private _firstFrameSkipped;
  43935. private _yawRange;
  43936. private _fowardAxis;
  43937. /**
  43938. * Gets or sets the minimum yaw angle that the bone can look to
  43939. */
  43940. get minYaw(): number;
  43941. set minYaw(value: number);
  43942. /**
  43943. * Gets or sets the maximum yaw angle that the bone can look to
  43944. */
  43945. get maxYaw(): number;
  43946. set maxYaw(value: number);
  43947. /**
  43948. * Gets or sets the minimum pitch angle that the bone can look to
  43949. */
  43950. get minPitch(): number;
  43951. set minPitch(value: number);
  43952. /**
  43953. * Gets or sets the maximum pitch angle that the bone can look to
  43954. */
  43955. get maxPitch(): number;
  43956. set maxPitch(value: number);
  43957. /**
  43958. * Create a BoneLookController
  43959. * @param mesh the mesh that the bone belongs to
  43960. * @param bone the bone that will be looking to the target
  43961. * @param target the target Vector3 to look at
  43962. * @param options optional settings:
  43963. * * maxYaw: the maximum angle the bone will yaw to
  43964. * * minYaw: the minimum angle the bone will yaw to
  43965. * * maxPitch: the maximum angle the bone will pitch to
  43966. * * minPitch: the minimum angle the bone will yaw to
  43967. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43968. * * upAxis: the up axis of the coordinate system
  43969. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43970. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43971. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43972. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43973. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43974. * * adjustRoll: used to make an adjustment to the roll of the bone
  43975. **/
  43976. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43977. maxYaw?: number;
  43978. minYaw?: number;
  43979. maxPitch?: number;
  43980. minPitch?: number;
  43981. slerpAmount?: number;
  43982. upAxis?: Vector3;
  43983. upAxisSpace?: Space;
  43984. yawAxis?: Vector3;
  43985. pitchAxis?: Vector3;
  43986. adjustYaw?: number;
  43987. adjustPitch?: number;
  43988. adjustRoll?: number;
  43989. });
  43990. /**
  43991. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43992. */
  43993. update(): void;
  43994. private _getAngleDiff;
  43995. private _getAngleBetween;
  43996. private _isAngleBetween;
  43997. }
  43998. }
  43999. declare module BABYLON {
  44000. /**
  44001. * Manage the gamepad inputs to control an arc rotate camera.
  44002. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44003. */
  44004. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44005. /**
  44006. * Defines the camera the input is attached to.
  44007. */
  44008. camera: ArcRotateCamera;
  44009. /**
  44010. * Defines the gamepad the input is gathering event from.
  44011. */
  44012. gamepad: Nullable<Gamepad>;
  44013. /**
  44014. * Defines the gamepad rotation sensiblity.
  44015. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44016. */
  44017. gamepadRotationSensibility: number;
  44018. /**
  44019. * Defines the gamepad move sensiblity.
  44020. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44021. */
  44022. gamepadMoveSensibility: number;
  44023. private _yAxisScale;
  44024. /**
  44025. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44026. */
  44027. get invertYAxis(): boolean;
  44028. set invertYAxis(value: boolean);
  44029. private _onGamepadConnectedObserver;
  44030. private _onGamepadDisconnectedObserver;
  44031. /**
  44032. * Attach the input controls to a specific dom element to get the input from.
  44033. * @param element Defines the element the controls should be listened from
  44034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44035. */
  44036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44037. /**
  44038. * Detach the current controls from the specified dom element.
  44039. * @param element Defines the element to stop listening the inputs from
  44040. */
  44041. detachControl(element: Nullable<HTMLElement>): void;
  44042. /**
  44043. * Update the current camera state depending on the inputs that have been used this frame.
  44044. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44045. */
  44046. checkInputs(): void;
  44047. /**
  44048. * Gets the class name of the current intput.
  44049. * @returns the class name
  44050. */
  44051. getClassName(): string;
  44052. /**
  44053. * Get the friendly name associated with the input class.
  44054. * @returns the input friendly name
  44055. */
  44056. getSimpleName(): string;
  44057. }
  44058. }
  44059. declare module BABYLON {
  44060. interface ArcRotateCameraInputsManager {
  44061. /**
  44062. * Add orientation input support to the input manager.
  44063. * @returns the current input manager
  44064. */
  44065. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44066. }
  44067. /**
  44068. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44069. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44070. */
  44071. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44072. /**
  44073. * Defines the camera the input is attached to.
  44074. */
  44075. camera: ArcRotateCamera;
  44076. /**
  44077. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44078. */
  44079. alphaCorrection: number;
  44080. /**
  44081. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44082. */
  44083. gammaCorrection: number;
  44084. private _alpha;
  44085. private _gamma;
  44086. private _dirty;
  44087. private _deviceOrientationHandler;
  44088. /**
  44089. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44090. */
  44091. constructor();
  44092. /**
  44093. * Attach the input controls to a specific dom element to get the input from.
  44094. * @param element Defines the element the controls should be listened from
  44095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44096. */
  44097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44098. /** @hidden */
  44099. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44100. /**
  44101. * Update the current camera state depending on the inputs that have been used this frame.
  44102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44103. */
  44104. checkInputs(): void;
  44105. /**
  44106. * Detach the current controls from the specified dom element.
  44107. * @param element Defines the element to stop listening the inputs from
  44108. */
  44109. detachControl(element: Nullable<HTMLElement>): void;
  44110. /**
  44111. * Gets the class name of the current intput.
  44112. * @returns the class name
  44113. */
  44114. getClassName(): string;
  44115. /**
  44116. * Get the friendly name associated with the input class.
  44117. * @returns the input friendly name
  44118. */
  44119. getSimpleName(): string;
  44120. }
  44121. }
  44122. declare module BABYLON {
  44123. /**
  44124. * Listen to mouse events to control the camera.
  44125. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44126. */
  44127. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44128. /**
  44129. * Defines the camera the input is attached to.
  44130. */
  44131. camera: FlyCamera;
  44132. /**
  44133. * Defines if touch is enabled. (Default is true.)
  44134. */
  44135. touchEnabled: boolean;
  44136. /**
  44137. * Defines the buttons associated with the input to handle camera rotation.
  44138. */
  44139. buttons: number[];
  44140. /**
  44141. * Assign buttons for Yaw control.
  44142. */
  44143. buttonsYaw: number[];
  44144. /**
  44145. * Assign buttons for Pitch control.
  44146. */
  44147. buttonsPitch: number[];
  44148. /**
  44149. * Assign buttons for Roll control.
  44150. */
  44151. buttonsRoll: number[];
  44152. /**
  44153. * Detect if any button is being pressed while mouse is moved.
  44154. * -1 = Mouse locked.
  44155. * 0 = Left button.
  44156. * 1 = Middle Button.
  44157. * 2 = Right Button.
  44158. */
  44159. activeButton: number;
  44160. /**
  44161. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44162. * Higher values reduce its sensitivity.
  44163. */
  44164. angularSensibility: number;
  44165. private _mousemoveCallback;
  44166. private _observer;
  44167. private _rollObserver;
  44168. private previousPosition;
  44169. private noPreventDefault;
  44170. private element;
  44171. /**
  44172. * Listen to mouse events to control the camera.
  44173. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44174. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44175. */
  44176. constructor(touchEnabled?: boolean);
  44177. /**
  44178. * Attach the mouse control to the HTML DOM element.
  44179. * @param element Defines the element that listens to the input events.
  44180. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44181. */
  44182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44183. /**
  44184. * Detach the current controls from the specified dom element.
  44185. * @param element Defines the element to stop listening the inputs from
  44186. */
  44187. detachControl(element: Nullable<HTMLElement>): void;
  44188. /**
  44189. * Gets the class name of the current input.
  44190. * @returns the class name.
  44191. */
  44192. getClassName(): string;
  44193. /**
  44194. * Get the friendly name associated with the input class.
  44195. * @returns the input's friendly name.
  44196. */
  44197. getSimpleName(): string;
  44198. private _pointerInput;
  44199. private _onMouseMove;
  44200. /**
  44201. * Rotate camera by mouse offset.
  44202. */
  44203. private rotateCamera;
  44204. }
  44205. }
  44206. declare module BABYLON {
  44207. /**
  44208. * Default Inputs manager for the FlyCamera.
  44209. * It groups all the default supported inputs for ease of use.
  44210. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44211. */
  44212. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44213. /**
  44214. * Instantiates a new FlyCameraInputsManager.
  44215. * @param camera Defines the camera the inputs belong to.
  44216. */
  44217. constructor(camera: FlyCamera);
  44218. /**
  44219. * Add keyboard input support to the input manager.
  44220. * @returns the new FlyCameraKeyboardMoveInput().
  44221. */
  44222. addKeyboard(): FlyCameraInputsManager;
  44223. /**
  44224. * Add mouse input support to the input manager.
  44225. * @param touchEnabled Enable touch screen support.
  44226. * @returns the new FlyCameraMouseInput().
  44227. */
  44228. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44229. }
  44230. }
  44231. declare module BABYLON {
  44232. /**
  44233. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44234. * such as in a 3D Space Shooter or a Flight Simulator.
  44235. */
  44236. export class FlyCamera extends TargetCamera {
  44237. /**
  44238. * Define the collision ellipsoid of the camera.
  44239. * This is helpful for simulating a camera body, like a player's body.
  44240. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44241. */
  44242. ellipsoid: Vector3;
  44243. /**
  44244. * Define an offset for the position of the ellipsoid around the camera.
  44245. * This can be helpful if the camera is attached away from the player's body center,
  44246. * such as at its head.
  44247. */
  44248. ellipsoidOffset: Vector3;
  44249. /**
  44250. * Enable or disable collisions of the camera with the rest of the scene objects.
  44251. */
  44252. checkCollisions: boolean;
  44253. /**
  44254. * Enable or disable gravity on the camera.
  44255. */
  44256. applyGravity: boolean;
  44257. /**
  44258. * Define the current direction the camera is moving to.
  44259. */
  44260. cameraDirection: Vector3;
  44261. /**
  44262. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44263. * This overrides and empties cameraRotation.
  44264. */
  44265. rotationQuaternion: Quaternion;
  44266. /**
  44267. * Track Roll to maintain the wanted Rolling when looking around.
  44268. */
  44269. _trackRoll: number;
  44270. /**
  44271. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44272. */
  44273. rollCorrect: number;
  44274. /**
  44275. * Mimic a banked turn, Rolling the camera when Yawing.
  44276. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44277. */
  44278. bankedTurn: boolean;
  44279. /**
  44280. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44281. */
  44282. bankedTurnLimit: number;
  44283. /**
  44284. * Value of 0 disables the banked Roll.
  44285. * Value of 1 is equal to the Yaw angle in radians.
  44286. */
  44287. bankedTurnMultiplier: number;
  44288. /**
  44289. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44290. */
  44291. inputs: FlyCameraInputsManager;
  44292. /**
  44293. * Gets the input sensibility for mouse input.
  44294. * Higher values reduce sensitivity.
  44295. */
  44296. get angularSensibility(): number;
  44297. /**
  44298. * Sets the input sensibility for a mouse input.
  44299. * Higher values reduce sensitivity.
  44300. */
  44301. set angularSensibility(value: number);
  44302. /**
  44303. * Get the keys for camera movement forward.
  44304. */
  44305. get keysForward(): number[];
  44306. /**
  44307. * Set the keys for camera movement forward.
  44308. */
  44309. set keysForward(value: number[]);
  44310. /**
  44311. * Get the keys for camera movement backward.
  44312. */
  44313. get keysBackward(): number[];
  44314. set keysBackward(value: number[]);
  44315. /**
  44316. * Get the keys for camera movement up.
  44317. */
  44318. get keysUp(): number[];
  44319. /**
  44320. * Set the keys for camera movement up.
  44321. */
  44322. set keysUp(value: number[]);
  44323. /**
  44324. * Get the keys for camera movement down.
  44325. */
  44326. get keysDown(): number[];
  44327. /**
  44328. * Set the keys for camera movement down.
  44329. */
  44330. set keysDown(value: number[]);
  44331. /**
  44332. * Get the keys for camera movement left.
  44333. */
  44334. get keysLeft(): number[];
  44335. /**
  44336. * Set the keys for camera movement left.
  44337. */
  44338. set keysLeft(value: number[]);
  44339. /**
  44340. * Set the keys for camera movement right.
  44341. */
  44342. get keysRight(): number[];
  44343. /**
  44344. * Set the keys for camera movement right.
  44345. */
  44346. set keysRight(value: number[]);
  44347. /**
  44348. * Event raised when the camera collides with a mesh in the scene.
  44349. */
  44350. onCollide: (collidedMesh: AbstractMesh) => void;
  44351. private _collider;
  44352. private _needMoveForGravity;
  44353. private _oldPosition;
  44354. private _diffPosition;
  44355. private _newPosition;
  44356. /** @hidden */
  44357. _localDirection: Vector3;
  44358. /** @hidden */
  44359. _transformedDirection: Vector3;
  44360. /**
  44361. * Instantiates a FlyCamera.
  44362. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44363. * such as in a 3D Space Shooter or a Flight Simulator.
  44364. * @param name Define the name of the camera in the scene.
  44365. * @param position Define the starting position of the camera in the scene.
  44366. * @param scene Define the scene the camera belongs to.
  44367. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44368. */
  44369. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44370. /**
  44371. * Attach a control to the HTML DOM element.
  44372. * @param element Defines the element that listens to the input events.
  44373. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44374. */
  44375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44376. /**
  44377. * Detach a control from the HTML DOM element.
  44378. * The camera will stop reacting to that input.
  44379. * @param element Defines the element that listens to the input events.
  44380. */
  44381. detachControl(element: HTMLElement): void;
  44382. private _collisionMask;
  44383. /**
  44384. * Get the mask that the camera ignores in collision events.
  44385. */
  44386. get collisionMask(): number;
  44387. /**
  44388. * Set the mask that the camera ignores in collision events.
  44389. */
  44390. set collisionMask(mask: number);
  44391. /** @hidden */
  44392. _collideWithWorld(displacement: Vector3): void;
  44393. /** @hidden */
  44394. private _onCollisionPositionChange;
  44395. /** @hidden */
  44396. _checkInputs(): void;
  44397. /** @hidden */
  44398. _decideIfNeedsToMove(): boolean;
  44399. /** @hidden */
  44400. _updatePosition(): void;
  44401. /**
  44402. * Restore the Roll to its target value at the rate specified.
  44403. * @param rate - Higher means slower restoring.
  44404. * @hidden
  44405. */
  44406. restoreRoll(rate: number): void;
  44407. /**
  44408. * Destroy the camera and release the current resources held by it.
  44409. */
  44410. dispose(): void;
  44411. /**
  44412. * Get the current object class name.
  44413. * @returns the class name.
  44414. */
  44415. getClassName(): string;
  44416. }
  44417. }
  44418. declare module BABYLON {
  44419. /**
  44420. * Listen to keyboard events to control the camera.
  44421. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44422. */
  44423. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44424. /**
  44425. * Defines the camera the input is attached to.
  44426. */
  44427. camera: FlyCamera;
  44428. /**
  44429. * The list of keyboard keys used to control the forward move of the camera.
  44430. */
  44431. keysForward: number[];
  44432. /**
  44433. * The list of keyboard keys used to control the backward move of the camera.
  44434. */
  44435. keysBackward: number[];
  44436. /**
  44437. * The list of keyboard keys used to control the forward move of the camera.
  44438. */
  44439. keysUp: number[];
  44440. /**
  44441. * The list of keyboard keys used to control the backward move of the camera.
  44442. */
  44443. keysDown: number[];
  44444. /**
  44445. * The list of keyboard keys used to control the right strafe move of the camera.
  44446. */
  44447. keysRight: number[];
  44448. /**
  44449. * The list of keyboard keys used to control the left strafe move of the camera.
  44450. */
  44451. keysLeft: number[];
  44452. private _keys;
  44453. private _onCanvasBlurObserver;
  44454. private _onKeyboardObserver;
  44455. private _engine;
  44456. private _scene;
  44457. /**
  44458. * Attach the input controls to a specific dom element to get the input from.
  44459. * @param element Defines the element the controls should be listened from
  44460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44461. */
  44462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44463. /**
  44464. * Detach the current controls from the specified dom element.
  44465. * @param element Defines the element to stop listening the inputs from
  44466. */
  44467. detachControl(element: Nullable<HTMLElement>): void;
  44468. /**
  44469. * Gets the class name of the current intput.
  44470. * @returns the class name
  44471. */
  44472. getClassName(): string;
  44473. /** @hidden */
  44474. _onLostFocus(e: FocusEvent): void;
  44475. /**
  44476. * Get the friendly name associated with the input class.
  44477. * @returns the input friendly name
  44478. */
  44479. getSimpleName(): string;
  44480. /**
  44481. * Update the current camera state depending on the inputs that have been used this frame.
  44482. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44483. */
  44484. checkInputs(): void;
  44485. }
  44486. }
  44487. declare module BABYLON {
  44488. /**
  44489. * Manage the mouse wheel inputs to control a follow camera.
  44490. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44491. */
  44492. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44493. /**
  44494. * Defines the camera the input is attached to.
  44495. */
  44496. camera: FollowCamera;
  44497. /**
  44498. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44499. */
  44500. axisControlRadius: boolean;
  44501. /**
  44502. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44503. */
  44504. axisControlHeight: boolean;
  44505. /**
  44506. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44507. */
  44508. axisControlRotation: boolean;
  44509. /**
  44510. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44511. * relation to mouseWheel events.
  44512. */
  44513. wheelPrecision: number;
  44514. /**
  44515. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44516. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44517. */
  44518. wheelDeltaPercentage: number;
  44519. private _wheel;
  44520. private _observer;
  44521. /**
  44522. * Attach the input controls to a specific dom element to get the input from.
  44523. * @param element Defines the element the controls should be listened from
  44524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44525. */
  44526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44527. /**
  44528. * Detach the current controls from the specified dom element.
  44529. * @param element Defines the element to stop listening the inputs from
  44530. */
  44531. detachControl(element: Nullable<HTMLElement>): void;
  44532. /**
  44533. * Gets the class name of the current intput.
  44534. * @returns the class name
  44535. */
  44536. getClassName(): string;
  44537. /**
  44538. * Get the friendly name associated with the input class.
  44539. * @returns the input friendly name
  44540. */
  44541. getSimpleName(): string;
  44542. }
  44543. }
  44544. declare module BABYLON {
  44545. /**
  44546. * Manage the pointers inputs to control an follow camera.
  44547. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44548. */
  44549. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44550. /**
  44551. * Defines the camera the input is attached to.
  44552. */
  44553. camera: FollowCamera;
  44554. /**
  44555. * Gets the class name of the current input.
  44556. * @returns the class name
  44557. */
  44558. getClassName(): string;
  44559. /**
  44560. * Defines the pointer angular sensibility along the X axis or how fast is
  44561. * the camera rotating.
  44562. * A negative number will reverse the axis direction.
  44563. */
  44564. angularSensibilityX: number;
  44565. /**
  44566. * Defines the pointer angular sensibility along the Y axis or how fast is
  44567. * the camera rotating.
  44568. * A negative number will reverse the axis direction.
  44569. */
  44570. angularSensibilityY: number;
  44571. /**
  44572. * Defines the pointer pinch precision or how fast is the camera zooming.
  44573. * A negative number will reverse the axis direction.
  44574. */
  44575. pinchPrecision: number;
  44576. /**
  44577. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44578. * from 0.
  44579. * It defines the percentage of current camera.radius to use as delta when
  44580. * pinch zoom is used.
  44581. */
  44582. pinchDeltaPercentage: number;
  44583. /**
  44584. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44585. */
  44586. axisXControlRadius: boolean;
  44587. /**
  44588. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44589. */
  44590. axisXControlHeight: boolean;
  44591. /**
  44592. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44593. */
  44594. axisXControlRotation: boolean;
  44595. /**
  44596. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44597. */
  44598. axisYControlRadius: boolean;
  44599. /**
  44600. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44601. */
  44602. axisYControlHeight: boolean;
  44603. /**
  44604. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44605. */
  44606. axisYControlRotation: boolean;
  44607. /**
  44608. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44609. */
  44610. axisPinchControlRadius: boolean;
  44611. /**
  44612. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44613. */
  44614. axisPinchControlHeight: boolean;
  44615. /**
  44616. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44617. */
  44618. axisPinchControlRotation: boolean;
  44619. /**
  44620. * Log error messages if basic misconfiguration has occurred.
  44621. */
  44622. warningEnable: boolean;
  44623. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44624. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44625. private _warningCounter;
  44626. private _warning;
  44627. }
  44628. }
  44629. declare module BABYLON {
  44630. /**
  44631. * Default Inputs manager for the FollowCamera.
  44632. * It groups all the default supported inputs for ease of use.
  44633. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44634. */
  44635. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44636. /**
  44637. * Instantiates a new FollowCameraInputsManager.
  44638. * @param camera Defines the camera the inputs belong to
  44639. */
  44640. constructor(camera: FollowCamera);
  44641. /**
  44642. * Add keyboard input support to the input manager.
  44643. * @returns the current input manager
  44644. */
  44645. addKeyboard(): FollowCameraInputsManager;
  44646. /**
  44647. * Add mouse wheel input support to the input manager.
  44648. * @returns the current input manager
  44649. */
  44650. addMouseWheel(): FollowCameraInputsManager;
  44651. /**
  44652. * Add pointers input support to the input manager.
  44653. * @returns the current input manager
  44654. */
  44655. addPointers(): FollowCameraInputsManager;
  44656. /**
  44657. * Add orientation input support to the input manager.
  44658. * @returns the current input manager
  44659. */
  44660. addVRDeviceOrientation(): FollowCameraInputsManager;
  44661. }
  44662. }
  44663. declare module BABYLON {
  44664. /**
  44665. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44666. * an arc rotate version arcFollowCamera are available.
  44667. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44668. */
  44669. export class FollowCamera extends TargetCamera {
  44670. /**
  44671. * Distance the follow camera should follow an object at
  44672. */
  44673. radius: number;
  44674. /**
  44675. * Minimum allowed distance of the camera to the axis of rotation
  44676. * (The camera can not get closer).
  44677. * This can help limiting how the Camera is able to move in the scene.
  44678. */
  44679. lowerRadiusLimit: Nullable<number>;
  44680. /**
  44681. * Maximum allowed distance of the camera to the axis of rotation
  44682. * (The camera can not get further).
  44683. * This can help limiting how the Camera is able to move in the scene.
  44684. */
  44685. upperRadiusLimit: Nullable<number>;
  44686. /**
  44687. * Define a rotation offset between the camera and the object it follows
  44688. */
  44689. rotationOffset: number;
  44690. /**
  44691. * Minimum allowed angle to camera position relative to target object.
  44692. * This can help limiting how the Camera is able to move in the scene.
  44693. */
  44694. lowerRotationOffsetLimit: Nullable<number>;
  44695. /**
  44696. * Maximum allowed angle to camera position relative to target object.
  44697. * This can help limiting how the Camera is able to move in the scene.
  44698. */
  44699. upperRotationOffsetLimit: Nullable<number>;
  44700. /**
  44701. * Define a height offset between the camera and the object it follows.
  44702. * It can help following an object from the top (like a car chaing a plane)
  44703. */
  44704. heightOffset: number;
  44705. /**
  44706. * Minimum allowed height of camera position relative to target object.
  44707. * This can help limiting how the Camera is able to move in the scene.
  44708. */
  44709. lowerHeightOffsetLimit: Nullable<number>;
  44710. /**
  44711. * Maximum allowed height of camera position relative to target object.
  44712. * This can help limiting how the Camera is able to move in the scene.
  44713. */
  44714. upperHeightOffsetLimit: Nullable<number>;
  44715. /**
  44716. * Define how fast the camera can accelerate to follow it s target.
  44717. */
  44718. cameraAcceleration: number;
  44719. /**
  44720. * Define the speed limit of the camera following an object.
  44721. */
  44722. maxCameraSpeed: number;
  44723. /**
  44724. * Define the target of the camera.
  44725. */
  44726. lockedTarget: Nullable<AbstractMesh>;
  44727. /**
  44728. * Defines the input associated with the camera.
  44729. */
  44730. inputs: FollowCameraInputsManager;
  44731. /**
  44732. * Instantiates the follow camera.
  44733. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44734. * @param name Define the name of the camera in the scene
  44735. * @param position Define the position of the camera
  44736. * @param scene Define the scene the camera belong to
  44737. * @param lockedTarget Define the target of the camera
  44738. */
  44739. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44740. private _follow;
  44741. /**
  44742. * Attached controls to the current camera.
  44743. * @param element Defines the element the controls should be listened from
  44744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44745. */
  44746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44747. /**
  44748. * Detach the current controls from the camera.
  44749. * The camera will stop reacting to inputs.
  44750. * @param element Defines the element to stop listening the inputs from
  44751. */
  44752. detachControl(element: HTMLElement): void;
  44753. /** @hidden */
  44754. _checkInputs(): void;
  44755. private _checkLimits;
  44756. /**
  44757. * Gets the camera class name.
  44758. * @returns the class name
  44759. */
  44760. getClassName(): string;
  44761. }
  44762. /**
  44763. * Arc Rotate version of the follow camera.
  44764. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44765. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44766. */
  44767. export class ArcFollowCamera extends TargetCamera {
  44768. /** The longitudinal angle of the camera */
  44769. alpha: number;
  44770. /** The latitudinal angle of the camera */
  44771. beta: number;
  44772. /** The radius of the camera from its target */
  44773. radius: number;
  44774. private _cartesianCoordinates;
  44775. /** Define the camera target (the mesh it should follow) */
  44776. private _meshTarget;
  44777. /**
  44778. * Instantiates a new ArcFollowCamera
  44779. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44780. * @param name Define the name of the camera
  44781. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44782. * @param beta Define the rotation angle of the camera around the elevation axis
  44783. * @param radius Define the radius of the camera from its target point
  44784. * @param target Define the target of the camera
  44785. * @param scene Define the scene the camera belongs to
  44786. */
  44787. constructor(name: string,
  44788. /** The longitudinal angle of the camera */
  44789. alpha: number,
  44790. /** The latitudinal angle of the camera */
  44791. beta: number,
  44792. /** The radius of the camera from its target */
  44793. radius: number,
  44794. /** Define the camera target (the mesh it should follow) */
  44795. target: Nullable<AbstractMesh>, scene: Scene);
  44796. private _follow;
  44797. /** @hidden */
  44798. _checkInputs(): void;
  44799. /**
  44800. * Returns the class name of the object.
  44801. * It is mostly used internally for serialization purposes.
  44802. */
  44803. getClassName(): string;
  44804. }
  44805. }
  44806. declare module BABYLON {
  44807. /**
  44808. * Manage the keyboard inputs to control the movement of a follow camera.
  44809. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44810. */
  44811. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44812. /**
  44813. * Defines the camera the input is attached to.
  44814. */
  44815. camera: FollowCamera;
  44816. /**
  44817. * Defines the list of key codes associated with the up action (increase heightOffset)
  44818. */
  44819. keysHeightOffsetIncr: number[];
  44820. /**
  44821. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44822. */
  44823. keysHeightOffsetDecr: number[];
  44824. /**
  44825. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44826. */
  44827. keysHeightOffsetModifierAlt: boolean;
  44828. /**
  44829. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44830. */
  44831. keysHeightOffsetModifierCtrl: boolean;
  44832. /**
  44833. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44834. */
  44835. keysHeightOffsetModifierShift: boolean;
  44836. /**
  44837. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44838. */
  44839. keysRotationOffsetIncr: number[];
  44840. /**
  44841. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44842. */
  44843. keysRotationOffsetDecr: number[];
  44844. /**
  44845. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44846. */
  44847. keysRotationOffsetModifierAlt: boolean;
  44848. /**
  44849. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44850. */
  44851. keysRotationOffsetModifierCtrl: boolean;
  44852. /**
  44853. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44854. */
  44855. keysRotationOffsetModifierShift: boolean;
  44856. /**
  44857. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44858. */
  44859. keysRadiusIncr: number[];
  44860. /**
  44861. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44862. */
  44863. keysRadiusDecr: number[];
  44864. /**
  44865. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44866. */
  44867. keysRadiusModifierAlt: boolean;
  44868. /**
  44869. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44870. */
  44871. keysRadiusModifierCtrl: boolean;
  44872. /**
  44873. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44874. */
  44875. keysRadiusModifierShift: boolean;
  44876. /**
  44877. * Defines the rate of change of heightOffset.
  44878. */
  44879. heightSensibility: number;
  44880. /**
  44881. * Defines the rate of change of rotationOffset.
  44882. */
  44883. rotationSensibility: number;
  44884. /**
  44885. * Defines the rate of change of radius.
  44886. */
  44887. radiusSensibility: number;
  44888. private _keys;
  44889. private _ctrlPressed;
  44890. private _altPressed;
  44891. private _shiftPressed;
  44892. private _onCanvasBlurObserver;
  44893. private _onKeyboardObserver;
  44894. private _engine;
  44895. private _scene;
  44896. /**
  44897. * Attach the input controls to a specific dom element to get the input from.
  44898. * @param element Defines the element the controls should be listened from
  44899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44900. */
  44901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44902. /**
  44903. * Detach the current controls from the specified dom element.
  44904. * @param element Defines the element to stop listening the inputs from
  44905. */
  44906. detachControl(element: Nullable<HTMLElement>): void;
  44907. /**
  44908. * Update the current camera state depending on the inputs that have been used this frame.
  44909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44910. */
  44911. checkInputs(): void;
  44912. /**
  44913. * Gets the class name of the current input.
  44914. * @returns the class name
  44915. */
  44916. getClassName(): string;
  44917. /**
  44918. * Get the friendly name associated with the input class.
  44919. * @returns the input friendly name
  44920. */
  44921. getSimpleName(): string;
  44922. /**
  44923. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44924. * allow modification of the heightOffset value.
  44925. */
  44926. private _modifierHeightOffset;
  44927. /**
  44928. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44929. * allow modification of the rotationOffset value.
  44930. */
  44931. private _modifierRotationOffset;
  44932. /**
  44933. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44934. * allow modification of the radius value.
  44935. */
  44936. private _modifierRadius;
  44937. }
  44938. }
  44939. declare module BABYLON {
  44940. interface FreeCameraInputsManager {
  44941. /**
  44942. * @hidden
  44943. */
  44944. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44945. /**
  44946. * Add orientation input support to the input manager.
  44947. * @returns the current input manager
  44948. */
  44949. addDeviceOrientation(): FreeCameraInputsManager;
  44950. }
  44951. /**
  44952. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44953. * Screen rotation is taken into account.
  44954. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44955. */
  44956. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44957. private _camera;
  44958. private _screenOrientationAngle;
  44959. private _constantTranform;
  44960. private _screenQuaternion;
  44961. private _alpha;
  44962. private _beta;
  44963. private _gamma;
  44964. /**
  44965. * Can be used to detect if a device orientation sensor is available on a device
  44966. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44967. * @returns a promise that will resolve on orientation change
  44968. */
  44969. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44970. /**
  44971. * @hidden
  44972. */
  44973. _onDeviceOrientationChangedObservable: Observable<void>;
  44974. /**
  44975. * Instantiates a new input
  44976. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44977. */
  44978. constructor();
  44979. /**
  44980. * Define the camera controlled by the input.
  44981. */
  44982. get camera(): FreeCamera;
  44983. set camera(camera: FreeCamera);
  44984. /**
  44985. * Attach the input controls to a specific dom element to get the input from.
  44986. * @param element Defines the element the controls should be listened from
  44987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44988. */
  44989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44990. private _orientationChanged;
  44991. private _deviceOrientation;
  44992. /**
  44993. * Detach the current controls from the specified dom element.
  44994. * @param element Defines the element to stop listening the inputs from
  44995. */
  44996. detachControl(element: Nullable<HTMLElement>): void;
  44997. /**
  44998. * Update the current camera state depending on the inputs that have been used this frame.
  44999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45000. */
  45001. checkInputs(): void;
  45002. /**
  45003. * Gets the class name of the current intput.
  45004. * @returns the class name
  45005. */
  45006. getClassName(): string;
  45007. /**
  45008. * Get the friendly name associated with the input class.
  45009. * @returns the input friendly name
  45010. */
  45011. getSimpleName(): string;
  45012. }
  45013. }
  45014. declare module BABYLON {
  45015. /**
  45016. * Manage the gamepad inputs to control a free camera.
  45017. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45018. */
  45019. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45020. /**
  45021. * Define the camera the input is attached to.
  45022. */
  45023. camera: FreeCamera;
  45024. /**
  45025. * Define the Gamepad controlling the input
  45026. */
  45027. gamepad: Nullable<Gamepad>;
  45028. /**
  45029. * Defines the gamepad rotation sensiblity.
  45030. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45031. */
  45032. gamepadAngularSensibility: number;
  45033. /**
  45034. * Defines the gamepad move sensiblity.
  45035. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45036. */
  45037. gamepadMoveSensibility: number;
  45038. private _yAxisScale;
  45039. /**
  45040. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45041. */
  45042. get invertYAxis(): boolean;
  45043. set invertYAxis(value: boolean);
  45044. private _onGamepadConnectedObserver;
  45045. private _onGamepadDisconnectedObserver;
  45046. private _cameraTransform;
  45047. private _deltaTransform;
  45048. private _vector3;
  45049. private _vector2;
  45050. /**
  45051. * Attach the input controls to a specific dom element to get the input from.
  45052. * @param element Defines the element the controls should be listened from
  45053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45054. */
  45055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45056. /**
  45057. * Detach the current controls from the specified dom element.
  45058. * @param element Defines the element to stop listening the inputs from
  45059. */
  45060. detachControl(element: Nullable<HTMLElement>): void;
  45061. /**
  45062. * Update the current camera state depending on the inputs that have been used this frame.
  45063. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45064. */
  45065. checkInputs(): void;
  45066. /**
  45067. * Gets the class name of the current intput.
  45068. * @returns the class name
  45069. */
  45070. getClassName(): string;
  45071. /**
  45072. * Get the friendly name associated with the input class.
  45073. * @returns the input friendly name
  45074. */
  45075. getSimpleName(): string;
  45076. }
  45077. }
  45078. declare module BABYLON {
  45079. /**
  45080. * Defines the potential axis of a Joystick
  45081. */
  45082. export enum JoystickAxis {
  45083. /** X axis */
  45084. X = 0,
  45085. /** Y axis */
  45086. Y = 1,
  45087. /** Z axis */
  45088. Z = 2
  45089. }
  45090. /**
  45091. * Represents the different customization options available
  45092. * for VirtualJoystick
  45093. */
  45094. interface VirtualJoystickCustomizations {
  45095. /**
  45096. * Size of the joystick's puck
  45097. */
  45098. puckSize: number;
  45099. /**
  45100. * Size of the joystick's container
  45101. */
  45102. containerSize: number;
  45103. /**
  45104. * Color of the joystick && puck
  45105. */
  45106. color: string;
  45107. /**
  45108. * Image URL for the joystick's puck
  45109. */
  45110. puckImage?: string;
  45111. /**
  45112. * Image URL for the joystick's container
  45113. */
  45114. containerImage?: string;
  45115. /**
  45116. * Defines the unmoving position of the joystick container
  45117. */
  45118. position?: {
  45119. x: number;
  45120. y: number;
  45121. };
  45122. /**
  45123. * Defines whether or not the joystick container is always visible
  45124. */
  45125. alwaysVisible: boolean;
  45126. /**
  45127. * Defines whether or not to limit the movement of the puck to the joystick's container
  45128. */
  45129. limitToContainer: boolean;
  45130. }
  45131. /**
  45132. * Class used to define virtual joystick (used in touch mode)
  45133. */
  45134. export class VirtualJoystick {
  45135. /**
  45136. * Gets or sets a boolean indicating that left and right values must be inverted
  45137. */
  45138. reverseLeftRight: boolean;
  45139. /**
  45140. * Gets or sets a boolean indicating that up and down values must be inverted
  45141. */
  45142. reverseUpDown: boolean;
  45143. /**
  45144. * Gets the offset value for the position (ie. the change of the position value)
  45145. */
  45146. deltaPosition: Vector3;
  45147. /**
  45148. * Gets a boolean indicating if the virtual joystick was pressed
  45149. */
  45150. pressed: boolean;
  45151. /**
  45152. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45153. */
  45154. static Canvas: Nullable<HTMLCanvasElement>;
  45155. /**
  45156. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45157. */
  45158. limitToContainer: boolean;
  45159. private static _globalJoystickIndex;
  45160. private static _alwaysVisibleSticks;
  45161. private static vjCanvasContext;
  45162. private static vjCanvasWidth;
  45163. private static vjCanvasHeight;
  45164. private static halfWidth;
  45165. private static _GetDefaultOptions;
  45166. private _action;
  45167. private _axisTargetedByLeftAndRight;
  45168. private _axisTargetedByUpAndDown;
  45169. private _joystickSensibility;
  45170. private _inversedSensibility;
  45171. private _joystickPointerID;
  45172. private _joystickColor;
  45173. private _joystickPointerPos;
  45174. private _joystickPreviousPointerPos;
  45175. private _joystickPointerStartPos;
  45176. private _deltaJoystickVector;
  45177. private _leftJoystick;
  45178. private _touches;
  45179. private _joystickPosition;
  45180. private _alwaysVisible;
  45181. private _puckImage;
  45182. private _containerImage;
  45183. private _joystickPuckSize;
  45184. private _joystickContainerSize;
  45185. private _clearPuckSize;
  45186. private _clearContainerSize;
  45187. private _clearPuckSizeOffset;
  45188. private _clearContainerSizeOffset;
  45189. private _onPointerDownHandlerRef;
  45190. private _onPointerMoveHandlerRef;
  45191. private _onPointerUpHandlerRef;
  45192. private _onResize;
  45193. /**
  45194. * Creates a new virtual joystick
  45195. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45196. * @param customizations Defines the options we want to customize the VirtualJoystick
  45197. */
  45198. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45199. /**
  45200. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45201. * @param newJoystickSensibility defines the new sensibility
  45202. */
  45203. setJoystickSensibility(newJoystickSensibility: number): void;
  45204. private _onPointerDown;
  45205. private _onPointerMove;
  45206. private _onPointerUp;
  45207. /**
  45208. * Change the color of the virtual joystick
  45209. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45210. */
  45211. setJoystickColor(newColor: string): void;
  45212. /**
  45213. * Size of the joystick's container
  45214. */
  45215. set containerSize(newSize: number);
  45216. get containerSize(): number;
  45217. /**
  45218. * Size of the joystick's puck
  45219. */
  45220. set puckSize(newSize: number);
  45221. get puckSize(): number;
  45222. /**
  45223. * Clears the set position of the joystick
  45224. */
  45225. clearPosition(): void;
  45226. /**
  45227. * Defines whether or not the joystick container is always visible
  45228. */
  45229. set alwaysVisible(value: boolean);
  45230. get alwaysVisible(): boolean;
  45231. /**
  45232. * Sets the constant position of the Joystick container
  45233. * @param x X axis coordinate
  45234. * @param y Y axis coordinate
  45235. */
  45236. setPosition(x: number, y: number): void;
  45237. /**
  45238. * Defines a callback to call when the joystick is touched
  45239. * @param action defines the callback
  45240. */
  45241. setActionOnTouch(action: () => any): void;
  45242. /**
  45243. * Defines which axis you'd like to control for left & right
  45244. * @param axis defines the axis to use
  45245. */
  45246. setAxisForLeftRight(axis: JoystickAxis): void;
  45247. /**
  45248. * Defines which axis you'd like to control for up & down
  45249. * @param axis defines the axis to use
  45250. */
  45251. setAxisForUpDown(axis: JoystickAxis): void;
  45252. /**
  45253. * Clears the canvas from the previous puck / container draw
  45254. */
  45255. private _clearPreviousDraw;
  45256. /**
  45257. * Loads `urlPath` to be used for the container's image
  45258. * @param urlPath defines the urlPath of an image to use
  45259. */
  45260. setContainerImage(urlPath: string): void;
  45261. /**
  45262. * Loads `urlPath` to be used for the puck's image
  45263. * @param urlPath defines the urlPath of an image to use
  45264. */
  45265. setPuckImage(urlPath: string): void;
  45266. /**
  45267. * Draws the Virtual Joystick's container
  45268. */
  45269. private _drawContainer;
  45270. /**
  45271. * Draws the Virtual Joystick's puck
  45272. */
  45273. private _drawPuck;
  45274. private _drawVirtualJoystick;
  45275. /**
  45276. * Release internal HTML canvas
  45277. */
  45278. releaseCanvas(): void;
  45279. }
  45280. }
  45281. declare module BABYLON {
  45282. interface FreeCameraInputsManager {
  45283. /**
  45284. * Add virtual joystick input support to the input manager.
  45285. * @returns the current input manager
  45286. */
  45287. addVirtualJoystick(): FreeCameraInputsManager;
  45288. }
  45289. /**
  45290. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45291. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45292. */
  45293. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45294. /**
  45295. * Defines the camera the input is attached to.
  45296. */
  45297. camera: FreeCamera;
  45298. private _leftjoystick;
  45299. private _rightjoystick;
  45300. /**
  45301. * Gets the left stick of the virtual joystick.
  45302. * @returns The virtual Joystick
  45303. */
  45304. getLeftJoystick(): VirtualJoystick;
  45305. /**
  45306. * Gets the right stick of the virtual joystick.
  45307. * @returns The virtual Joystick
  45308. */
  45309. getRightJoystick(): VirtualJoystick;
  45310. /**
  45311. * Update the current camera state depending on the inputs that have been used this frame.
  45312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45313. */
  45314. checkInputs(): void;
  45315. /**
  45316. * Attach the input controls to a specific dom element to get the input from.
  45317. * @param element Defines the element the controls should be listened from
  45318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45319. */
  45320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45321. /**
  45322. * Detach the current controls from the specified dom element.
  45323. * @param element Defines the element to stop listening the inputs from
  45324. */
  45325. detachControl(element: Nullable<HTMLElement>): void;
  45326. /**
  45327. * Gets the class name of the current intput.
  45328. * @returns the class name
  45329. */
  45330. getClassName(): string;
  45331. /**
  45332. * Get the friendly name associated with the input class.
  45333. * @returns the input friendly name
  45334. */
  45335. getSimpleName(): string;
  45336. }
  45337. }
  45338. declare module BABYLON {
  45339. /**
  45340. * This represents a FPS type of camera controlled by touch.
  45341. * This is like a universal camera minus the Gamepad controls.
  45342. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45343. */
  45344. export class TouchCamera extends FreeCamera {
  45345. /**
  45346. * Defines the touch sensibility for rotation.
  45347. * The higher the faster.
  45348. */
  45349. get touchAngularSensibility(): number;
  45350. set touchAngularSensibility(value: number);
  45351. /**
  45352. * Defines the touch sensibility for move.
  45353. * The higher the faster.
  45354. */
  45355. get touchMoveSensibility(): number;
  45356. set touchMoveSensibility(value: number);
  45357. /**
  45358. * Instantiates a new touch camera.
  45359. * This represents a FPS type of camera controlled by touch.
  45360. * This is like a universal camera minus the Gamepad controls.
  45361. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45362. * @param name Define the name of the camera in the scene
  45363. * @param position Define the start position of the camera in the scene
  45364. * @param scene Define the scene the camera belongs to
  45365. */
  45366. constructor(name: string, position: Vector3, scene: Scene);
  45367. /**
  45368. * Gets the current object class name.
  45369. * @return the class name
  45370. */
  45371. getClassName(): string;
  45372. /** @hidden */
  45373. _setupInputs(): void;
  45374. }
  45375. }
  45376. declare module BABYLON {
  45377. /**
  45378. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45379. * being tilted forward or back and left or right.
  45380. */
  45381. export class DeviceOrientationCamera extends FreeCamera {
  45382. private _initialQuaternion;
  45383. private _quaternionCache;
  45384. private _tmpDragQuaternion;
  45385. private _disablePointerInputWhenUsingDeviceOrientation;
  45386. /**
  45387. * Creates a new device orientation camera
  45388. * @param name The name of the camera
  45389. * @param position The start position camera
  45390. * @param scene The scene the camera belongs to
  45391. */
  45392. constructor(name: string, position: Vector3, scene: Scene);
  45393. /**
  45394. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45395. */
  45396. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45397. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45398. private _dragFactor;
  45399. /**
  45400. * Enabled turning on the y axis when the orientation sensor is active
  45401. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45402. */
  45403. enableHorizontalDragging(dragFactor?: number): void;
  45404. /**
  45405. * Gets the current instance class name ("DeviceOrientationCamera").
  45406. * This helps avoiding instanceof at run time.
  45407. * @returns the class name
  45408. */
  45409. getClassName(): string;
  45410. /**
  45411. * @hidden
  45412. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45413. */
  45414. _checkInputs(): void;
  45415. /**
  45416. * Reset the camera to its default orientation on the specified axis only.
  45417. * @param axis The axis to reset
  45418. */
  45419. resetToCurrentRotation(axis?: Axis): void;
  45420. }
  45421. }
  45422. declare module BABYLON {
  45423. /**
  45424. * Defines supported buttons for XBox360 compatible gamepads
  45425. */
  45426. export enum Xbox360Button {
  45427. /** A */
  45428. A = 0,
  45429. /** B */
  45430. B = 1,
  45431. /** X */
  45432. X = 2,
  45433. /** Y */
  45434. Y = 3,
  45435. /** Left button */
  45436. LB = 4,
  45437. /** Right button */
  45438. RB = 5,
  45439. /** Back */
  45440. Back = 8,
  45441. /** Start */
  45442. Start = 9,
  45443. /** Left stick */
  45444. LeftStick = 10,
  45445. /** Right stick */
  45446. RightStick = 11
  45447. }
  45448. /** Defines values for XBox360 DPad */
  45449. export enum Xbox360Dpad {
  45450. /** Up */
  45451. Up = 12,
  45452. /** Down */
  45453. Down = 13,
  45454. /** Left */
  45455. Left = 14,
  45456. /** Right */
  45457. Right = 15
  45458. }
  45459. /**
  45460. * Defines a XBox360 gamepad
  45461. */
  45462. export class Xbox360Pad extends Gamepad {
  45463. private _leftTrigger;
  45464. private _rightTrigger;
  45465. private _onlefttriggerchanged;
  45466. private _onrighttriggerchanged;
  45467. private _onbuttondown;
  45468. private _onbuttonup;
  45469. private _ondpaddown;
  45470. private _ondpadup;
  45471. /** Observable raised when a button is pressed */
  45472. onButtonDownObservable: Observable<Xbox360Button>;
  45473. /** Observable raised when a button is released */
  45474. onButtonUpObservable: Observable<Xbox360Button>;
  45475. /** Observable raised when a pad is pressed */
  45476. onPadDownObservable: Observable<Xbox360Dpad>;
  45477. /** Observable raised when a pad is released */
  45478. onPadUpObservable: Observable<Xbox360Dpad>;
  45479. private _buttonA;
  45480. private _buttonB;
  45481. private _buttonX;
  45482. private _buttonY;
  45483. private _buttonBack;
  45484. private _buttonStart;
  45485. private _buttonLB;
  45486. private _buttonRB;
  45487. private _buttonLeftStick;
  45488. private _buttonRightStick;
  45489. private _dPadUp;
  45490. private _dPadDown;
  45491. private _dPadLeft;
  45492. private _dPadRight;
  45493. private _isXboxOnePad;
  45494. /**
  45495. * Creates a new XBox360 gamepad object
  45496. * @param id defines the id of this gamepad
  45497. * @param index defines its index
  45498. * @param gamepad defines the internal HTML gamepad object
  45499. * @param xboxOne defines if it is a XBox One gamepad
  45500. */
  45501. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45502. /**
  45503. * Defines the callback to call when left trigger is pressed
  45504. * @param callback defines the callback to use
  45505. */
  45506. onlefttriggerchanged(callback: (value: number) => void): void;
  45507. /**
  45508. * Defines the callback to call when right trigger is pressed
  45509. * @param callback defines the callback to use
  45510. */
  45511. onrighttriggerchanged(callback: (value: number) => void): void;
  45512. /**
  45513. * Gets the left trigger value
  45514. */
  45515. get leftTrigger(): number;
  45516. /**
  45517. * Sets the left trigger value
  45518. */
  45519. set leftTrigger(newValue: number);
  45520. /**
  45521. * Gets the right trigger value
  45522. */
  45523. get rightTrigger(): number;
  45524. /**
  45525. * Sets the right trigger value
  45526. */
  45527. set rightTrigger(newValue: number);
  45528. /**
  45529. * Defines the callback to call when a button is pressed
  45530. * @param callback defines the callback to use
  45531. */
  45532. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45533. /**
  45534. * Defines the callback to call when a button is released
  45535. * @param callback defines the callback to use
  45536. */
  45537. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45538. /**
  45539. * Defines the callback to call when a pad is pressed
  45540. * @param callback defines the callback to use
  45541. */
  45542. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45543. /**
  45544. * Defines the callback to call when a pad is released
  45545. * @param callback defines the callback to use
  45546. */
  45547. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45548. private _setButtonValue;
  45549. private _setDPadValue;
  45550. /**
  45551. * Gets the value of the `A` button
  45552. */
  45553. get buttonA(): number;
  45554. /**
  45555. * Sets the value of the `A` button
  45556. */
  45557. set buttonA(value: number);
  45558. /**
  45559. * Gets the value of the `B` button
  45560. */
  45561. get buttonB(): number;
  45562. /**
  45563. * Sets the value of the `B` button
  45564. */
  45565. set buttonB(value: number);
  45566. /**
  45567. * Gets the value of the `X` button
  45568. */
  45569. get buttonX(): number;
  45570. /**
  45571. * Sets the value of the `X` button
  45572. */
  45573. set buttonX(value: number);
  45574. /**
  45575. * Gets the value of the `Y` button
  45576. */
  45577. get buttonY(): number;
  45578. /**
  45579. * Sets the value of the `Y` button
  45580. */
  45581. set buttonY(value: number);
  45582. /**
  45583. * Gets the value of the `Start` button
  45584. */
  45585. get buttonStart(): number;
  45586. /**
  45587. * Sets the value of the `Start` button
  45588. */
  45589. set buttonStart(value: number);
  45590. /**
  45591. * Gets the value of the `Back` button
  45592. */
  45593. get buttonBack(): number;
  45594. /**
  45595. * Sets the value of the `Back` button
  45596. */
  45597. set buttonBack(value: number);
  45598. /**
  45599. * Gets the value of the `Left` button
  45600. */
  45601. get buttonLB(): number;
  45602. /**
  45603. * Sets the value of the `Left` button
  45604. */
  45605. set buttonLB(value: number);
  45606. /**
  45607. * Gets the value of the `Right` button
  45608. */
  45609. get buttonRB(): number;
  45610. /**
  45611. * Sets the value of the `Right` button
  45612. */
  45613. set buttonRB(value: number);
  45614. /**
  45615. * Gets the value of the Left joystick
  45616. */
  45617. get buttonLeftStick(): number;
  45618. /**
  45619. * Sets the value of the Left joystick
  45620. */
  45621. set buttonLeftStick(value: number);
  45622. /**
  45623. * Gets the value of the Right joystick
  45624. */
  45625. get buttonRightStick(): number;
  45626. /**
  45627. * Sets the value of the Right joystick
  45628. */
  45629. set buttonRightStick(value: number);
  45630. /**
  45631. * Gets the value of D-pad up
  45632. */
  45633. get dPadUp(): number;
  45634. /**
  45635. * Sets the value of D-pad up
  45636. */
  45637. set dPadUp(value: number);
  45638. /**
  45639. * Gets the value of D-pad down
  45640. */
  45641. get dPadDown(): number;
  45642. /**
  45643. * Sets the value of D-pad down
  45644. */
  45645. set dPadDown(value: number);
  45646. /**
  45647. * Gets the value of D-pad left
  45648. */
  45649. get dPadLeft(): number;
  45650. /**
  45651. * Sets the value of D-pad left
  45652. */
  45653. set dPadLeft(value: number);
  45654. /**
  45655. * Gets the value of D-pad right
  45656. */
  45657. get dPadRight(): number;
  45658. /**
  45659. * Sets the value of D-pad right
  45660. */
  45661. set dPadRight(value: number);
  45662. /**
  45663. * Force the gamepad to synchronize with device values
  45664. */
  45665. update(): void;
  45666. /**
  45667. * Disposes the gamepad
  45668. */
  45669. dispose(): void;
  45670. }
  45671. }
  45672. declare module BABYLON {
  45673. /**
  45674. * Defines supported buttons for DualShock compatible gamepads
  45675. */
  45676. export enum DualShockButton {
  45677. /** Cross */
  45678. Cross = 0,
  45679. /** Circle */
  45680. Circle = 1,
  45681. /** Square */
  45682. Square = 2,
  45683. /** Triangle */
  45684. Triangle = 3,
  45685. /** L1 */
  45686. L1 = 4,
  45687. /** R1 */
  45688. R1 = 5,
  45689. /** Share */
  45690. Share = 8,
  45691. /** Options */
  45692. Options = 9,
  45693. /** Left stick */
  45694. LeftStick = 10,
  45695. /** Right stick */
  45696. RightStick = 11
  45697. }
  45698. /** Defines values for DualShock DPad */
  45699. export enum DualShockDpad {
  45700. /** Up */
  45701. Up = 12,
  45702. /** Down */
  45703. Down = 13,
  45704. /** Left */
  45705. Left = 14,
  45706. /** Right */
  45707. Right = 15
  45708. }
  45709. /**
  45710. * Defines a DualShock gamepad
  45711. */
  45712. export class DualShockPad extends Gamepad {
  45713. private _leftTrigger;
  45714. private _rightTrigger;
  45715. private _onlefttriggerchanged;
  45716. private _onrighttriggerchanged;
  45717. private _onbuttondown;
  45718. private _onbuttonup;
  45719. private _ondpaddown;
  45720. private _ondpadup;
  45721. /** Observable raised when a button is pressed */
  45722. onButtonDownObservable: Observable<DualShockButton>;
  45723. /** Observable raised when a button is released */
  45724. onButtonUpObservable: Observable<DualShockButton>;
  45725. /** Observable raised when a pad is pressed */
  45726. onPadDownObservable: Observable<DualShockDpad>;
  45727. /** Observable raised when a pad is released */
  45728. onPadUpObservable: Observable<DualShockDpad>;
  45729. private _buttonCross;
  45730. private _buttonCircle;
  45731. private _buttonSquare;
  45732. private _buttonTriangle;
  45733. private _buttonShare;
  45734. private _buttonOptions;
  45735. private _buttonL1;
  45736. private _buttonR1;
  45737. private _buttonLeftStick;
  45738. private _buttonRightStick;
  45739. private _dPadUp;
  45740. private _dPadDown;
  45741. private _dPadLeft;
  45742. private _dPadRight;
  45743. /**
  45744. * Creates a new DualShock gamepad object
  45745. * @param id defines the id of this gamepad
  45746. * @param index defines its index
  45747. * @param gamepad defines the internal HTML gamepad object
  45748. */
  45749. constructor(id: string, index: number, gamepad: any);
  45750. /**
  45751. * Defines the callback to call when left trigger is pressed
  45752. * @param callback defines the callback to use
  45753. */
  45754. onlefttriggerchanged(callback: (value: number) => void): void;
  45755. /**
  45756. * Defines the callback to call when right trigger is pressed
  45757. * @param callback defines the callback to use
  45758. */
  45759. onrighttriggerchanged(callback: (value: number) => void): void;
  45760. /**
  45761. * Gets the left trigger value
  45762. */
  45763. get leftTrigger(): number;
  45764. /**
  45765. * Sets the left trigger value
  45766. */
  45767. set leftTrigger(newValue: number);
  45768. /**
  45769. * Gets the right trigger value
  45770. */
  45771. get rightTrigger(): number;
  45772. /**
  45773. * Sets the right trigger value
  45774. */
  45775. set rightTrigger(newValue: number);
  45776. /**
  45777. * Defines the callback to call when a button is pressed
  45778. * @param callback defines the callback to use
  45779. */
  45780. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45781. /**
  45782. * Defines the callback to call when a button is released
  45783. * @param callback defines the callback to use
  45784. */
  45785. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45786. /**
  45787. * Defines the callback to call when a pad is pressed
  45788. * @param callback defines the callback to use
  45789. */
  45790. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45791. /**
  45792. * Defines the callback to call when a pad is released
  45793. * @param callback defines the callback to use
  45794. */
  45795. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45796. private _setButtonValue;
  45797. private _setDPadValue;
  45798. /**
  45799. * Gets the value of the `Cross` button
  45800. */
  45801. get buttonCross(): number;
  45802. /**
  45803. * Sets the value of the `Cross` button
  45804. */
  45805. set buttonCross(value: number);
  45806. /**
  45807. * Gets the value of the `Circle` button
  45808. */
  45809. get buttonCircle(): number;
  45810. /**
  45811. * Sets the value of the `Circle` button
  45812. */
  45813. set buttonCircle(value: number);
  45814. /**
  45815. * Gets the value of the `Square` button
  45816. */
  45817. get buttonSquare(): number;
  45818. /**
  45819. * Sets the value of the `Square` button
  45820. */
  45821. set buttonSquare(value: number);
  45822. /**
  45823. * Gets the value of the `Triangle` button
  45824. */
  45825. get buttonTriangle(): number;
  45826. /**
  45827. * Sets the value of the `Triangle` button
  45828. */
  45829. set buttonTriangle(value: number);
  45830. /**
  45831. * Gets the value of the `Options` button
  45832. */
  45833. get buttonOptions(): number;
  45834. /**
  45835. * Sets the value of the `Options` button
  45836. */
  45837. set buttonOptions(value: number);
  45838. /**
  45839. * Gets the value of the `Share` button
  45840. */
  45841. get buttonShare(): number;
  45842. /**
  45843. * Sets the value of the `Share` button
  45844. */
  45845. set buttonShare(value: number);
  45846. /**
  45847. * Gets the value of the `L1` button
  45848. */
  45849. get buttonL1(): number;
  45850. /**
  45851. * Sets the value of the `L1` button
  45852. */
  45853. set buttonL1(value: number);
  45854. /**
  45855. * Gets the value of the `R1` button
  45856. */
  45857. get buttonR1(): number;
  45858. /**
  45859. * Sets the value of the `R1` button
  45860. */
  45861. set buttonR1(value: number);
  45862. /**
  45863. * Gets the value of the Left joystick
  45864. */
  45865. get buttonLeftStick(): number;
  45866. /**
  45867. * Sets the value of the Left joystick
  45868. */
  45869. set buttonLeftStick(value: number);
  45870. /**
  45871. * Gets the value of the Right joystick
  45872. */
  45873. get buttonRightStick(): number;
  45874. /**
  45875. * Sets the value of the Right joystick
  45876. */
  45877. set buttonRightStick(value: number);
  45878. /**
  45879. * Gets the value of D-pad up
  45880. */
  45881. get dPadUp(): number;
  45882. /**
  45883. * Sets the value of D-pad up
  45884. */
  45885. set dPadUp(value: number);
  45886. /**
  45887. * Gets the value of D-pad down
  45888. */
  45889. get dPadDown(): number;
  45890. /**
  45891. * Sets the value of D-pad down
  45892. */
  45893. set dPadDown(value: number);
  45894. /**
  45895. * Gets the value of D-pad left
  45896. */
  45897. get dPadLeft(): number;
  45898. /**
  45899. * Sets the value of D-pad left
  45900. */
  45901. set dPadLeft(value: number);
  45902. /**
  45903. * Gets the value of D-pad right
  45904. */
  45905. get dPadRight(): number;
  45906. /**
  45907. * Sets the value of D-pad right
  45908. */
  45909. set dPadRight(value: number);
  45910. /**
  45911. * Force the gamepad to synchronize with device values
  45912. */
  45913. update(): void;
  45914. /**
  45915. * Disposes the gamepad
  45916. */
  45917. dispose(): void;
  45918. }
  45919. }
  45920. declare module BABYLON {
  45921. /**
  45922. * Manager for handling gamepads
  45923. */
  45924. export class GamepadManager {
  45925. private _scene?;
  45926. private _babylonGamepads;
  45927. private _oneGamepadConnected;
  45928. /** @hidden */
  45929. _isMonitoring: boolean;
  45930. private _gamepadEventSupported;
  45931. private _gamepadSupport?;
  45932. /**
  45933. * observable to be triggered when the gamepad controller has been connected
  45934. */
  45935. onGamepadConnectedObservable: Observable<Gamepad>;
  45936. /**
  45937. * observable to be triggered when the gamepad controller has been disconnected
  45938. */
  45939. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45940. private _onGamepadConnectedEvent;
  45941. private _onGamepadDisconnectedEvent;
  45942. /**
  45943. * Initializes the gamepad manager
  45944. * @param _scene BabylonJS scene
  45945. */
  45946. constructor(_scene?: Scene | undefined);
  45947. /**
  45948. * The gamepads in the game pad manager
  45949. */
  45950. get gamepads(): Gamepad[];
  45951. /**
  45952. * Get the gamepad controllers based on type
  45953. * @param type The type of gamepad controller
  45954. * @returns Nullable gamepad
  45955. */
  45956. getGamepadByType(type?: number): Nullable<Gamepad>;
  45957. /**
  45958. * Disposes the gamepad manager
  45959. */
  45960. dispose(): void;
  45961. private _addNewGamepad;
  45962. private _startMonitoringGamepads;
  45963. private _stopMonitoringGamepads;
  45964. /** @hidden */
  45965. _checkGamepadsStatus(): void;
  45966. private _updateGamepadObjects;
  45967. }
  45968. }
  45969. declare module BABYLON {
  45970. interface Scene {
  45971. /** @hidden */
  45972. _gamepadManager: Nullable<GamepadManager>;
  45973. /**
  45974. * Gets the gamepad manager associated with the scene
  45975. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45976. */
  45977. gamepadManager: GamepadManager;
  45978. }
  45979. /**
  45980. * Interface representing a free camera inputs manager
  45981. */
  45982. interface FreeCameraInputsManager {
  45983. /**
  45984. * Adds gamepad input support to the FreeCameraInputsManager.
  45985. * @returns the FreeCameraInputsManager
  45986. */
  45987. addGamepad(): FreeCameraInputsManager;
  45988. }
  45989. /**
  45990. * Interface representing an arc rotate camera inputs manager
  45991. */
  45992. interface ArcRotateCameraInputsManager {
  45993. /**
  45994. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45995. * @returns the camera inputs manager
  45996. */
  45997. addGamepad(): ArcRotateCameraInputsManager;
  45998. }
  45999. /**
  46000. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46001. */
  46002. export class GamepadSystemSceneComponent implements ISceneComponent {
  46003. /**
  46004. * The component name helpfull to identify the component in the list of scene components.
  46005. */
  46006. readonly name: string;
  46007. /**
  46008. * The scene the component belongs to.
  46009. */
  46010. scene: Scene;
  46011. /**
  46012. * Creates a new instance of the component for the given scene
  46013. * @param scene Defines the scene to register the component in
  46014. */
  46015. constructor(scene: Scene);
  46016. /**
  46017. * Registers the component in a given scene
  46018. */
  46019. register(): void;
  46020. /**
  46021. * Rebuilds the elements related to this component in case of
  46022. * context lost for instance.
  46023. */
  46024. rebuild(): void;
  46025. /**
  46026. * Disposes the component and the associated ressources
  46027. */
  46028. dispose(): void;
  46029. private _beforeCameraUpdate;
  46030. }
  46031. }
  46032. declare module BABYLON {
  46033. /**
  46034. * 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,
  46035. * which still works and will still be found in many Playgrounds.
  46036. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46037. */
  46038. export class UniversalCamera extends TouchCamera {
  46039. /**
  46040. * Defines the gamepad rotation sensiblity.
  46041. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46042. */
  46043. get gamepadAngularSensibility(): number;
  46044. set gamepadAngularSensibility(value: number);
  46045. /**
  46046. * Defines the gamepad move sensiblity.
  46047. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46048. */
  46049. get gamepadMoveSensibility(): number;
  46050. set gamepadMoveSensibility(value: number);
  46051. /**
  46052. * 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,
  46053. * which still works and will still be found in many Playgrounds.
  46054. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46055. * @param name Define the name of the camera in the scene
  46056. * @param position Define the start position of the camera in the scene
  46057. * @param scene Define the scene the camera belongs to
  46058. */
  46059. constructor(name: string, position: Vector3, scene: Scene);
  46060. /**
  46061. * Gets the current object class name.
  46062. * @return the class name
  46063. */
  46064. getClassName(): string;
  46065. }
  46066. }
  46067. declare module BABYLON {
  46068. /**
  46069. * This represents a FPS type of camera. This is only here for back compat purpose.
  46070. * Please use the UniversalCamera instead as both are identical.
  46071. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46072. */
  46073. export class GamepadCamera extends UniversalCamera {
  46074. /**
  46075. * Instantiates a new Gamepad Camera
  46076. * This represents a FPS type of camera. This is only here for back compat purpose.
  46077. * Please use the UniversalCamera instead as both are identical.
  46078. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46079. * @param name Define the name of the camera in the scene
  46080. * @param position Define the start position of the camera in the scene
  46081. * @param scene Define the scene the camera belongs to
  46082. */
  46083. constructor(name: string, position: Vector3, scene: Scene);
  46084. /**
  46085. * Gets the current object class name.
  46086. * @return the class name
  46087. */
  46088. getClassName(): string;
  46089. }
  46090. }
  46091. declare module BABYLON {
  46092. /** @hidden */
  46093. export var passPixelShader: {
  46094. name: string;
  46095. shader: string;
  46096. };
  46097. }
  46098. declare module BABYLON {
  46099. /** @hidden */
  46100. export var passCubePixelShader: {
  46101. name: string;
  46102. shader: string;
  46103. };
  46104. }
  46105. declare module BABYLON {
  46106. /**
  46107. * PassPostProcess which produces an output the same as it's input
  46108. */
  46109. export class PassPostProcess extends PostProcess {
  46110. /**
  46111. * Gets a string identifying the name of the class
  46112. * @returns "PassPostProcess" string
  46113. */
  46114. getClassName(): string;
  46115. /**
  46116. * Creates the PassPostProcess
  46117. * @param name The name of the effect.
  46118. * @param options The required width/height ratio to downsize to before computing the render pass.
  46119. * @param camera The camera to apply the render pass to.
  46120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46121. * @param engine The engine which the post process will be applied. (default: current engine)
  46122. * @param reusable If the post process can be reused on the same frame. (default: false)
  46123. * @param textureType The type of texture to be used when performing the post processing.
  46124. * @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)
  46125. */
  46126. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46127. /** @hidden */
  46128. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46129. }
  46130. /**
  46131. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46132. */
  46133. export class PassCubePostProcess extends PostProcess {
  46134. private _face;
  46135. /**
  46136. * Gets or sets the cube face to display.
  46137. * * 0 is +X
  46138. * * 1 is -X
  46139. * * 2 is +Y
  46140. * * 3 is -Y
  46141. * * 4 is +Z
  46142. * * 5 is -Z
  46143. */
  46144. get face(): number;
  46145. set face(value: number);
  46146. /**
  46147. * Gets a string identifying the name of the class
  46148. * @returns "PassCubePostProcess" string
  46149. */
  46150. getClassName(): string;
  46151. /**
  46152. * Creates the PassCubePostProcess
  46153. * @param name The name of the effect.
  46154. * @param options The required width/height ratio to downsize to before computing the render pass.
  46155. * @param camera The camera to apply the render pass to.
  46156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46157. * @param engine The engine which the post process will be applied. (default: current engine)
  46158. * @param reusable If the post process can be reused on the same frame. (default: false)
  46159. * @param textureType The type of texture to be used when performing the post processing.
  46160. * @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)
  46161. */
  46162. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46163. /** @hidden */
  46164. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46165. }
  46166. }
  46167. declare module BABYLON {
  46168. /** @hidden */
  46169. export var anaglyphPixelShader: {
  46170. name: string;
  46171. shader: string;
  46172. };
  46173. }
  46174. declare module BABYLON {
  46175. /**
  46176. * Postprocess used to generate anaglyphic rendering
  46177. */
  46178. export class AnaglyphPostProcess extends PostProcess {
  46179. private _passedProcess;
  46180. /**
  46181. * Gets a string identifying the name of the class
  46182. * @returns "AnaglyphPostProcess" string
  46183. */
  46184. getClassName(): string;
  46185. /**
  46186. * Creates a new AnaglyphPostProcess
  46187. * @param name defines postprocess name
  46188. * @param options defines creation options or target ratio scale
  46189. * @param rigCameras defines cameras using this postprocess
  46190. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46191. * @param engine defines hosting engine
  46192. * @param reusable defines if the postprocess will be reused multiple times per frame
  46193. */
  46194. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46195. }
  46196. }
  46197. declare module BABYLON {
  46198. /**
  46199. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46200. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46201. */
  46202. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46203. /**
  46204. * Creates a new AnaglyphArcRotateCamera
  46205. * @param name defines camera name
  46206. * @param alpha defines alpha angle (in radians)
  46207. * @param beta defines beta angle (in radians)
  46208. * @param radius defines radius
  46209. * @param target defines camera target
  46210. * @param interaxialDistance defines distance between each color axis
  46211. * @param scene defines the hosting scene
  46212. */
  46213. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46214. /**
  46215. * Gets camera class name
  46216. * @returns AnaglyphArcRotateCamera
  46217. */
  46218. getClassName(): string;
  46219. }
  46220. }
  46221. declare module BABYLON {
  46222. /**
  46223. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46224. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46225. */
  46226. export class AnaglyphFreeCamera extends FreeCamera {
  46227. /**
  46228. * Creates a new AnaglyphFreeCamera
  46229. * @param name defines camera name
  46230. * @param position defines initial position
  46231. * @param interaxialDistance defines distance between each color axis
  46232. * @param scene defines the hosting scene
  46233. */
  46234. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46235. /**
  46236. * Gets camera class name
  46237. * @returns AnaglyphFreeCamera
  46238. */
  46239. getClassName(): string;
  46240. }
  46241. }
  46242. declare module BABYLON {
  46243. /**
  46244. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46245. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46246. */
  46247. export class AnaglyphGamepadCamera extends GamepadCamera {
  46248. /**
  46249. * Creates a new AnaglyphGamepadCamera
  46250. * @param name defines camera name
  46251. * @param position defines initial position
  46252. * @param interaxialDistance defines distance between each color axis
  46253. * @param scene defines the hosting scene
  46254. */
  46255. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46256. /**
  46257. * Gets camera class name
  46258. * @returns AnaglyphGamepadCamera
  46259. */
  46260. getClassName(): string;
  46261. }
  46262. }
  46263. declare module BABYLON {
  46264. /**
  46265. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46266. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46267. */
  46268. export class AnaglyphUniversalCamera extends UniversalCamera {
  46269. /**
  46270. * Creates a new AnaglyphUniversalCamera
  46271. * @param name defines camera name
  46272. * @param position defines initial position
  46273. * @param interaxialDistance defines distance between each color axis
  46274. * @param scene defines the hosting scene
  46275. */
  46276. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46277. /**
  46278. * Gets camera class name
  46279. * @returns AnaglyphUniversalCamera
  46280. */
  46281. getClassName(): string;
  46282. }
  46283. }
  46284. declare module BABYLON {
  46285. /**
  46286. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46287. * @see https://doc.babylonjs.com/features/cameras
  46288. */
  46289. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46290. /**
  46291. * Creates a new StereoscopicArcRotateCamera
  46292. * @param name defines camera name
  46293. * @param alpha defines alpha angle (in radians)
  46294. * @param beta defines beta angle (in radians)
  46295. * @param radius defines radius
  46296. * @param target defines camera target
  46297. * @param interaxialDistance defines distance between each color axis
  46298. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46299. * @param scene defines the hosting scene
  46300. */
  46301. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46302. /**
  46303. * Gets camera class name
  46304. * @returns StereoscopicArcRotateCamera
  46305. */
  46306. getClassName(): string;
  46307. }
  46308. }
  46309. declare module BABYLON {
  46310. /**
  46311. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46312. * @see https://doc.babylonjs.com/features/cameras
  46313. */
  46314. export class StereoscopicFreeCamera extends FreeCamera {
  46315. /**
  46316. * Creates a new StereoscopicFreeCamera
  46317. * @param name defines camera name
  46318. * @param position defines initial position
  46319. * @param interaxialDistance defines distance between each color axis
  46320. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46321. * @param scene defines the hosting scene
  46322. */
  46323. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46324. /**
  46325. * Gets camera class name
  46326. * @returns StereoscopicFreeCamera
  46327. */
  46328. getClassName(): string;
  46329. }
  46330. }
  46331. declare module BABYLON {
  46332. /**
  46333. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46334. * @see https://doc.babylonjs.com/features/cameras
  46335. */
  46336. export class StereoscopicGamepadCamera extends GamepadCamera {
  46337. /**
  46338. * Creates a new StereoscopicGamepadCamera
  46339. * @param name defines camera name
  46340. * @param position defines initial position
  46341. * @param interaxialDistance defines distance between each color axis
  46342. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46343. * @param scene defines the hosting scene
  46344. */
  46345. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46346. /**
  46347. * Gets camera class name
  46348. * @returns StereoscopicGamepadCamera
  46349. */
  46350. getClassName(): string;
  46351. }
  46352. }
  46353. declare module BABYLON {
  46354. /**
  46355. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46356. * @see https://doc.babylonjs.com/features/cameras
  46357. */
  46358. export class StereoscopicUniversalCamera extends UniversalCamera {
  46359. /**
  46360. * Creates a new StereoscopicUniversalCamera
  46361. * @param name defines camera name
  46362. * @param position defines initial position
  46363. * @param interaxialDistance defines distance between each color axis
  46364. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46365. * @param scene defines the hosting scene
  46366. */
  46367. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46368. /**
  46369. * Gets camera class name
  46370. * @returns StereoscopicUniversalCamera
  46371. */
  46372. getClassName(): string;
  46373. }
  46374. }
  46375. declare module BABYLON {
  46376. /**
  46377. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46378. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46379. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46380. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46381. */
  46382. export class VirtualJoysticksCamera extends FreeCamera {
  46383. /**
  46384. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46385. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46386. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46387. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46388. * @param name Define the name of the camera in the scene
  46389. * @param position Define the start position of the camera in the scene
  46390. * @param scene Define the scene the camera belongs to
  46391. */
  46392. constructor(name: string, position: Vector3, scene: Scene);
  46393. /**
  46394. * Gets the current object class name.
  46395. * @return the class name
  46396. */
  46397. getClassName(): string;
  46398. }
  46399. }
  46400. declare module BABYLON {
  46401. /**
  46402. * This represents all the required metrics to create a VR camera.
  46403. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46404. */
  46405. export class VRCameraMetrics {
  46406. /**
  46407. * Define the horizontal resolution off the screen.
  46408. */
  46409. hResolution: number;
  46410. /**
  46411. * Define the vertical resolution off the screen.
  46412. */
  46413. vResolution: number;
  46414. /**
  46415. * Define the horizontal screen size.
  46416. */
  46417. hScreenSize: number;
  46418. /**
  46419. * Define the vertical screen size.
  46420. */
  46421. vScreenSize: number;
  46422. /**
  46423. * Define the vertical screen center position.
  46424. */
  46425. vScreenCenter: number;
  46426. /**
  46427. * Define the distance of the eyes to the screen.
  46428. */
  46429. eyeToScreenDistance: number;
  46430. /**
  46431. * Define the distance between both lenses
  46432. */
  46433. lensSeparationDistance: number;
  46434. /**
  46435. * Define the distance between both viewer's eyes.
  46436. */
  46437. interpupillaryDistance: number;
  46438. /**
  46439. * Define the distortion factor of the VR postprocess.
  46440. * Please, touch with care.
  46441. */
  46442. distortionK: number[];
  46443. /**
  46444. * Define the chromatic aberration correction factors for the VR post process.
  46445. */
  46446. chromaAbCorrection: number[];
  46447. /**
  46448. * Define the scale factor of the post process.
  46449. * The smaller the better but the slower.
  46450. */
  46451. postProcessScaleFactor: number;
  46452. /**
  46453. * Define an offset for the lens center.
  46454. */
  46455. lensCenterOffset: number;
  46456. /**
  46457. * Define if the current vr camera should compensate the distortion of the lense or not.
  46458. */
  46459. compensateDistortion: boolean;
  46460. /**
  46461. * Defines if multiview should be enabled when rendering (Default: false)
  46462. */
  46463. multiviewEnabled: boolean;
  46464. /**
  46465. * Gets the rendering aspect ratio based on the provided resolutions.
  46466. */
  46467. get aspectRatio(): number;
  46468. /**
  46469. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46470. */
  46471. get aspectRatioFov(): number;
  46472. /**
  46473. * @hidden
  46474. */
  46475. get leftHMatrix(): Matrix;
  46476. /**
  46477. * @hidden
  46478. */
  46479. get rightHMatrix(): Matrix;
  46480. /**
  46481. * @hidden
  46482. */
  46483. get leftPreViewMatrix(): Matrix;
  46484. /**
  46485. * @hidden
  46486. */
  46487. get rightPreViewMatrix(): Matrix;
  46488. /**
  46489. * Get the default VRMetrics based on the most generic setup.
  46490. * @returns the default vr metrics
  46491. */
  46492. static GetDefault(): VRCameraMetrics;
  46493. }
  46494. }
  46495. declare module BABYLON {
  46496. /** @hidden */
  46497. export var vrDistortionCorrectionPixelShader: {
  46498. name: string;
  46499. shader: string;
  46500. };
  46501. }
  46502. declare module BABYLON {
  46503. /**
  46504. * VRDistortionCorrectionPostProcess used for mobile VR
  46505. */
  46506. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46507. private _isRightEye;
  46508. private _distortionFactors;
  46509. private _postProcessScaleFactor;
  46510. private _lensCenterOffset;
  46511. private _scaleIn;
  46512. private _scaleFactor;
  46513. private _lensCenter;
  46514. /**
  46515. * Gets a string identifying the name of the class
  46516. * @returns "VRDistortionCorrectionPostProcess" string
  46517. */
  46518. getClassName(): string;
  46519. /**
  46520. * Initializes the VRDistortionCorrectionPostProcess
  46521. * @param name The name of the effect.
  46522. * @param camera The camera to apply the render pass to.
  46523. * @param isRightEye If this is for the right eye distortion
  46524. * @param vrMetrics All the required metrics for the VR camera
  46525. */
  46526. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46527. }
  46528. }
  46529. declare module BABYLON {
  46530. /**
  46531. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46532. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46533. */
  46534. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46535. /**
  46536. * Creates a new VRDeviceOrientationArcRotateCamera
  46537. * @param name defines camera name
  46538. * @param alpha defines the camera rotation along the logitudinal axis
  46539. * @param beta defines the camera rotation along the latitudinal axis
  46540. * @param radius defines the camera distance from its target
  46541. * @param target defines the camera target
  46542. * @param scene defines the scene the camera belongs to
  46543. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46544. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46545. */
  46546. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46547. /**
  46548. * Gets camera class name
  46549. * @returns VRDeviceOrientationArcRotateCamera
  46550. */
  46551. getClassName(): string;
  46552. }
  46553. }
  46554. declare module BABYLON {
  46555. /**
  46556. * Camera used to simulate VR rendering (based on FreeCamera)
  46557. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46558. */
  46559. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46560. /**
  46561. * Creates a new VRDeviceOrientationFreeCamera
  46562. * @param name defines camera name
  46563. * @param position defines the start position of the camera
  46564. * @param scene defines the scene the camera belongs to
  46565. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46566. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46567. */
  46568. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46569. /**
  46570. * Gets camera class name
  46571. * @returns VRDeviceOrientationFreeCamera
  46572. */
  46573. getClassName(): string;
  46574. }
  46575. }
  46576. declare module BABYLON {
  46577. /**
  46578. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46579. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46580. */
  46581. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46582. /**
  46583. * Creates a new VRDeviceOrientationGamepadCamera
  46584. * @param name defines camera name
  46585. * @param position defines the start position of the camera
  46586. * @param scene defines the scene the camera belongs to
  46587. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46588. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46589. */
  46590. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46591. /**
  46592. * Gets camera class name
  46593. * @returns VRDeviceOrientationGamepadCamera
  46594. */
  46595. getClassName(): string;
  46596. }
  46597. }
  46598. declare module BABYLON {
  46599. /**
  46600. * A class extending Texture allowing drawing on a texture
  46601. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46602. */
  46603. export class DynamicTexture extends Texture {
  46604. private _generateMipMaps;
  46605. private _canvas;
  46606. private _context;
  46607. /**
  46608. * Creates a DynamicTexture
  46609. * @param name defines the name of the texture
  46610. * @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
  46611. * @param scene defines the scene where you want the texture
  46612. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46613. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46614. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46615. */
  46616. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46617. /**
  46618. * Get the current class name of the texture useful for serialization or dynamic coding.
  46619. * @returns "DynamicTexture"
  46620. */
  46621. getClassName(): string;
  46622. /**
  46623. * Gets the current state of canRescale
  46624. */
  46625. get canRescale(): boolean;
  46626. private _recreate;
  46627. /**
  46628. * Scales the texture
  46629. * @param ratio the scale factor to apply to both width and height
  46630. */
  46631. scale(ratio: number): void;
  46632. /**
  46633. * Resizes the texture
  46634. * @param width the new width
  46635. * @param height the new height
  46636. */
  46637. scaleTo(width: number, height: number): void;
  46638. /**
  46639. * Gets the context of the canvas used by the texture
  46640. * @returns the canvas context of the dynamic texture
  46641. */
  46642. getContext(): CanvasRenderingContext2D;
  46643. /**
  46644. * Clears the texture
  46645. */
  46646. clear(): void;
  46647. /**
  46648. * Updates the texture
  46649. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46650. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46651. */
  46652. update(invertY?: boolean, premulAlpha?: boolean): void;
  46653. /**
  46654. * Draws text onto the texture
  46655. * @param text defines the text to be drawn
  46656. * @param x defines the placement of the text from the left
  46657. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46658. * @param font defines the font to be used with font-style, font-size, font-name
  46659. * @param color defines the color used for the text
  46660. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46661. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46662. * @param update defines whether texture is immediately update (default is true)
  46663. */
  46664. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46665. /**
  46666. * Clones the texture
  46667. * @returns the clone of the texture.
  46668. */
  46669. clone(): DynamicTexture;
  46670. /**
  46671. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46672. * @returns a serialized dynamic texture object
  46673. */
  46674. serialize(): any;
  46675. private _IsCanvasElement;
  46676. /** @hidden */
  46677. _rebuild(): void;
  46678. }
  46679. }
  46680. declare module BABYLON {
  46681. /**
  46682. * Class containing static functions to help procedurally build meshes
  46683. */
  46684. export class GroundBuilder {
  46685. /**
  46686. * Creates a ground mesh
  46687. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46688. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46690. * @param name defines the name of the mesh
  46691. * @param options defines the options used to create the mesh
  46692. * @param scene defines the hosting scene
  46693. * @returns the ground mesh
  46694. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46695. */
  46696. static CreateGround(name: string, options: {
  46697. width?: number;
  46698. height?: number;
  46699. subdivisions?: number;
  46700. subdivisionsX?: number;
  46701. subdivisionsY?: number;
  46702. updatable?: boolean;
  46703. }, scene: any): Mesh;
  46704. /**
  46705. * Creates a tiled ground mesh
  46706. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46707. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46708. * * 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
  46709. * * 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
  46710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46711. * @param name defines the name of the mesh
  46712. * @param options defines the options used to create the mesh
  46713. * @param scene defines the hosting scene
  46714. * @returns the tiled ground mesh
  46715. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46716. */
  46717. static CreateTiledGround(name: string, options: {
  46718. xmin: number;
  46719. zmin: number;
  46720. xmax: number;
  46721. zmax: number;
  46722. subdivisions?: {
  46723. w: number;
  46724. h: number;
  46725. };
  46726. precision?: {
  46727. w: number;
  46728. h: number;
  46729. };
  46730. updatable?: boolean;
  46731. }, scene?: Nullable<Scene>): Mesh;
  46732. /**
  46733. * Creates a ground mesh from a height map
  46734. * * The parameter `url` sets the URL of the height map image resource.
  46735. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46736. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46737. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46738. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46739. * * 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.
  46740. * * 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).
  46741. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46743. * @param name defines the name of the mesh
  46744. * @param url defines the url to the height map
  46745. * @param options defines the options used to create the mesh
  46746. * @param scene defines the hosting scene
  46747. * @returns the ground mesh
  46748. * @see https://doc.babylonjs.com/babylon101/height_map
  46749. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46750. */
  46751. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46752. width?: number;
  46753. height?: number;
  46754. subdivisions?: number;
  46755. minHeight?: number;
  46756. maxHeight?: number;
  46757. colorFilter?: Color3;
  46758. alphaFilter?: number;
  46759. updatable?: boolean;
  46760. onReady?: (mesh: GroundMesh) => void;
  46761. }, scene?: Nullable<Scene>): GroundMesh;
  46762. }
  46763. }
  46764. declare module BABYLON {
  46765. /**
  46766. * Class containing static functions to help procedurally build meshes
  46767. */
  46768. export class TorusBuilder {
  46769. /**
  46770. * Creates a torus mesh
  46771. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46772. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46773. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46775. * * 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
  46776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46777. * @param name defines the name of the mesh
  46778. * @param options defines the options used to create the mesh
  46779. * @param scene defines the hosting scene
  46780. * @returns the torus mesh
  46781. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46782. */
  46783. static CreateTorus(name: string, options: {
  46784. diameter?: number;
  46785. thickness?: number;
  46786. tessellation?: number;
  46787. updatable?: boolean;
  46788. sideOrientation?: number;
  46789. frontUVs?: Vector4;
  46790. backUVs?: Vector4;
  46791. }, scene: any): Mesh;
  46792. }
  46793. }
  46794. declare module BABYLON {
  46795. /**
  46796. * Class containing static functions to help procedurally build meshes
  46797. */
  46798. export class CylinderBuilder {
  46799. /**
  46800. * Creates a cylinder or a cone mesh
  46801. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46802. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46803. * * 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.
  46804. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46805. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46806. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46807. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46808. * * 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).
  46809. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46810. * * 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).
  46811. * * 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
  46812. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46813. * * 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
  46814. * * 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.
  46815. * * If `enclose` is false, a ring surface is one element.
  46816. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46817. * * 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
  46818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46819. * * 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
  46820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46821. * @param name defines the name of the mesh
  46822. * @param options defines the options used to create the mesh
  46823. * @param scene defines the hosting scene
  46824. * @returns the cylinder mesh
  46825. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46826. */
  46827. static CreateCylinder(name: string, options: {
  46828. height?: number;
  46829. diameterTop?: number;
  46830. diameterBottom?: number;
  46831. diameter?: number;
  46832. tessellation?: number;
  46833. subdivisions?: number;
  46834. arc?: number;
  46835. faceColors?: Color4[];
  46836. faceUV?: Vector4[];
  46837. updatable?: boolean;
  46838. hasRings?: boolean;
  46839. enclose?: boolean;
  46840. cap?: number;
  46841. sideOrientation?: number;
  46842. frontUVs?: Vector4;
  46843. backUVs?: Vector4;
  46844. }, scene: any): Mesh;
  46845. }
  46846. }
  46847. declare module BABYLON {
  46848. /**
  46849. * States of the webXR experience
  46850. */
  46851. export enum WebXRState {
  46852. /**
  46853. * Transitioning to being in XR mode
  46854. */
  46855. ENTERING_XR = 0,
  46856. /**
  46857. * Transitioning to non XR mode
  46858. */
  46859. EXITING_XR = 1,
  46860. /**
  46861. * In XR mode and presenting
  46862. */
  46863. IN_XR = 2,
  46864. /**
  46865. * Not entered XR mode
  46866. */
  46867. NOT_IN_XR = 3
  46868. }
  46869. /**
  46870. * Abstraction of the XR render target
  46871. */
  46872. export interface WebXRRenderTarget extends IDisposable {
  46873. /**
  46874. * xrpresent context of the canvas which can be used to display/mirror xr content
  46875. */
  46876. canvasContext: WebGLRenderingContext;
  46877. /**
  46878. * xr layer for the canvas
  46879. */
  46880. xrLayer: Nullable<XRWebGLLayer>;
  46881. /**
  46882. * Initializes the xr layer for the session
  46883. * @param xrSession xr session
  46884. * @returns a promise that will resolve once the XR Layer has been created
  46885. */
  46886. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46887. }
  46888. }
  46889. declare module BABYLON {
  46890. /**
  46891. * COnfiguration object for WebXR output canvas
  46892. */
  46893. export class WebXRManagedOutputCanvasOptions {
  46894. /**
  46895. * An optional canvas in case you wish to create it yourself and provide it here.
  46896. * If not provided, a new canvas will be created
  46897. */
  46898. canvasElement?: HTMLCanvasElement;
  46899. /**
  46900. * Options for this XR Layer output
  46901. */
  46902. canvasOptions?: XRWebGLLayerOptions;
  46903. /**
  46904. * CSS styling for a newly created canvas (if not provided)
  46905. */
  46906. newCanvasCssStyle?: string;
  46907. /**
  46908. * Get the default values of the configuration object
  46909. * @param engine defines the engine to use (can be null)
  46910. * @returns default values of this configuration object
  46911. */
  46912. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46913. }
  46914. /**
  46915. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46916. */
  46917. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46918. private _options;
  46919. private _canvas;
  46920. private _engine;
  46921. private _originalCanvasSize;
  46922. /**
  46923. * Rendering context of the canvas which can be used to display/mirror xr content
  46924. */
  46925. canvasContext: WebGLRenderingContext;
  46926. /**
  46927. * xr layer for the canvas
  46928. */
  46929. xrLayer: Nullable<XRWebGLLayer>;
  46930. /**
  46931. * Obseervers registered here will be triggered when the xr layer was initialized
  46932. */
  46933. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46934. /**
  46935. * Initializes the canvas to be added/removed upon entering/exiting xr
  46936. * @param _xrSessionManager The XR Session manager
  46937. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46938. */
  46939. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46940. /**
  46941. * Disposes of the object
  46942. */
  46943. dispose(): void;
  46944. /**
  46945. * Initializes the xr layer for the session
  46946. * @param xrSession xr session
  46947. * @returns a promise that will resolve once the XR Layer has been created
  46948. */
  46949. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46950. private _addCanvas;
  46951. private _removeCanvas;
  46952. private _setCanvasSize;
  46953. private _setManagedOutputCanvas;
  46954. }
  46955. }
  46956. declare module BABYLON {
  46957. /**
  46958. * Manages an XRSession to work with Babylon's engine
  46959. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46960. */
  46961. export class WebXRSessionManager implements IDisposable {
  46962. /** The scene which the session should be created for */
  46963. scene: Scene;
  46964. private _referenceSpace;
  46965. private _rttProvider;
  46966. private _sessionEnded;
  46967. private _xrNavigator;
  46968. private baseLayer;
  46969. /**
  46970. * The base reference space from which the session started. good if you want to reset your
  46971. * reference space
  46972. */
  46973. baseReferenceSpace: XRReferenceSpace;
  46974. /**
  46975. * Current XR frame
  46976. */
  46977. currentFrame: Nullable<XRFrame>;
  46978. /** WebXR timestamp updated every frame */
  46979. currentTimestamp: number;
  46980. /**
  46981. * Used just in case of a failure to initialize an immersive session.
  46982. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46983. */
  46984. defaultHeightCompensation: number;
  46985. /**
  46986. * Fires every time a new xrFrame arrives which can be used to update the camera
  46987. */
  46988. onXRFrameObservable: Observable<XRFrame>;
  46989. /**
  46990. * Fires when the reference space changed
  46991. */
  46992. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46993. /**
  46994. * Fires when the xr session is ended either by the device or manually done
  46995. */
  46996. onXRSessionEnded: Observable<any>;
  46997. /**
  46998. * Fires when the xr session is ended either by the device or manually done
  46999. */
  47000. onXRSessionInit: Observable<XRSession>;
  47001. /**
  47002. * Underlying xr session
  47003. */
  47004. session: XRSession;
  47005. /**
  47006. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47007. * or get the offset the player is currently at.
  47008. */
  47009. viewerReferenceSpace: XRReferenceSpace;
  47010. /**
  47011. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47012. * @param scene The scene which the session should be created for
  47013. */
  47014. constructor(
  47015. /** The scene which the session should be created for */
  47016. scene: Scene);
  47017. /**
  47018. * The current reference space used in this session. This reference space can constantly change!
  47019. * It is mainly used to offset the camera's position.
  47020. */
  47021. get referenceSpace(): XRReferenceSpace;
  47022. /**
  47023. * Set a new reference space and triggers the observable
  47024. */
  47025. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47026. /**
  47027. * Disposes of the session manager
  47028. */
  47029. dispose(): void;
  47030. /**
  47031. * Stops the xrSession and restores the render loop
  47032. * @returns Promise which resolves after it exits XR
  47033. */
  47034. exitXRAsync(): Promise<void>;
  47035. /**
  47036. * Gets the correct render target texture to be rendered this frame for this eye
  47037. * @param eye the eye for which to get the render target
  47038. * @returns the render target for the specified eye
  47039. */
  47040. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47041. /**
  47042. * Creates a WebXRRenderTarget object for the XR session
  47043. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47044. * @param options optional options to provide when creating a new render target
  47045. * @returns a WebXR render target to which the session can render
  47046. */
  47047. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47048. /**
  47049. * Initializes the manager
  47050. * After initialization enterXR can be called to start an XR session
  47051. * @returns Promise which resolves after it is initialized
  47052. */
  47053. initializeAsync(): Promise<void>;
  47054. /**
  47055. * Initializes an xr session
  47056. * @param xrSessionMode mode to initialize
  47057. * @param xrSessionInit defines optional and required values to pass to the session builder
  47058. * @returns a promise which will resolve once the session has been initialized
  47059. */
  47060. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47061. /**
  47062. * Checks if a session would be supported for the creation options specified
  47063. * @param sessionMode session mode to check if supported eg. immersive-vr
  47064. * @returns A Promise that resolves to true if supported and false if not
  47065. */
  47066. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47067. /**
  47068. * Resets the reference space to the one started the session
  47069. */
  47070. resetReferenceSpace(): void;
  47071. /**
  47072. * Starts rendering to the xr layer
  47073. */
  47074. runXRRenderLoop(): void;
  47075. /**
  47076. * Sets the reference space on the xr session
  47077. * @param referenceSpaceType space to set
  47078. * @returns a promise that will resolve once the reference space has been set
  47079. */
  47080. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47081. /**
  47082. * Updates the render state of the session
  47083. * @param state state to set
  47084. * @returns a promise that resolves once the render state has been updated
  47085. */
  47086. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47087. /**
  47088. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47089. * @param sessionMode defines the session to test
  47090. * @returns a promise with boolean as final value
  47091. */
  47092. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47093. private _createRenderTargetTexture;
  47094. }
  47095. }
  47096. declare module BABYLON {
  47097. /**
  47098. * WebXR Camera which holds the views for the xrSession
  47099. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47100. */
  47101. export class WebXRCamera extends FreeCamera {
  47102. private _xrSessionManager;
  47103. private _firstFrame;
  47104. private _referenceQuaternion;
  47105. private _referencedPosition;
  47106. private _xrInvPositionCache;
  47107. private _xrInvQuaternionCache;
  47108. /**
  47109. * Observable raised before camera teleportation
  47110. */
  47111. onBeforeCameraTeleport: Observable<Vector3>;
  47112. /**
  47113. * Observable raised after camera teleportation
  47114. */
  47115. onAfterCameraTeleport: Observable<Vector3>;
  47116. /**
  47117. * Should position compensation execute on first frame.
  47118. * This is used when copying the position from a native (non XR) camera
  47119. */
  47120. compensateOnFirstFrame: boolean;
  47121. /**
  47122. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47123. * @param name the name of the camera
  47124. * @param scene the scene to add the camera to
  47125. * @param _xrSessionManager a constructed xr session manager
  47126. */
  47127. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47128. /**
  47129. * Return the user's height, unrelated to the current ground.
  47130. * This will be the y position of this camera, when ground level is 0.
  47131. */
  47132. get realWorldHeight(): number;
  47133. /** @hidden */
  47134. _updateForDualEyeDebugging(): void;
  47135. /**
  47136. * Sets this camera's transformation based on a non-vr camera
  47137. * @param otherCamera the non-vr camera to copy the transformation from
  47138. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47139. */
  47140. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47141. /**
  47142. * Gets the current instance class name ("WebXRCamera").
  47143. * @returns the class name
  47144. */
  47145. getClassName(): string;
  47146. private _rotate180;
  47147. private _updateFromXRSession;
  47148. private _updateNumberOfRigCameras;
  47149. private _updateReferenceSpace;
  47150. private _updateReferenceSpaceOffset;
  47151. }
  47152. }
  47153. declare module BABYLON {
  47154. /**
  47155. * Defining the interface required for a (webxr) feature
  47156. */
  47157. export interface IWebXRFeature extends IDisposable {
  47158. /**
  47159. * Is this feature attached
  47160. */
  47161. attached: boolean;
  47162. /**
  47163. * Should auto-attach be disabled?
  47164. */
  47165. disableAutoAttach: boolean;
  47166. /**
  47167. * Attach the feature to the session
  47168. * Will usually be called by the features manager
  47169. *
  47170. * @param force should attachment be forced (even when already attached)
  47171. * @returns true if successful.
  47172. */
  47173. attach(force?: boolean): boolean;
  47174. /**
  47175. * Detach the feature from the session
  47176. * Will usually be called by the features manager
  47177. *
  47178. * @returns true if successful.
  47179. */
  47180. detach(): boolean;
  47181. /**
  47182. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47183. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47184. *
  47185. * @returns whether or not the feature is compatible in this environment
  47186. */
  47187. isCompatible(): boolean;
  47188. /**
  47189. * Was this feature disposed;
  47190. */
  47191. isDisposed: boolean;
  47192. /**
  47193. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47194. */
  47195. xrNativeFeatureName?: string;
  47196. /**
  47197. * A list of (Babylon WebXR) features this feature depends on
  47198. */
  47199. dependsOn?: string[];
  47200. }
  47201. /**
  47202. * A list of the currently available features without referencing them
  47203. */
  47204. export class WebXRFeatureName {
  47205. /**
  47206. * The name of the anchor system feature
  47207. */
  47208. static readonly ANCHOR_SYSTEM: string;
  47209. /**
  47210. * The name of the background remover feature
  47211. */
  47212. static readonly BACKGROUND_REMOVER: string;
  47213. /**
  47214. * The name of the hit test feature
  47215. */
  47216. static readonly HIT_TEST: string;
  47217. /**
  47218. * physics impostors for xr controllers feature
  47219. */
  47220. static readonly PHYSICS_CONTROLLERS: string;
  47221. /**
  47222. * The name of the plane detection feature
  47223. */
  47224. static readonly PLANE_DETECTION: string;
  47225. /**
  47226. * The name of the pointer selection feature
  47227. */
  47228. static readonly POINTER_SELECTION: string;
  47229. /**
  47230. * The name of the teleportation feature
  47231. */
  47232. static readonly TELEPORTATION: string;
  47233. /**
  47234. * The name of the feature points feature.
  47235. */
  47236. static readonly FEATURE_POINTS: string;
  47237. /**
  47238. * The name of the hand tracking feature.
  47239. */
  47240. static readonly HAND_TRACKING: string;
  47241. }
  47242. /**
  47243. * Defining the constructor of a feature. Used to register the modules.
  47244. */
  47245. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47246. /**
  47247. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47248. * It is mainly used in AR sessions.
  47249. *
  47250. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47251. */
  47252. export class WebXRFeaturesManager implements IDisposable {
  47253. private _xrSessionManager;
  47254. private static readonly _AvailableFeatures;
  47255. private _features;
  47256. /**
  47257. * constructs a new features manages.
  47258. *
  47259. * @param _xrSessionManager an instance of WebXRSessionManager
  47260. */
  47261. constructor(_xrSessionManager: WebXRSessionManager);
  47262. /**
  47263. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47264. * Mainly used internally.
  47265. *
  47266. * @param featureName the name of the feature to register
  47267. * @param constructorFunction the function used to construct the module
  47268. * @param version the (babylon) version of the module
  47269. * @param stable is that a stable version of this module
  47270. */
  47271. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47272. /**
  47273. * Returns a constructor of a specific feature.
  47274. *
  47275. * @param featureName the name of the feature to construct
  47276. * @param version the version of the feature to load
  47277. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47278. * @param options optional options provided to the module.
  47279. * @returns a function that, when called, will return a new instance of this feature
  47280. */
  47281. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47282. /**
  47283. * Can be used to return the list of features currently registered
  47284. *
  47285. * @returns an Array of available features
  47286. */
  47287. static GetAvailableFeatures(): string[];
  47288. /**
  47289. * Gets the versions available for a specific feature
  47290. * @param featureName the name of the feature
  47291. * @returns an array with the available versions
  47292. */
  47293. static GetAvailableVersions(featureName: string): string[];
  47294. /**
  47295. * Return the latest unstable version of this feature
  47296. * @param featureName the name of the feature to search
  47297. * @returns the version number. if not found will return -1
  47298. */
  47299. static GetLatestVersionOfFeature(featureName: string): number;
  47300. /**
  47301. * Return the latest stable version of this feature
  47302. * @param featureName the name of the feature to search
  47303. * @returns the version number. if not found will return -1
  47304. */
  47305. static GetStableVersionOfFeature(featureName: string): number;
  47306. /**
  47307. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47308. * Can be used during a session to start a feature
  47309. * @param featureName the name of feature to attach
  47310. */
  47311. attachFeature(featureName: string): void;
  47312. /**
  47313. * Can be used inside a session or when the session ends to detach a specific feature
  47314. * @param featureName the name of the feature to detach
  47315. */
  47316. detachFeature(featureName: string): void;
  47317. /**
  47318. * Used to disable an already-enabled feature
  47319. * The feature will be disposed and will be recreated once enabled.
  47320. * @param featureName the feature to disable
  47321. * @returns true if disable was successful
  47322. */
  47323. disableFeature(featureName: string | {
  47324. Name: string;
  47325. }): boolean;
  47326. /**
  47327. * dispose this features manager
  47328. */
  47329. dispose(): void;
  47330. /**
  47331. * 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.
  47332. * 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.
  47333. *
  47334. * @param featureName the name of the feature to load or the class of the feature
  47335. * @param version optional version to load. if not provided the latest version will be enabled
  47336. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47337. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47338. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47339. * @returns a new constructed feature or throws an error if feature not found.
  47340. */
  47341. enableFeature(featureName: string | {
  47342. Name: string;
  47343. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47344. /**
  47345. * get the implementation of an enabled feature.
  47346. * @param featureName the name of the feature to load
  47347. * @returns the feature class, if found
  47348. */
  47349. getEnabledFeature(featureName: string): IWebXRFeature;
  47350. /**
  47351. * Get the list of enabled features
  47352. * @returns an array of enabled features
  47353. */
  47354. getEnabledFeatures(): string[];
  47355. /**
  47356. * This function will exten the session creation configuration object with enabled features.
  47357. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47358. * according to the defined "required" variable, provided during enableFeature call
  47359. * @param xrSessionInit the xr Session init object to extend
  47360. *
  47361. * @returns an extended XRSessionInit object
  47362. */
  47363. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47364. }
  47365. }
  47366. declare module BABYLON {
  47367. /**
  47368. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47369. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47370. */
  47371. export class WebXRExperienceHelper implements IDisposable {
  47372. private scene;
  47373. private _nonVRCamera;
  47374. private _originalSceneAutoClear;
  47375. private _supported;
  47376. /**
  47377. * Camera used to render xr content
  47378. */
  47379. camera: WebXRCamera;
  47380. /** A features manager for this xr session */
  47381. featuresManager: WebXRFeaturesManager;
  47382. /**
  47383. * Observers registered here will be triggered after the camera's initial transformation is set
  47384. * This can be used to set a different ground level or an extra rotation.
  47385. *
  47386. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47387. * to the position set after this observable is done executing.
  47388. */
  47389. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47390. /**
  47391. * Fires when the state of the experience helper has changed
  47392. */
  47393. onStateChangedObservable: Observable<WebXRState>;
  47394. /** Session manager used to keep track of xr session */
  47395. sessionManager: WebXRSessionManager;
  47396. /**
  47397. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47398. */
  47399. state: WebXRState;
  47400. /**
  47401. * Creates a WebXRExperienceHelper
  47402. * @param scene The scene the helper should be created in
  47403. */
  47404. private constructor();
  47405. /**
  47406. * Creates the experience helper
  47407. * @param scene the scene to attach the experience helper to
  47408. * @returns a promise for the experience helper
  47409. */
  47410. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47411. /**
  47412. * Disposes of the experience helper
  47413. */
  47414. dispose(): void;
  47415. /**
  47416. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47417. * @param sessionMode options for the XR session
  47418. * @param referenceSpaceType frame of reference of the XR session
  47419. * @param renderTarget the output canvas that will be used to enter XR mode
  47420. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47421. * @returns promise that resolves after xr mode has entered
  47422. */
  47423. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47424. /**
  47425. * Exits XR mode and returns the scene to its original state
  47426. * @returns promise that resolves after xr mode has exited
  47427. */
  47428. exitXRAsync(): Promise<void>;
  47429. private _nonXRToXRCamera;
  47430. private _setState;
  47431. }
  47432. }
  47433. declare module BABYLON {
  47434. /**
  47435. * X-Y values for axes in WebXR
  47436. */
  47437. export interface IWebXRMotionControllerAxesValue {
  47438. /**
  47439. * The value of the x axis
  47440. */
  47441. x: number;
  47442. /**
  47443. * The value of the y-axis
  47444. */
  47445. y: number;
  47446. }
  47447. /**
  47448. * changed / previous values for the values of this component
  47449. */
  47450. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47451. /**
  47452. * current (this frame) value
  47453. */
  47454. current: T;
  47455. /**
  47456. * previous (last change) value
  47457. */
  47458. previous: T;
  47459. }
  47460. /**
  47461. * Represents changes in the component between current frame and last values recorded
  47462. */
  47463. export interface IWebXRMotionControllerComponentChanges {
  47464. /**
  47465. * will be populated with previous and current values if axes changed
  47466. */
  47467. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47468. /**
  47469. * will be populated with previous and current values if pressed changed
  47470. */
  47471. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47472. /**
  47473. * will be populated with previous and current values if touched changed
  47474. */
  47475. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47476. /**
  47477. * will be populated with previous and current values if value changed
  47478. */
  47479. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47480. }
  47481. /**
  47482. * This class represents a single component (for example button or thumbstick) of a motion controller
  47483. */
  47484. export class WebXRControllerComponent implements IDisposable {
  47485. /**
  47486. * the id of this component
  47487. */
  47488. id: string;
  47489. /**
  47490. * the type of the component
  47491. */
  47492. type: MotionControllerComponentType;
  47493. private _buttonIndex;
  47494. private _axesIndices;
  47495. private _axes;
  47496. private _changes;
  47497. private _currentValue;
  47498. private _hasChanges;
  47499. private _pressed;
  47500. private _touched;
  47501. /**
  47502. * button component type
  47503. */
  47504. static BUTTON_TYPE: MotionControllerComponentType;
  47505. /**
  47506. * squeeze component type
  47507. */
  47508. static SQUEEZE_TYPE: MotionControllerComponentType;
  47509. /**
  47510. * Thumbstick component type
  47511. */
  47512. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47513. /**
  47514. * Touchpad component type
  47515. */
  47516. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47517. /**
  47518. * trigger component type
  47519. */
  47520. static TRIGGER_TYPE: MotionControllerComponentType;
  47521. /**
  47522. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47523. * the axes data changes
  47524. */
  47525. onAxisValueChangedObservable: Observable<{
  47526. x: number;
  47527. y: number;
  47528. }>;
  47529. /**
  47530. * Observers registered here will be triggered when the state of a button changes
  47531. * State change is either pressed / touched / value
  47532. */
  47533. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47534. /**
  47535. * Creates a new component for a motion controller.
  47536. * It is created by the motion controller itself
  47537. *
  47538. * @param id the id of this component
  47539. * @param type the type of the component
  47540. * @param _buttonIndex index in the buttons array of the gamepad
  47541. * @param _axesIndices indices of the values in the axes array of the gamepad
  47542. */
  47543. constructor(
  47544. /**
  47545. * the id of this component
  47546. */
  47547. id: string,
  47548. /**
  47549. * the type of the component
  47550. */
  47551. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47552. /**
  47553. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47554. */
  47555. get axes(): IWebXRMotionControllerAxesValue;
  47556. /**
  47557. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47558. */
  47559. get changes(): IWebXRMotionControllerComponentChanges;
  47560. /**
  47561. * Return whether or not the component changed the last frame
  47562. */
  47563. get hasChanges(): boolean;
  47564. /**
  47565. * is the button currently pressed
  47566. */
  47567. get pressed(): boolean;
  47568. /**
  47569. * is the button currently touched
  47570. */
  47571. get touched(): boolean;
  47572. /**
  47573. * Get the current value of this component
  47574. */
  47575. get value(): number;
  47576. /**
  47577. * Dispose this component
  47578. */
  47579. dispose(): void;
  47580. /**
  47581. * Are there axes correlating to this component
  47582. * @return true is axes data is available
  47583. */
  47584. isAxes(): boolean;
  47585. /**
  47586. * Is this component a button (hence - pressable)
  47587. * @returns true if can be pressed
  47588. */
  47589. isButton(): boolean;
  47590. /**
  47591. * update this component using the gamepad object it is in. Called on every frame
  47592. * @param nativeController the native gamepad controller object
  47593. */
  47594. update(nativeController: IMinimalMotionControllerObject): void;
  47595. }
  47596. }
  47597. declare module BABYLON {
  47598. /**
  47599. * Interface used to represent data loading progression
  47600. */
  47601. export interface ISceneLoaderProgressEvent {
  47602. /**
  47603. * Defines if data length to load can be evaluated
  47604. */
  47605. readonly lengthComputable: boolean;
  47606. /**
  47607. * Defines the loaded data length
  47608. */
  47609. readonly loaded: number;
  47610. /**
  47611. * Defines the data length to load
  47612. */
  47613. readonly total: number;
  47614. }
  47615. /**
  47616. * Interface used by SceneLoader plugins to define supported file extensions
  47617. */
  47618. export interface ISceneLoaderPluginExtensions {
  47619. /**
  47620. * Defines the list of supported extensions
  47621. */
  47622. [extension: string]: {
  47623. isBinary: boolean;
  47624. };
  47625. }
  47626. /**
  47627. * Interface used by SceneLoader plugin factory
  47628. */
  47629. export interface ISceneLoaderPluginFactory {
  47630. /**
  47631. * Defines the name of the factory
  47632. */
  47633. name: string;
  47634. /**
  47635. * Function called to create a new plugin
  47636. * @return the new plugin
  47637. */
  47638. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47639. /**
  47640. * The callback that returns true if the data can be directly loaded.
  47641. * @param data string containing the file data
  47642. * @returns if the data can be loaded directly
  47643. */
  47644. canDirectLoad?(data: string): boolean;
  47645. }
  47646. /**
  47647. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47648. */
  47649. export interface ISceneLoaderPluginBase {
  47650. /**
  47651. * The friendly name of this plugin.
  47652. */
  47653. name: string;
  47654. /**
  47655. * The file extensions supported by this plugin.
  47656. */
  47657. extensions: string | ISceneLoaderPluginExtensions;
  47658. /**
  47659. * The callback called when loading from a url.
  47660. * @param scene scene loading this url
  47661. * @param url url to load
  47662. * @param onSuccess callback called when the file successfully loads
  47663. * @param onProgress callback called while file is loading (if the server supports this mode)
  47664. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47665. * @param onError callback called when the file fails to load
  47666. * @returns a file request object
  47667. */
  47668. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47669. /**
  47670. * The callback called when loading from a file object.
  47671. * @param scene scene loading this file
  47672. * @param file defines the file to load
  47673. * @param onSuccess defines the callback to call when data is loaded
  47674. * @param onProgress defines the callback to call during loading process
  47675. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47676. * @param onError defines the callback to call when an error occurs
  47677. * @returns a file request object
  47678. */
  47679. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47680. /**
  47681. * The callback that returns true if the data can be directly loaded.
  47682. * @param data string containing the file data
  47683. * @returns if the data can be loaded directly
  47684. */
  47685. canDirectLoad?(data: string): boolean;
  47686. /**
  47687. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47688. * @param scene scene loading this data
  47689. * @param data string containing the data
  47690. * @returns data to pass to the plugin
  47691. */
  47692. directLoad?(scene: Scene, data: string): any;
  47693. /**
  47694. * The callback that allows custom handling of the root url based on the response url.
  47695. * @param rootUrl the original root url
  47696. * @param responseURL the response url if available
  47697. * @returns the new root url
  47698. */
  47699. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47700. }
  47701. /**
  47702. * Interface used to define a SceneLoader plugin
  47703. */
  47704. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47705. /**
  47706. * Import meshes into a scene.
  47707. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47708. * @param scene The scene to import into
  47709. * @param data The data to import
  47710. * @param rootUrl The root url for scene and resources
  47711. * @param meshes The meshes array to import into
  47712. * @param particleSystems The particle systems array to import into
  47713. * @param skeletons The skeletons array to import into
  47714. * @param onError The callback when import fails
  47715. * @returns True if successful or false otherwise
  47716. */
  47717. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47718. /**
  47719. * Load into a scene.
  47720. * @param scene The scene to load into
  47721. * @param data The data to import
  47722. * @param rootUrl The root url for scene and resources
  47723. * @param onError The callback when import fails
  47724. * @returns True if successful or false otherwise
  47725. */
  47726. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47727. /**
  47728. * Load into an asset container.
  47729. * @param scene The scene to load into
  47730. * @param data The data to import
  47731. * @param rootUrl The root url for scene and resources
  47732. * @param onError The callback when import fails
  47733. * @returns The loaded asset container
  47734. */
  47735. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47736. }
  47737. /**
  47738. * Interface used to define an async SceneLoader plugin
  47739. */
  47740. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47741. /**
  47742. * Import meshes into a scene.
  47743. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47744. * @param scene The scene to import into
  47745. * @param data The data to import
  47746. * @param rootUrl The root url for scene and resources
  47747. * @param onProgress The callback when the load progresses
  47748. * @param fileName Defines the name of the file to load
  47749. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47750. */
  47751. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47752. meshes: AbstractMesh[];
  47753. particleSystems: IParticleSystem[];
  47754. skeletons: Skeleton[];
  47755. animationGroups: AnimationGroup[];
  47756. }>;
  47757. /**
  47758. * Load into a scene.
  47759. * @param scene The scene to load into
  47760. * @param data The data to import
  47761. * @param rootUrl The root url for scene and resources
  47762. * @param onProgress The callback when the load progresses
  47763. * @param fileName Defines the name of the file to load
  47764. * @returns Nothing
  47765. */
  47766. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47767. /**
  47768. * Load into an asset container.
  47769. * @param scene The scene to load into
  47770. * @param data The data to import
  47771. * @param rootUrl The root url for scene and resources
  47772. * @param onProgress The callback when the load progresses
  47773. * @param fileName Defines the name of the file to load
  47774. * @returns The loaded asset container
  47775. */
  47776. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47777. }
  47778. /**
  47779. * Mode that determines how to handle old animation groups before loading new ones.
  47780. */
  47781. export enum SceneLoaderAnimationGroupLoadingMode {
  47782. /**
  47783. * Reset all old animations to initial state then dispose them.
  47784. */
  47785. Clean = 0,
  47786. /**
  47787. * Stop all old animations.
  47788. */
  47789. Stop = 1,
  47790. /**
  47791. * Restart old animations from first frame.
  47792. */
  47793. Sync = 2,
  47794. /**
  47795. * Old animations remains untouched.
  47796. */
  47797. NoSync = 3
  47798. }
  47799. /**
  47800. * Defines a plugin registered by the SceneLoader
  47801. */
  47802. interface IRegisteredPlugin {
  47803. /**
  47804. * Defines the plugin to use
  47805. */
  47806. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47807. /**
  47808. * Defines if the plugin supports binary data
  47809. */
  47810. isBinary: boolean;
  47811. }
  47812. /**
  47813. * Class used to load scene from various file formats using registered plugins
  47814. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47815. */
  47816. export class SceneLoader {
  47817. /**
  47818. * No logging while loading
  47819. */
  47820. static readonly NO_LOGGING: number;
  47821. /**
  47822. * Minimal logging while loading
  47823. */
  47824. static readonly MINIMAL_LOGGING: number;
  47825. /**
  47826. * Summary logging while loading
  47827. */
  47828. static readonly SUMMARY_LOGGING: number;
  47829. /**
  47830. * Detailled logging while loading
  47831. */
  47832. static readonly DETAILED_LOGGING: number;
  47833. /**
  47834. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47835. */
  47836. static get ForceFullSceneLoadingForIncremental(): boolean;
  47837. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47838. /**
  47839. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47840. */
  47841. static get ShowLoadingScreen(): boolean;
  47842. static set ShowLoadingScreen(value: boolean);
  47843. /**
  47844. * Defines the current logging level (while loading the scene)
  47845. * @ignorenaming
  47846. */
  47847. static get loggingLevel(): number;
  47848. static set loggingLevel(value: number);
  47849. /**
  47850. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47851. */
  47852. static get CleanBoneMatrixWeights(): boolean;
  47853. static set CleanBoneMatrixWeights(value: boolean);
  47854. /**
  47855. * Event raised when a plugin is used to load a scene
  47856. */
  47857. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47858. private static _registeredPlugins;
  47859. private static _showingLoadingScreen;
  47860. /**
  47861. * Gets the default plugin (used to load Babylon files)
  47862. * @returns the .babylon plugin
  47863. */
  47864. static GetDefaultPlugin(): IRegisteredPlugin;
  47865. private static _GetPluginForExtension;
  47866. private static _GetPluginForDirectLoad;
  47867. private static _GetPluginForFilename;
  47868. private static _GetDirectLoad;
  47869. private static _LoadData;
  47870. private static _GetFileInfo;
  47871. /**
  47872. * Gets a plugin that can load the given extension
  47873. * @param extension defines the extension to load
  47874. * @returns a plugin or null if none works
  47875. */
  47876. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47877. /**
  47878. * Gets a boolean indicating that the given extension can be loaded
  47879. * @param extension defines the extension to load
  47880. * @returns true if the extension is supported
  47881. */
  47882. static IsPluginForExtensionAvailable(extension: string): boolean;
  47883. /**
  47884. * Adds a new plugin to the list of registered plugins
  47885. * @param plugin defines the plugin to add
  47886. */
  47887. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47888. /**
  47889. * Import meshes into a scene
  47890. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47891. * @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)
  47892. * @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)
  47893. * @param scene the instance of BABYLON.Scene to append to
  47894. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47895. * @param onProgress a callback with a progress event for each file being loaded
  47896. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47897. * @param pluginExtension the extension used to determine the plugin
  47898. * @returns The loaded plugin
  47899. */
  47900. 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>;
  47901. /**
  47902. * Import meshes into a scene
  47903. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47904. * @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)
  47905. * @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)
  47906. * @param scene the instance of BABYLON.Scene to append to
  47907. * @param onProgress a callback with a progress event for each file being loaded
  47908. * @param pluginExtension the extension used to determine the plugin
  47909. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47910. */
  47911. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47912. meshes: AbstractMesh[];
  47913. particleSystems: IParticleSystem[];
  47914. skeletons: Skeleton[];
  47915. animationGroups: AnimationGroup[];
  47916. }>;
  47917. /**
  47918. * Load a scene
  47919. * @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)
  47920. * @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)
  47921. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47922. * @param onSuccess a callback with the scene when import succeeds
  47923. * @param onProgress a callback with a progress event for each file being loaded
  47924. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47925. * @param pluginExtension the extension used to determine the plugin
  47926. * @returns The loaded plugin
  47927. */
  47928. 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>;
  47929. /**
  47930. * Load a scene
  47931. * @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)
  47932. * @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)
  47933. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47934. * @param onProgress a callback with a progress event for each file being loaded
  47935. * @param pluginExtension the extension used to determine the plugin
  47936. * @returns The loaded scene
  47937. */
  47938. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47939. /**
  47940. * Append a scene
  47941. * @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)
  47942. * @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)
  47943. * @param scene is the instance of BABYLON.Scene to append to
  47944. * @param onSuccess a callback with the scene when import succeeds
  47945. * @param onProgress a callback with a progress event for each file being loaded
  47946. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47947. * @param pluginExtension the extension used to determine the plugin
  47948. * @returns The loaded plugin
  47949. */
  47950. 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>;
  47951. /**
  47952. * Append a scene
  47953. * @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)
  47954. * @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)
  47955. * @param scene is the instance of BABYLON.Scene to append to
  47956. * @param onProgress a callback with a progress event for each file being loaded
  47957. * @param pluginExtension the extension used to determine the plugin
  47958. * @returns The given scene
  47959. */
  47960. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47961. /**
  47962. * Load a scene into an asset container
  47963. * @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)
  47964. * @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)
  47965. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47966. * @param onSuccess a callback with the scene when import succeeds
  47967. * @param onProgress a callback with a progress event for each file being loaded
  47968. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47969. * @param pluginExtension the extension used to determine the plugin
  47970. * @returns The loaded plugin
  47971. */
  47972. 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>;
  47973. /**
  47974. * Load a scene into an asset container
  47975. * @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)
  47976. * @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)
  47977. * @param scene is the instance of Scene to append to
  47978. * @param onProgress a callback with a progress event for each file being loaded
  47979. * @param pluginExtension the extension used to determine the plugin
  47980. * @returns The loaded asset container
  47981. */
  47982. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47983. /**
  47984. * Import animations from a file into a scene
  47985. * @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)
  47986. * @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)
  47987. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47988. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47989. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47990. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47991. * @param onSuccess a callback with the scene when import succeeds
  47992. * @param onProgress a callback with a progress event for each file being loaded
  47993. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47994. * @param pluginExtension the extension used to determine the plugin
  47995. */
  47996. 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;
  47997. /**
  47998. * Import animations from a file into a scene
  47999. * @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)
  48000. * @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)
  48001. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48002. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48003. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48004. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48005. * @param onSuccess a callback with the scene when import succeeds
  48006. * @param onProgress a callback with a progress event for each file being loaded
  48007. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48008. * @param pluginExtension the extension used to determine the plugin
  48009. * @returns the updated scene with imported animations
  48010. */
  48011. 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>;
  48012. }
  48013. }
  48014. declare module BABYLON {
  48015. /**
  48016. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48017. */
  48018. export type MotionControllerHandedness = "none" | "left" | "right";
  48019. /**
  48020. * The type of components available in motion controllers.
  48021. * This is not the name of the component.
  48022. */
  48023. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48024. /**
  48025. * The state of a controller component
  48026. */
  48027. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48028. /**
  48029. * The schema of motion controller layout.
  48030. * No object will be initialized using this interface
  48031. * This is used just to define the profile.
  48032. */
  48033. export interface IMotionControllerLayout {
  48034. /**
  48035. * Path to load the assets. Usually relative to the base path
  48036. */
  48037. assetPath: string;
  48038. /**
  48039. * Available components (unsorted)
  48040. */
  48041. components: {
  48042. /**
  48043. * A map of component Ids
  48044. */
  48045. [componentId: string]: {
  48046. /**
  48047. * The type of input the component outputs
  48048. */
  48049. type: MotionControllerComponentType;
  48050. /**
  48051. * The indices of this component in the gamepad object
  48052. */
  48053. gamepadIndices: {
  48054. /**
  48055. * Index of button
  48056. */
  48057. button?: number;
  48058. /**
  48059. * If available, index of x-axis
  48060. */
  48061. xAxis?: number;
  48062. /**
  48063. * If available, index of y-axis
  48064. */
  48065. yAxis?: number;
  48066. };
  48067. /**
  48068. * The mesh's root node name
  48069. */
  48070. rootNodeName: string;
  48071. /**
  48072. * Animation definitions for this model
  48073. */
  48074. visualResponses: {
  48075. [stateKey: string]: {
  48076. /**
  48077. * What property will be animated
  48078. */
  48079. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48080. /**
  48081. * What states influence this visual response
  48082. */
  48083. states: MotionControllerComponentStateType[];
  48084. /**
  48085. * Type of animation - movement or visibility
  48086. */
  48087. valueNodeProperty: "transform" | "visibility";
  48088. /**
  48089. * Base node name to move. Its position will be calculated according to the min and max nodes
  48090. */
  48091. valueNodeName?: string;
  48092. /**
  48093. * Minimum movement node
  48094. */
  48095. minNodeName?: string;
  48096. /**
  48097. * Max movement node
  48098. */
  48099. maxNodeName?: string;
  48100. };
  48101. };
  48102. /**
  48103. * If touch enabled, what is the name of node to display user feedback
  48104. */
  48105. touchPointNodeName?: string;
  48106. };
  48107. };
  48108. /**
  48109. * Is it xr standard mapping or not
  48110. */
  48111. gamepadMapping: "" | "xr-standard";
  48112. /**
  48113. * Base root node of this entire model
  48114. */
  48115. rootNodeName: string;
  48116. /**
  48117. * Defines the main button component id
  48118. */
  48119. selectComponentId: string;
  48120. }
  48121. /**
  48122. * A definition for the layout map in the input profile
  48123. */
  48124. export interface IMotionControllerLayoutMap {
  48125. /**
  48126. * Layouts with handedness type as a key
  48127. */
  48128. [handedness: string]: IMotionControllerLayout;
  48129. }
  48130. /**
  48131. * The XR Input profile schema
  48132. * Profiles can be found here:
  48133. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48134. */
  48135. export interface IMotionControllerProfile {
  48136. /**
  48137. * fallback profiles for this profileId
  48138. */
  48139. fallbackProfileIds: string[];
  48140. /**
  48141. * The layout map, with handedness as key
  48142. */
  48143. layouts: IMotionControllerLayoutMap;
  48144. /**
  48145. * The id of this profile
  48146. * correlates to the profile(s) in the xrInput.profiles array
  48147. */
  48148. profileId: string;
  48149. }
  48150. /**
  48151. * A helper-interface for the 3 meshes needed for controller button animation
  48152. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48153. */
  48154. export interface IMotionControllerButtonMeshMap {
  48155. /**
  48156. * the mesh that defines the pressed value mesh position.
  48157. * This is used to find the max-position of this button
  48158. */
  48159. pressedMesh: AbstractMesh;
  48160. /**
  48161. * the mesh that defines the unpressed value mesh position.
  48162. * This is used to find the min (or initial) position of this button
  48163. */
  48164. unpressedMesh: AbstractMesh;
  48165. /**
  48166. * The mesh that will be changed when value changes
  48167. */
  48168. valueMesh: AbstractMesh;
  48169. }
  48170. /**
  48171. * A helper-interface for the 3 meshes needed for controller axis animation.
  48172. * This will be expanded when touchpad animations are fully supported
  48173. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48174. */
  48175. export interface IMotionControllerMeshMap {
  48176. /**
  48177. * the mesh that defines the maximum value mesh position.
  48178. */
  48179. maxMesh?: AbstractMesh;
  48180. /**
  48181. * the mesh that defines the minimum value mesh position.
  48182. */
  48183. minMesh?: AbstractMesh;
  48184. /**
  48185. * The mesh that will be changed when axis value changes
  48186. */
  48187. valueMesh?: AbstractMesh;
  48188. }
  48189. /**
  48190. * The elements needed for change-detection of the gamepad objects in motion controllers
  48191. */
  48192. export interface IMinimalMotionControllerObject {
  48193. /**
  48194. * Available axes of this controller
  48195. */
  48196. axes: number[];
  48197. /**
  48198. * An array of available buttons
  48199. */
  48200. buttons: Array<{
  48201. /**
  48202. * Value of the button/trigger
  48203. */
  48204. value: number;
  48205. /**
  48206. * If the button/trigger is currently touched
  48207. */
  48208. touched: boolean;
  48209. /**
  48210. * If the button/trigger is currently pressed
  48211. */
  48212. pressed: boolean;
  48213. }>;
  48214. /**
  48215. * EXPERIMENTAL haptic support.
  48216. */
  48217. hapticActuators?: Array<{
  48218. pulse: (value: number, duration: number) => Promise<boolean>;
  48219. }>;
  48220. }
  48221. /**
  48222. * An Abstract Motion controller
  48223. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48224. * Each component has an observable to check for changes in value and state
  48225. */
  48226. export abstract class WebXRAbstractMotionController implements IDisposable {
  48227. protected scene: Scene;
  48228. protected layout: IMotionControllerLayout;
  48229. /**
  48230. * The gamepad object correlating to this controller
  48231. */
  48232. gamepadObject: IMinimalMotionControllerObject;
  48233. /**
  48234. * handedness (left/right/none) of this controller
  48235. */
  48236. handedness: MotionControllerHandedness;
  48237. private _initComponent;
  48238. private _modelReady;
  48239. /**
  48240. * A map of components (WebXRControllerComponent) in this motion controller
  48241. * Components have a ComponentType and can also have both button and axis definitions
  48242. */
  48243. readonly components: {
  48244. [id: string]: WebXRControllerComponent;
  48245. };
  48246. /**
  48247. * Disable the model's animation. Can be set at any time.
  48248. */
  48249. disableAnimation: boolean;
  48250. /**
  48251. * Observers registered here will be triggered when the model of this controller is done loading
  48252. */
  48253. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48254. /**
  48255. * The profile id of this motion controller
  48256. */
  48257. abstract profileId: string;
  48258. /**
  48259. * The root mesh of the model. It is null if the model was not yet initialized
  48260. */
  48261. rootMesh: Nullable<AbstractMesh>;
  48262. /**
  48263. * constructs a new abstract motion controller
  48264. * @param scene the scene to which the model of the controller will be added
  48265. * @param layout The profile layout to load
  48266. * @param gamepadObject The gamepad object correlating to this controller
  48267. * @param handedness handedness (left/right/none) of this controller
  48268. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48269. */
  48270. constructor(scene: Scene, layout: IMotionControllerLayout,
  48271. /**
  48272. * The gamepad object correlating to this controller
  48273. */
  48274. gamepadObject: IMinimalMotionControllerObject,
  48275. /**
  48276. * handedness (left/right/none) of this controller
  48277. */
  48278. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48279. /**
  48280. * Dispose this controller, the model mesh and all its components
  48281. */
  48282. dispose(): void;
  48283. /**
  48284. * Returns all components of specific type
  48285. * @param type the type to search for
  48286. * @return an array of components with this type
  48287. */
  48288. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48289. /**
  48290. * get a component based an its component id as defined in layout.components
  48291. * @param id the id of the component
  48292. * @returns the component correlates to the id or undefined if not found
  48293. */
  48294. getComponent(id: string): WebXRControllerComponent;
  48295. /**
  48296. * Get the list of components available in this motion controller
  48297. * @returns an array of strings correlating to available components
  48298. */
  48299. getComponentIds(): string[];
  48300. /**
  48301. * Get the first component of specific type
  48302. * @param type type of component to find
  48303. * @return a controller component or null if not found
  48304. */
  48305. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48306. /**
  48307. * Get the main (Select) component of this controller as defined in the layout
  48308. * @returns the main component of this controller
  48309. */
  48310. getMainComponent(): WebXRControllerComponent;
  48311. /**
  48312. * Loads the model correlating to this controller
  48313. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48314. * @returns A promise fulfilled with the result of the model loading
  48315. */
  48316. loadModel(): Promise<boolean>;
  48317. /**
  48318. * Update this model using the current XRFrame
  48319. * @param xrFrame the current xr frame to use and update the model
  48320. */
  48321. updateFromXRFrame(xrFrame: XRFrame): void;
  48322. /**
  48323. * Backwards compatibility due to a deeply-integrated typo
  48324. */
  48325. get handness(): XREye;
  48326. /**
  48327. * Pulse (vibrate) this controller
  48328. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48329. * Consecutive calls to this function will cancel the last pulse call
  48330. *
  48331. * @param value the strength of the pulse in 0.0...1.0 range
  48332. * @param duration Duration of the pulse in milliseconds
  48333. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48334. * @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
  48335. */
  48336. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48337. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48338. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48339. /**
  48340. * Moves the axis on the controller mesh based on its current state
  48341. * @param axis the index of the axis
  48342. * @param axisValue the value of the axis which determines the meshes new position
  48343. * @hidden
  48344. */
  48345. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48346. /**
  48347. * Update the model itself with the current frame data
  48348. * @param xrFrame the frame to use for updating the model mesh
  48349. */
  48350. protected updateModel(xrFrame: XRFrame): void;
  48351. /**
  48352. * Get the filename and path for this controller's model
  48353. * @returns a map of filename and path
  48354. */
  48355. protected abstract _getFilenameAndPath(): {
  48356. filename: string;
  48357. path: string;
  48358. };
  48359. /**
  48360. * This function is called before the mesh is loaded. It checks for loading constraints.
  48361. * For example, this function can check if the GLB loader is available
  48362. * If this function returns false, the generic controller will be loaded instead
  48363. * @returns Is the client ready to load the mesh
  48364. */
  48365. protected abstract _getModelLoadingConstraints(): boolean;
  48366. /**
  48367. * This function will be called after the model was successfully loaded and can be used
  48368. * for mesh transformations before it is available for the user
  48369. * @param meshes the loaded meshes
  48370. */
  48371. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48372. /**
  48373. * Set the root mesh for this controller. Important for the WebXR controller class
  48374. * @param meshes the loaded meshes
  48375. */
  48376. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48377. /**
  48378. * A function executed each frame that updates the mesh (if needed)
  48379. * @param xrFrame the current xrFrame
  48380. */
  48381. protected abstract _updateModel(xrFrame: XRFrame): void;
  48382. private _getGenericFilenameAndPath;
  48383. private _getGenericParentMesh;
  48384. }
  48385. }
  48386. declare module BABYLON {
  48387. /**
  48388. * A generic trigger-only motion controller for WebXR
  48389. */
  48390. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48391. /**
  48392. * Static version of the profile id of this controller
  48393. */
  48394. static ProfileId: string;
  48395. profileId: string;
  48396. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48397. protected _getFilenameAndPath(): {
  48398. filename: string;
  48399. path: string;
  48400. };
  48401. protected _getModelLoadingConstraints(): boolean;
  48402. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48403. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48404. protected _updateModel(): void;
  48405. }
  48406. }
  48407. declare module BABYLON {
  48408. /**
  48409. * Class containing static functions to help procedurally build meshes
  48410. */
  48411. export class SphereBuilder {
  48412. /**
  48413. * Creates a sphere mesh
  48414. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48415. * * 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`)
  48416. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48417. * * 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
  48418. * * 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)
  48419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48420. * * 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
  48421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48422. * @param name defines the name of the mesh
  48423. * @param options defines the options used to create the mesh
  48424. * @param scene defines the hosting scene
  48425. * @returns the sphere mesh
  48426. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48427. */
  48428. static CreateSphere(name: string, options: {
  48429. segments?: number;
  48430. diameter?: number;
  48431. diameterX?: number;
  48432. diameterY?: number;
  48433. diameterZ?: number;
  48434. arc?: number;
  48435. slice?: number;
  48436. sideOrientation?: number;
  48437. frontUVs?: Vector4;
  48438. backUVs?: Vector4;
  48439. updatable?: boolean;
  48440. }, scene?: Nullable<Scene>): Mesh;
  48441. }
  48442. }
  48443. declare module BABYLON {
  48444. /**
  48445. * A profiled motion controller has its profile loaded from an online repository.
  48446. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48447. */
  48448. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48449. private _repositoryUrl;
  48450. private _buttonMeshMapping;
  48451. private _touchDots;
  48452. /**
  48453. * The profile ID of this controller. Will be populated when the controller initializes.
  48454. */
  48455. profileId: string;
  48456. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48457. dispose(): void;
  48458. protected _getFilenameAndPath(): {
  48459. filename: string;
  48460. path: string;
  48461. };
  48462. protected _getModelLoadingConstraints(): boolean;
  48463. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48464. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48465. protected _updateModel(_xrFrame: XRFrame): void;
  48466. }
  48467. }
  48468. declare module BABYLON {
  48469. /**
  48470. * A construction function type to create a new controller based on an xrInput object
  48471. */
  48472. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48473. /**
  48474. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48475. *
  48476. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48477. * it should be replaced with auto-loaded controllers.
  48478. *
  48479. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48480. */
  48481. export class WebXRMotionControllerManager {
  48482. private static _AvailableControllers;
  48483. private static _Fallbacks;
  48484. private static _ProfileLoadingPromises;
  48485. private static _ProfilesList;
  48486. /**
  48487. * The base URL of the online controller repository. Can be changed at any time.
  48488. */
  48489. static BaseRepositoryUrl: string;
  48490. /**
  48491. * Which repository gets priority - local or online
  48492. */
  48493. static PrioritizeOnlineRepository: boolean;
  48494. /**
  48495. * Use the online repository, or use only locally-defined controllers
  48496. */
  48497. static UseOnlineRepository: boolean;
  48498. /**
  48499. * Clear the cache used for profile loading and reload when requested again
  48500. */
  48501. static ClearProfilesCache(): void;
  48502. /**
  48503. * Register the default fallbacks.
  48504. * This function is called automatically when this file is imported.
  48505. */
  48506. static DefaultFallbacks(): void;
  48507. /**
  48508. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48509. * @param profileId the profile to which a fallback needs to be found
  48510. * @return an array with corresponding fallback profiles
  48511. */
  48512. static FindFallbackWithProfileId(profileId: string): string[];
  48513. /**
  48514. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48515. * The order of search:
  48516. *
  48517. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48518. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48519. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48520. * 4) return the generic trigger controller if none were found
  48521. *
  48522. * @param xrInput the xrInput to which a new controller is initialized
  48523. * @param scene the scene to which the model will be added
  48524. * @param forceProfile force a certain profile for this controller
  48525. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48526. */
  48527. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48528. /**
  48529. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48530. *
  48531. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48532. *
  48533. * @param type the profile type to register
  48534. * @param constructFunction the function to be called when loading this profile
  48535. */
  48536. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48537. /**
  48538. * Register a fallback to a specific profile.
  48539. * @param profileId the profileId that will receive the fallbacks
  48540. * @param fallbacks A list of fallback profiles
  48541. */
  48542. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48543. /**
  48544. * Will update the list of profiles available in the repository
  48545. * @return a promise that resolves to a map of profiles available online
  48546. */
  48547. static UpdateProfilesList(): Promise<{
  48548. [profile: string]: string;
  48549. }>;
  48550. private static _LoadProfileFromRepository;
  48551. private static _LoadProfilesFromAvailableControllers;
  48552. }
  48553. }
  48554. declare module BABYLON {
  48555. /**
  48556. * Configuration options for the WebXR controller creation
  48557. */
  48558. export interface IWebXRControllerOptions {
  48559. /**
  48560. * Should the controller mesh be animated when a user interacts with it
  48561. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48562. */
  48563. disableMotionControllerAnimation?: boolean;
  48564. /**
  48565. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48566. */
  48567. doNotLoadControllerMesh?: boolean;
  48568. /**
  48569. * Force a specific controller type for this controller.
  48570. * This can be used when creating your own profile or when testing different controllers
  48571. */
  48572. forceControllerProfile?: string;
  48573. /**
  48574. * Defines a rendering group ID for meshes that will be loaded.
  48575. * This is for the default controllers only.
  48576. */
  48577. renderingGroupId?: number;
  48578. }
  48579. /**
  48580. * Represents an XR controller
  48581. */
  48582. export class WebXRInputSource {
  48583. private _scene;
  48584. /** The underlying input source for the controller */
  48585. inputSource: XRInputSource;
  48586. private _options;
  48587. private _tmpVector;
  48588. private _uniqueId;
  48589. private _disposed;
  48590. /**
  48591. * 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
  48592. */
  48593. grip?: AbstractMesh;
  48594. /**
  48595. * If available, this is the gamepad object related to this controller.
  48596. * Using this object it is possible to get click events and trackpad changes of the
  48597. * webxr controller that is currently being used.
  48598. */
  48599. motionController?: WebXRAbstractMotionController;
  48600. /**
  48601. * Event that fires when the controller is removed/disposed.
  48602. * The object provided as event data is this controller, after associated assets were disposed.
  48603. * uniqueId is still available.
  48604. */
  48605. onDisposeObservable: Observable<WebXRInputSource>;
  48606. /**
  48607. * Will be triggered when the mesh associated with the motion controller is done loading.
  48608. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48609. * A shortened version of controller -> motion controller -> on mesh loaded.
  48610. */
  48611. onMeshLoadedObservable: Observable<AbstractMesh>;
  48612. /**
  48613. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48614. */
  48615. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48616. /**
  48617. * Pointer which can be used to select objects or attach a visible laser to
  48618. */
  48619. pointer: AbstractMesh;
  48620. /**
  48621. * Creates the input source object
  48622. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48623. * @param _scene the scene which the controller should be associated to
  48624. * @param inputSource the underlying input source for the controller
  48625. * @param _options options for this controller creation
  48626. */
  48627. constructor(_scene: Scene,
  48628. /** The underlying input source for the controller */
  48629. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48630. /**
  48631. * Get this controllers unique id
  48632. */
  48633. get uniqueId(): string;
  48634. /**
  48635. * Disposes of the object
  48636. */
  48637. dispose(): void;
  48638. /**
  48639. * Gets a world space ray coming from the pointer or grip
  48640. * @param result the resulting ray
  48641. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48642. */
  48643. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48644. /**
  48645. * Updates the controller pose based on the given XRFrame
  48646. * @param xrFrame xr frame to update the pose with
  48647. * @param referenceSpace reference space to use
  48648. */
  48649. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48650. }
  48651. }
  48652. declare module BABYLON {
  48653. /**
  48654. * The schema for initialization options of the XR Input class
  48655. */
  48656. export interface IWebXRInputOptions {
  48657. /**
  48658. * If set to true no model will be automatically loaded
  48659. */
  48660. doNotLoadControllerMeshes?: boolean;
  48661. /**
  48662. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48663. * If not found, the xr input profile data will be used.
  48664. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48665. */
  48666. forceInputProfile?: string;
  48667. /**
  48668. * Do not send a request to the controller repository to load the profile.
  48669. *
  48670. * Instead, use the controllers available in babylon itself.
  48671. */
  48672. disableOnlineControllerRepository?: boolean;
  48673. /**
  48674. * A custom URL for the controllers repository
  48675. */
  48676. customControllersRepositoryURL?: string;
  48677. /**
  48678. * Should the controller model's components not move according to the user input
  48679. */
  48680. disableControllerAnimation?: boolean;
  48681. /**
  48682. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48683. */
  48684. controllerOptions?: IWebXRControllerOptions;
  48685. }
  48686. /**
  48687. * XR input used to track XR inputs such as controllers/rays
  48688. */
  48689. export class WebXRInput implements IDisposable {
  48690. /**
  48691. * the xr session manager for this session
  48692. */
  48693. xrSessionManager: WebXRSessionManager;
  48694. /**
  48695. * the WebXR camera for this session. Mainly used for teleportation
  48696. */
  48697. xrCamera: WebXRCamera;
  48698. private readonly options;
  48699. /**
  48700. * XR controllers being tracked
  48701. */
  48702. controllers: Array<WebXRInputSource>;
  48703. private _frameObserver;
  48704. private _sessionEndedObserver;
  48705. private _sessionInitObserver;
  48706. /**
  48707. * Event when a controller has been connected/added
  48708. */
  48709. onControllerAddedObservable: Observable<WebXRInputSource>;
  48710. /**
  48711. * Event when a controller has been removed/disconnected
  48712. */
  48713. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48714. /**
  48715. * Initializes the WebXRInput
  48716. * @param xrSessionManager the xr session manager for this session
  48717. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48718. * @param options = initialization options for this xr input
  48719. */
  48720. constructor(
  48721. /**
  48722. * the xr session manager for this session
  48723. */
  48724. xrSessionManager: WebXRSessionManager,
  48725. /**
  48726. * the WebXR camera for this session. Mainly used for teleportation
  48727. */
  48728. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48729. private _onInputSourcesChange;
  48730. private _addAndRemoveControllers;
  48731. /**
  48732. * Disposes of the object
  48733. */
  48734. dispose(): void;
  48735. }
  48736. }
  48737. declare module BABYLON {
  48738. /**
  48739. * This is the base class for all WebXR features.
  48740. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48741. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48742. */
  48743. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48744. protected _xrSessionManager: WebXRSessionManager;
  48745. private _attached;
  48746. private _removeOnDetach;
  48747. /**
  48748. * Is this feature disposed?
  48749. */
  48750. isDisposed: boolean;
  48751. /**
  48752. * Should auto-attach be disabled?
  48753. */
  48754. disableAutoAttach: boolean;
  48755. /**
  48756. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48757. */
  48758. xrNativeFeatureName: string;
  48759. /**
  48760. * Construct a new (abstract) WebXR feature
  48761. * @param _xrSessionManager the xr session manager for this feature
  48762. */
  48763. constructor(_xrSessionManager: WebXRSessionManager);
  48764. /**
  48765. * Is this feature attached
  48766. */
  48767. get attached(): boolean;
  48768. /**
  48769. * attach this feature
  48770. *
  48771. * @param force should attachment be forced (even when already attached)
  48772. * @returns true if successful, false is failed or already attached
  48773. */
  48774. attach(force?: boolean): boolean;
  48775. /**
  48776. * detach this feature.
  48777. *
  48778. * @returns true if successful, false if failed or already detached
  48779. */
  48780. detach(): boolean;
  48781. /**
  48782. * Dispose this feature and all of the resources attached
  48783. */
  48784. dispose(): void;
  48785. /**
  48786. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48787. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48788. *
  48789. * @returns whether or not the feature is compatible in this environment
  48790. */
  48791. isCompatible(): boolean;
  48792. /**
  48793. * This is used to register callbacks that will automatically be removed when detach is called.
  48794. * @param observable the observable to which the observer will be attached
  48795. * @param callback the callback to register
  48796. */
  48797. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48798. /**
  48799. * Code in this function will be executed on each xrFrame received from the browser.
  48800. * This function will not execute after the feature is detached.
  48801. * @param _xrFrame the current frame
  48802. */
  48803. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48804. }
  48805. }
  48806. declare module BABYLON {
  48807. /**
  48808. * Renders a layer on top of an existing scene
  48809. */
  48810. export class UtilityLayerRenderer implements IDisposable {
  48811. /** the original scene that will be rendered on top of */
  48812. originalScene: Scene;
  48813. private _pointerCaptures;
  48814. private _lastPointerEvents;
  48815. private static _DefaultUtilityLayer;
  48816. private static _DefaultKeepDepthUtilityLayer;
  48817. private _sharedGizmoLight;
  48818. private _renderCamera;
  48819. /**
  48820. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48821. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48822. * @returns the camera that is used when rendering the utility layer
  48823. */
  48824. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48825. /**
  48826. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48827. * @param cam the camera that should be used when rendering the utility layer
  48828. */
  48829. setRenderCamera(cam: Nullable<Camera>): void;
  48830. /**
  48831. * @hidden
  48832. * Light which used by gizmos to get light shading
  48833. */
  48834. _getSharedGizmoLight(): HemisphericLight;
  48835. /**
  48836. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48837. */
  48838. pickUtilitySceneFirst: boolean;
  48839. /**
  48840. * 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)
  48841. */
  48842. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48843. /**
  48844. * 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)
  48845. */
  48846. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48847. /**
  48848. * The scene that is rendered on top of the original scene
  48849. */
  48850. utilityLayerScene: Scene;
  48851. /**
  48852. * If the utility layer should automatically be rendered on top of existing scene
  48853. */
  48854. shouldRender: boolean;
  48855. /**
  48856. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48857. */
  48858. onlyCheckPointerDownEvents: boolean;
  48859. /**
  48860. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48861. */
  48862. processAllEvents: boolean;
  48863. /**
  48864. * Observable raised when the pointer move from the utility layer scene to the main scene
  48865. */
  48866. onPointerOutObservable: Observable<number>;
  48867. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48868. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48869. private _afterRenderObserver;
  48870. private _sceneDisposeObserver;
  48871. private _originalPointerObserver;
  48872. /**
  48873. * Instantiates a UtilityLayerRenderer
  48874. * @param originalScene the original scene that will be rendered on top of
  48875. * @param handleEvents boolean indicating if the utility layer should handle events
  48876. */
  48877. constructor(
  48878. /** the original scene that will be rendered on top of */
  48879. originalScene: Scene, handleEvents?: boolean);
  48880. private _notifyObservers;
  48881. /**
  48882. * Renders the utility layers scene on top of the original scene
  48883. */
  48884. render(): void;
  48885. /**
  48886. * Disposes of the renderer
  48887. */
  48888. dispose(): void;
  48889. private _updateCamera;
  48890. }
  48891. }
  48892. declare module BABYLON {
  48893. /**
  48894. * Options interface for the pointer selection module
  48895. */
  48896. export interface IWebXRControllerPointerSelectionOptions {
  48897. /**
  48898. * if provided, this scene will be used to render meshes.
  48899. */
  48900. customUtilityLayerScene?: Scene;
  48901. /**
  48902. * 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)
  48903. * If not disabled, the last picked point will be used to execute a pointer up event
  48904. * If disabled, pointer up event will be triggered right after the pointer down event.
  48905. * Used in screen and gaze target ray mode only
  48906. */
  48907. disablePointerUpOnTouchOut: boolean;
  48908. /**
  48909. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48910. */
  48911. forceGazeMode: boolean;
  48912. /**
  48913. * 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
  48914. * to start a new countdown to the pointer down event.
  48915. * Defaults to 1.
  48916. */
  48917. gazeModePointerMovedFactor?: number;
  48918. /**
  48919. * Different button type to use instead of the main component
  48920. */
  48921. overrideButtonId?: string;
  48922. /**
  48923. * use this rendering group id for the meshes (optional)
  48924. */
  48925. renderingGroupId?: number;
  48926. /**
  48927. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48928. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48929. * 3000 means 3 seconds between pointing at something and selecting it
  48930. */
  48931. timeToSelect?: number;
  48932. /**
  48933. * Should meshes created here be added to a utility layer or the main scene
  48934. */
  48935. useUtilityLayer?: boolean;
  48936. /**
  48937. * Optional WebXR camera to be used for gaze selection
  48938. */
  48939. gazeCamera?: WebXRCamera;
  48940. /**
  48941. * the xr input to use with this pointer selection
  48942. */
  48943. xrInput: WebXRInput;
  48944. }
  48945. /**
  48946. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48947. */
  48948. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48949. private readonly _options;
  48950. private static _idCounter;
  48951. private _attachController;
  48952. private _controllers;
  48953. private _scene;
  48954. private _tmpVectorForPickCompare;
  48955. /**
  48956. * The module's name
  48957. */
  48958. static readonly Name: string;
  48959. /**
  48960. * The (Babylon) version of this module.
  48961. * This is an integer representing the implementation version.
  48962. * This number does not correspond to the WebXR specs version
  48963. */
  48964. static readonly Version: number;
  48965. /**
  48966. * Disable lighting on the laser pointer (so it will always be visible)
  48967. */
  48968. disablePointerLighting: boolean;
  48969. /**
  48970. * Disable lighting on the selection mesh (so it will always be visible)
  48971. */
  48972. disableSelectionMeshLighting: boolean;
  48973. /**
  48974. * Should the laser pointer be displayed
  48975. */
  48976. displayLaserPointer: boolean;
  48977. /**
  48978. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48979. */
  48980. displaySelectionMesh: boolean;
  48981. /**
  48982. * This color will be set to the laser pointer when selection is triggered
  48983. */
  48984. laserPointerPickedColor: Color3;
  48985. /**
  48986. * Default color of the laser pointer
  48987. */
  48988. laserPointerDefaultColor: Color3;
  48989. /**
  48990. * default color of the selection ring
  48991. */
  48992. selectionMeshDefaultColor: Color3;
  48993. /**
  48994. * This color will be applied to the selection ring when selection is triggered
  48995. */
  48996. selectionMeshPickedColor: Color3;
  48997. /**
  48998. * Optional filter to be used for ray selection. This predicate shares behavior with
  48999. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49000. */
  49001. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49002. /**
  49003. * constructs a new background remover module
  49004. * @param _xrSessionManager the session manager for this module
  49005. * @param _options read-only options to be used in this module
  49006. */
  49007. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49008. /**
  49009. * attach this feature
  49010. * Will usually be called by the features manager
  49011. *
  49012. * @returns true if successful.
  49013. */
  49014. attach(): boolean;
  49015. /**
  49016. * detach this feature.
  49017. * Will usually be called by the features manager
  49018. *
  49019. * @returns true if successful.
  49020. */
  49021. detach(): boolean;
  49022. /**
  49023. * Will get the mesh under a specific pointer.
  49024. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49025. * @param controllerId the controllerId to check
  49026. * @returns The mesh under pointer or null if no mesh is under the pointer
  49027. */
  49028. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49029. /**
  49030. * Get the xr controller that correlates to the pointer id in the pointer event
  49031. *
  49032. * @param id the pointer id to search for
  49033. * @returns the controller that correlates to this id or null if not found
  49034. */
  49035. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49036. protected _onXRFrame(_xrFrame: XRFrame): void;
  49037. private _attachGazeMode;
  49038. private _attachScreenRayMode;
  49039. private _attachTrackedPointerRayMode;
  49040. private _convertNormalToDirectionOfRay;
  49041. private _detachController;
  49042. private _generateNewMeshPair;
  49043. private _pickingMoved;
  49044. private _updatePointerDistance;
  49045. /** @hidden */
  49046. get lasterPointerDefaultColor(): Color3;
  49047. }
  49048. }
  49049. declare module BABYLON {
  49050. /**
  49051. * Button which can be used to enter a different mode of XR
  49052. */
  49053. export class WebXREnterExitUIButton {
  49054. /** button element */
  49055. element: HTMLElement;
  49056. /** XR initialization options for the button */
  49057. sessionMode: XRSessionMode;
  49058. /** Reference space type */
  49059. referenceSpaceType: XRReferenceSpaceType;
  49060. /**
  49061. * Creates a WebXREnterExitUIButton
  49062. * @param element button element
  49063. * @param sessionMode XR initialization session mode
  49064. * @param referenceSpaceType the type of reference space to be used
  49065. */
  49066. constructor(
  49067. /** button element */
  49068. element: HTMLElement,
  49069. /** XR initialization options for the button */
  49070. sessionMode: XRSessionMode,
  49071. /** Reference space type */
  49072. referenceSpaceType: XRReferenceSpaceType);
  49073. /**
  49074. * Extendable function which can be used to update the button's visuals when the state changes
  49075. * @param activeButton the current active button in the UI
  49076. */
  49077. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49078. }
  49079. /**
  49080. * Options to create the webXR UI
  49081. */
  49082. export class WebXREnterExitUIOptions {
  49083. /**
  49084. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49085. */
  49086. customButtons?: Array<WebXREnterExitUIButton>;
  49087. /**
  49088. * A reference space type to use when creating the default button.
  49089. * Default is local-floor
  49090. */
  49091. referenceSpaceType?: XRReferenceSpaceType;
  49092. /**
  49093. * Context to enter xr with
  49094. */
  49095. renderTarget?: Nullable<WebXRRenderTarget>;
  49096. /**
  49097. * A session mode to use when creating the default button.
  49098. * Default is immersive-vr
  49099. */
  49100. sessionMode?: XRSessionMode;
  49101. /**
  49102. * A list of optional features to init the session with
  49103. */
  49104. optionalFeatures?: string[];
  49105. /**
  49106. * A list of optional features to init the session with
  49107. */
  49108. requiredFeatures?: string[];
  49109. }
  49110. /**
  49111. * UI to allow the user to enter/exit XR mode
  49112. */
  49113. export class WebXREnterExitUI implements IDisposable {
  49114. private scene;
  49115. /** version of the options passed to this UI */
  49116. options: WebXREnterExitUIOptions;
  49117. private _activeButton;
  49118. private _buttons;
  49119. /**
  49120. * The HTML Div Element to which buttons are added.
  49121. */
  49122. readonly overlay: HTMLDivElement;
  49123. /**
  49124. * Fired every time the active button is changed.
  49125. *
  49126. * When xr is entered via a button that launches xr that button will be the callback parameter
  49127. *
  49128. * When exiting xr the callback parameter will be null)
  49129. */
  49130. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49131. /**
  49132. *
  49133. * @param scene babylon scene object to use
  49134. * @param options (read-only) version of the options passed to this UI
  49135. */
  49136. private constructor();
  49137. /**
  49138. * Creates UI to allow the user to enter/exit XR mode
  49139. * @param scene the scene to add the ui to
  49140. * @param helper the xr experience helper to enter/exit xr with
  49141. * @param options options to configure the UI
  49142. * @returns the created ui
  49143. */
  49144. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49145. /**
  49146. * Disposes of the XR UI component
  49147. */
  49148. dispose(): void;
  49149. private _updateButtons;
  49150. }
  49151. }
  49152. declare module BABYLON {
  49153. /**
  49154. * Class containing static functions to help procedurally build meshes
  49155. */
  49156. export class LinesBuilder {
  49157. /**
  49158. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49159. * * 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
  49160. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49161. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49162. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49163. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49164. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49165. * * 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
  49166. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49168. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49169. * @param name defines the name of the new line system
  49170. * @param options defines the options used to create the line system
  49171. * @param scene defines the hosting scene
  49172. * @returns a new line system mesh
  49173. */
  49174. static CreateLineSystem(name: string, options: {
  49175. lines: Vector3[][];
  49176. updatable?: boolean;
  49177. instance?: Nullable<LinesMesh>;
  49178. colors?: Nullable<Color4[][]>;
  49179. useVertexAlpha?: boolean;
  49180. }, scene: Nullable<Scene>): LinesMesh;
  49181. /**
  49182. * Creates a line mesh
  49183. * 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
  49184. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49185. * * The parameter `points` is an array successive Vector3
  49186. * * 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
  49187. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49188. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49189. * * When updating an instance, remember that only point positions can change, not the number of points
  49190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49192. * @param name defines the name of the new line system
  49193. * @param options defines the options used to create the line system
  49194. * @param scene defines the hosting scene
  49195. * @returns a new line mesh
  49196. */
  49197. static CreateLines(name: string, options: {
  49198. points: Vector3[];
  49199. updatable?: boolean;
  49200. instance?: Nullable<LinesMesh>;
  49201. colors?: Color4[];
  49202. useVertexAlpha?: boolean;
  49203. }, scene?: Nullable<Scene>): LinesMesh;
  49204. /**
  49205. * Creates a dashed line mesh
  49206. * * 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
  49207. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49208. * * The parameter `points` is an array successive Vector3
  49209. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49210. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49211. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49212. * * 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
  49213. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49214. * * When updating an instance, remember that only point positions can change, not the number of points
  49215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49216. * @param name defines the name of the mesh
  49217. * @param options defines the options used to create the mesh
  49218. * @param scene defines the hosting scene
  49219. * @returns the dashed line mesh
  49220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49221. */
  49222. static CreateDashedLines(name: string, options: {
  49223. points: Vector3[];
  49224. dashSize?: number;
  49225. gapSize?: number;
  49226. dashNb?: number;
  49227. updatable?: boolean;
  49228. instance?: LinesMesh;
  49229. useVertexAlpha?: boolean;
  49230. }, scene?: Nullable<Scene>): LinesMesh;
  49231. }
  49232. }
  49233. declare module BABYLON {
  49234. /**
  49235. * Construction options for a timer
  49236. */
  49237. export interface ITimerOptions<T> {
  49238. /**
  49239. * Time-to-end
  49240. */
  49241. timeout: number;
  49242. /**
  49243. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49244. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49245. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49246. */
  49247. contextObservable: Observable<T>;
  49248. /**
  49249. * Optional parameters when adding an observer to the observable
  49250. */
  49251. observableParameters?: {
  49252. mask?: number;
  49253. insertFirst?: boolean;
  49254. scope?: any;
  49255. };
  49256. /**
  49257. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49258. */
  49259. breakCondition?: (data?: ITimerData<T>) => boolean;
  49260. /**
  49261. * Will be triggered when the time condition has met
  49262. */
  49263. onEnded?: (data: ITimerData<any>) => void;
  49264. /**
  49265. * Will be triggered when the break condition has met (prematurely ended)
  49266. */
  49267. onAborted?: (data: ITimerData<any>) => void;
  49268. /**
  49269. * Optional function to execute on each tick (or count)
  49270. */
  49271. onTick?: (data: ITimerData<any>) => void;
  49272. }
  49273. /**
  49274. * An interface defining the data sent by the timer
  49275. */
  49276. export interface ITimerData<T> {
  49277. /**
  49278. * When did it start
  49279. */
  49280. startTime: number;
  49281. /**
  49282. * Time now
  49283. */
  49284. currentTime: number;
  49285. /**
  49286. * Time passed since started
  49287. */
  49288. deltaTime: number;
  49289. /**
  49290. * How much is completed, in [0.0...1.0].
  49291. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49292. */
  49293. completeRate: number;
  49294. /**
  49295. * What the registered observable sent in the last count
  49296. */
  49297. payload: T;
  49298. }
  49299. /**
  49300. * The current state of the timer
  49301. */
  49302. export enum TimerState {
  49303. /**
  49304. * Timer initialized, not yet started
  49305. */
  49306. INIT = 0,
  49307. /**
  49308. * Timer started and counting
  49309. */
  49310. STARTED = 1,
  49311. /**
  49312. * Timer ended (whether aborted or time reached)
  49313. */
  49314. ENDED = 2
  49315. }
  49316. /**
  49317. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49318. *
  49319. * @param options options with which to initialize this timer
  49320. */
  49321. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49322. /**
  49323. * An advanced implementation of a timer class
  49324. */
  49325. export class AdvancedTimer<T = any> implements IDisposable {
  49326. /**
  49327. * Will notify each time the timer calculates the remaining time
  49328. */
  49329. onEachCountObservable: Observable<ITimerData<T>>;
  49330. /**
  49331. * Will trigger when the timer was aborted due to the break condition
  49332. */
  49333. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49334. /**
  49335. * Will trigger when the timer ended successfully
  49336. */
  49337. onTimerEndedObservable: Observable<ITimerData<T>>;
  49338. /**
  49339. * Will trigger when the timer state has changed
  49340. */
  49341. onStateChangedObservable: Observable<TimerState>;
  49342. private _observer;
  49343. private _contextObservable;
  49344. private _observableParameters;
  49345. private _startTime;
  49346. private _timer;
  49347. private _state;
  49348. private _breakCondition;
  49349. private _timeToEnd;
  49350. private _breakOnNextTick;
  49351. /**
  49352. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49353. * @param options construction options for this advanced timer
  49354. */
  49355. constructor(options: ITimerOptions<T>);
  49356. /**
  49357. * set a breaking condition for this timer. Default is to never break during count
  49358. * @param predicate the new break condition. Returns true to break, false otherwise
  49359. */
  49360. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49361. /**
  49362. * Reset ALL associated observables in this advanced timer
  49363. */
  49364. clearObservables(): void;
  49365. /**
  49366. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49367. *
  49368. * @param timeToEnd how much time to measure until timer ended
  49369. */
  49370. start(timeToEnd?: number): void;
  49371. /**
  49372. * Will force a stop on the next tick.
  49373. */
  49374. stop(): void;
  49375. /**
  49376. * Dispose this timer, clearing all resources
  49377. */
  49378. dispose(): void;
  49379. private _setState;
  49380. private _tick;
  49381. private _stop;
  49382. }
  49383. }
  49384. declare module BABYLON {
  49385. /**
  49386. * The options container for the teleportation module
  49387. */
  49388. export interface IWebXRTeleportationOptions {
  49389. /**
  49390. * if provided, this scene will be used to render meshes.
  49391. */
  49392. customUtilityLayerScene?: Scene;
  49393. /**
  49394. * Values to configure the default target mesh
  49395. */
  49396. defaultTargetMeshOptions?: {
  49397. /**
  49398. * Fill color of the teleportation area
  49399. */
  49400. teleportationFillColor?: string;
  49401. /**
  49402. * Border color for the teleportation area
  49403. */
  49404. teleportationBorderColor?: string;
  49405. /**
  49406. * Disable the mesh's animation sequence
  49407. */
  49408. disableAnimation?: boolean;
  49409. /**
  49410. * Disable lighting on the material or the ring and arrow
  49411. */
  49412. disableLighting?: boolean;
  49413. /**
  49414. * Override the default material of the torus and arrow
  49415. */
  49416. torusArrowMaterial?: Material;
  49417. };
  49418. /**
  49419. * A list of meshes to use as floor meshes.
  49420. * Meshes can be added and removed after initializing the feature using the
  49421. * addFloorMesh and removeFloorMesh functions
  49422. * If empty, rotation will still work
  49423. */
  49424. floorMeshes?: AbstractMesh[];
  49425. /**
  49426. * use this rendering group id for the meshes (optional)
  49427. */
  49428. renderingGroupId?: number;
  49429. /**
  49430. * Should teleportation move only to snap points
  49431. */
  49432. snapPointsOnly?: boolean;
  49433. /**
  49434. * An array of points to which the teleportation will snap to.
  49435. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49436. */
  49437. snapPositions?: Vector3[];
  49438. /**
  49439. * How close should the teleportation ray be in order to snap to position.
  49440. * Default to 0.8 units (meters)
  49441. */
  49442. snapToPositionRadius?: number;
  49443. /**
  49444. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49445. * If you want to support rotation, make sure your mesh has a direction indicator.
  49446. *
  49447. * When left untouched, the default mesh will be initialized.
  49448. */
  49449. teleportationTargetMesh?: AbstractMesh;
  49450. /**
  49451. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49452. */
  49453. timeToTeleport?: number;
  49454. /**
  49455. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49456. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49457. */
  49458. useMainComponentOnly?: boolean;
  49459. /**
  49460. * Should meshes created here be added to a utility layer or the main scene
  49461. */
  49462. useUtilityLayer?: boolean;
  49463. /**
  49464. * Babylon XR Input class for controller
  49465. */
  49466. xrInput: WebXRInput;
  49467. /**
  49468. * Meshes that the teleportation ray cannot go through
  49469. */
  49470. pickBlockerMeshes?: AbstractMesh[];
  49471. }
  49472. /**
  49473. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49474. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49475. * the input of the attached controllers.
  49476. */
  49477. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49478. private _options;
  49479. private _controllers;
  49480. private _currentTeleportationControllerId;
  49481. private _floorMeshes;
  49482. private _quadraticBezierCurve;
  49483. private _selectionFeature;
  49484. private _snapToPositions;
  49485. private _snappedToPoint;
  49486. private _teleportationRingMaterial?;
  49487. private _tmpRay;
  49488. private _tmpVector;
  49489. private _tmpQuaternion;
  49490. /**
  49491. * The module's name
  49492. */
  49493. static readonly Name: string;
  49494. /**
  49495. * The (Babylon) version of this module.
  49496. * This is an integer representing the implementation version.
  49497. * This number does not correspond to the webxr specs version
  49498. */
  49499. static readonly Version: number;
  49500. /**
  49501. * Is movement backwards enabled
  49502. */
  49503. backwardsMovementEnabled: boolean;
  49504. /**
  49505. * Distance to travel when moving backwards
  49506. */
  49507. backwardsTeleportationDistance: number;
  49508. /**
  49509. * The distance from the user to the inspection point in the direction of the controller
  49510. * A higher number will allow the user to move further
  49511. * defaults to 5 (meters, in xr units)
  49512. */
  49513. parabolicCheckRadius: number;
  49514. /**
  49515. * Should the module support parabolic ray on top of direct ray
  49516. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49517. * Very helpful when moving between floors / different heights
  49518. */
  49519. parabolicRayEnabled: boolean;
  49520. /**
  49521. * How much rotation should be applied when rotating right and left
  49522. */
  49523. rotationAngle: number;
  49524. /**
  49525. * Is rotation enabled when moving forward?
  49526. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49527. */
  49528. rotationEnabled: boolean;
  49529. /**
  49530. * constructs a new anchor system
  49531. * @param _xrSessionManager an instance of WebXRSessionManager
  49532. * @param _options configuration object for this feature
  49533. */
  49534. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49535. /**
  49536. * Get the snapPointsOnly flag
  49537. */
  49538. get snapPointsOnly(): boolean;
  49539. /**
  49540. * Sets the snapPointsOnly flag
  49541. * @param snapToPoints should teleportation be exclusively to snap points
  49542. */
  49543. set snapPointsOnly(snapToPoints: boolean);
  49544. /**
  49545. * Add a new mesh to the floor meshes array
  49546. * @param mesh the mesh to use as floor mesh
  49547. */
  49548. addFloorMesh(mesh: AbstractMesh): void;
  49549. /**
  49550. * Add a new snap-to point to fix teleportation to this position
  49551. * @param newSnapPoint The new Snap-To point
  49552. */
  49553. addSnapPoint(newSnapPoint: Vector3): void;
  49554. attach(): boolean;
  49555. detach(): boolean;
  49556. dispose(): void;
  49557. /**
  49558. * Remove a mesh from the floor meshes array
  49559. * @param mesh the mesh to remove
  49560. */
  49561. removeFloorMesh(mesh: AbstractMesh): void;
  49562. /**
  49563. * Remove a mesh from the floor meshes array using its name
  49564. * @param name the mesh name to remove
  49565. */
  49566. removeFloorMeshByName(name: string): void;
  49567. /**
  49568. * 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
  49569. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49570. * @returns was the point found and removed or not
  49571. */
  49572. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49573. /**
  49574. * This function sets a selection feature that will be disabled when
  49575. * the forward ray is shown and will be reattached when hidden.
  49576. * This is used to remove the selection rays when moving.
  49577. * @param selectionFeature the feature to disable when forward movement is enabled
  49578. */
  49579. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  49580. protected _onXRFrame(_xrFrame: XRFrame): void;
  49581. private _attachController;
  49582. private _createDefaultTargetMesh;
  49583. private _detachController;
  49584. private _findClosestSnapPointWithRadius;
  49585. private _setTargetMeshPosition;
  49586. private _setTargetMeshVisibility;
  49587. private _showParabolicPath;
  49588. private _teleportForward;
  49589. }
  49590. }
  49591. declare module BABYLON {
  49592. /**
  49593. * Options for the default xr helper
  49594. */
  49595. export class WebXRDefaultExperienceOptions {
  49596. /**
  49597. * Enable or disable default UI to enter XR
  49598. */
  49599. disableDefaultUI?: boolean;
  49600. /**
  49601. * Should teleportation not initialize. defaults to false.
  49602. */
  49603. disableTeleportation?: boolean;
  49604. /**
  49605. * Floor meshes that will be used for teleport
  49606. */
  49607. floorMeshes?: Array<AbstractMesh>;
  49608. /**
  49609. * If set to true, the first frame will not be used to reset position
  49610. * The first frame is mainly used when copying transformation from the old camera
  49611. * Mainly used in AR
  49612. */
  49613. ignoreNativeCameraTransformation?: boolean;
  49614. /**
  49615. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49616. */
  49617. inputOptions?: IWebXRInputOptions;
  49618. /**
  49619. * optional configuration for the output canvas
  49620. */
  49621. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49622. /**
  49623. * optional UI options. This can be used among other to change session mode and reference space type
  49624. */
  49625. uiOptions?: WebXREnterExitUIOptions;
  49626. /**
  49627. * When loading teleportation and pointer select, use stable versions instead of latest.
  49628. */
  49629. useStablePlugins?: boolean;
  49630. /**
  49631. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49632. */
  49633. renderingGroupId?: number;
  49634. /**
  49635. * A list of optional features to init the session with
  49636. * If set to true, all features we support will be added
  49637. */
  49638. optionalFeatures?: boolean | string[];
  49639. }
  49640. /**
  49641. * Default experience which provides a similar setup to the previous webVRExperience
  49642. */
  49643. export class WebXRDefaultExperience {
  49644. /**
  49645. * Base experience
  49646. */
  49647. baseExperience: WebXRExperienceHelper;
  49648. /**
  49649. * Enables ui for entering/exiting xr
  49650. */
  49651. enterExitUI: WebXREnterExitUI;
  49652. /**
  49653. * Input experience extension
  49654. */
  49655. input: WebXRInput;
  49656. /**
  49657. * Enables laser pointer and selection
  49658. */
  49659. pointerSelection: WebXRControllerPointerSelection;
  49660. /**
  49661. * Default target xr should render to
  49662. */
  49663. renderTarget: WebXRRenderTarget;
  49664. /**
  49665. * Enables teleportation
  49666. */
  49667. teleportation: WebXRMotionControllerTeleportation;
  49668. private constructor();
  49669. /**
  49670. * Creates the default xr experience
  49671. * @param scene scene
  49672. * @param options options for basic configuration
  49673. * @returns resulting WebXRDefaultExperience
  49674. */
  49675. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49676. /**
  49677. * DIsposes of the experience helper
  49678. */
  49679. dispose(): void;
  49680. }
  49681. }
  49682. declare module BABYLON {
  49683. /**
  49684. * Options to modify the vr teleportation behavior.
  49685. */
  49686. export interface VRTeleportationOptions {
  49687. /**
  49688. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49689. */
  49690. floorMeshName?: string;
  49691. /**
  49692. * A list of meshes to be used as the teleportation floor. (default: empty)
  49693. */
  49694. floorMeshes?: Mesh[];
  49695. /**
  49696. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49697. */
  49698. teleportationMode?: number;
  49699. /**
  49700. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49701. */
  49702. teleportationTime?: number;
  49703. /**
  49704. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49705. */
  49706. teleportationSpeed?: number;
  49707. /**
  49708. * The easing function used in the animation or null for Linear. (default CircleEase)
  49709. */
  49710. easingFunction?: EasingFunction;
  49711. }
  49712. /**
  49713. * Options to modify the vr experience helper's behavior.
  49714. */
  49715. export interface VRExperienceHelperOptions extends WebVROptions {
  49716. /**
  49717. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49718. */
  49719. createDeviceOrientationCamera?: boolean;
  49720. /**
  49721. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49722. */
  49723. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49724. /**
  49725. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49726. */
  49727. laserToggle?: boolean;
  49728. /**
  49729. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49730. */
  49731. floorMeshes?: Mesh[];
  49732. /**
  49733. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49734. */
  49735. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49736. /**
  49737. * Defines if WebXR should be used instead of WebVR (if available)
  49738. */
  49739. useXR?: boolean;
  49740. }
  49741. /**
  49742. * Event containing information after VR has been entered
  49743. */
  49744. export class OnAfterEnteringVRObservableEvent {
  49745. /**
  49746. * If entering vr was successful
  49747. */
  49748. success: boolean;
  49749. }
  49750. /**
  49751. * Helps to quickly add VR support to an existing scene.
  49752. * See https://doc.babylonjs.com/how_to/webvr_helper
  49753. */
  49754. export class VRExperienceHelper {
  49755. /** Options to modify the vr experience helper's behavior. */
  49756. webVROptions: VRExperienceHelperOptions;
  49757. private _scene;
  49758. private _position;
  49759. private _btnVR;
  49760. private _btnVRDisplayed;
  49761. private _webVRsupported;
  49762. private _webVRready;
  49763. private _webVRrequesting;
  49764. private _webVRpresenting;
  49765. private _hasEnteredVR;
  49766. private _fullscreenVRpresenting;
  49767. private _inputElement;
  49768. private _webVRCamera;
  49769. private _vrDeviceOrientationCamera;
  49770. private _deviceOrientationCamera;
  49771. private _existingCamera;
  49772. private _onKeyDown;
  49773. private _onVrDisplayPresentChange;
  49774. private _onVRDisplayChanged;
  49775. private _onVRRequestPresentStart;
  49776. private _onVRRequestPresentComplete;
  49777. /**
  49778. * 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)
  49779. */
  49780. enableGazeEvenWhenNoPointerLock: boolean;
  49781. /**
  49782. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49783. */
  49784. exitVROnDoubleTap: boolean;
  49785. /**
  49786. * Observable raised right before entering VR.
  49787. */
  49788. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49789. /**
  49790. * Observable raised when entering VR has completed.
  49791. */
  49792. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49793. /**
  49794. * Observable raised when exiting VR.
  49795. */
  49796. onExitingVRObservable: Observable<VRExperienceHelper>;
  49797. /**
  49798. * Observable raised when controller mesh is loaded.
  49799. */
  49800. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49801. /** Return this.onEnteringVRObservable
  49802. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49803. */
  49804. get onEnteringVR(): Observable<VRExperienceHelper>;
  49805. /** Return this.onExitingVRObservable
  49806. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49807. */
  49808. get onExitingVR(): Observable<VRExperienceHelper>;
  49809. /** Return this.onControllerMeshLoadedObservable
  49810. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49811. */
  49812. get onControllerMeshLoaded(): Observable<WebVRController>;
  49813. private _rayLength;
  49814. private _useCustomVRButton;
  49815. private _teleportationRequested;
  49816. private _teleportActive;
  49817. private _floorMeshName;
  49818. private _floorMeshesCollection;
  49819. private _teleportationMode;
  49820. private _teleportationTime;
  49821. private _teleportationSpeed;
  49822. private _teleportationEasing;
  49823. private _rotationAllowed;
  49824. private _teleportBackwardsVector;
  49825. private _teleportationTarget;
  49826. private _isDefaultTeleportationTarget;
  49827. private _postProcessMove;
  49828. private _teleportationFillColor;
  49829. private _teleportationBorderColor;
  49830. private _rotationAngle;
  49831. private _haloCenter;
  49832. private _cameraGazer;
  49833. private _padSensibilityUp;
  49834. private _padSensibilityDown;
  49835. private _leftController;
  49836. private _rightController;
  49837. private _gazeColor;
  49838. private _laserColor;
  49839. private _pickedLaserColor;
  49840. private _pickedGazeColor;
  49841. /**
  49842. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49843. */
  49844. onNewMeshSelected: Observable<AbstractMesh>;
  49845. /**
  49846. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49847. * This observable will provide the mesh and the controller used to select the mesh
  49848. */
  49849. onMeshSelectedWithController: Observable<{
  49850. mesh: AbstractMesh;
  49851. controller: WebVRController;
  49852. }>;
  49853. /**
  49854. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49855. */
  49856. onNewMeshPicked: Observable<PickingInfo>;
  49857. private _circleEase;
  49858. /**
  49859. * Observable raised before camera teleportation
  49860. */
  49861. onBeforeCameraTeleport: Observable<Vector3>;
  49862. /**
  49863. * Observable raised after camera teleportation
  49864. */
  49865. onAfterCameraTeleport: Observable<Vector3>;
  49866. /**
  49867. * Observable raised when current selected mesh gets unselected
  49868. */
  49869. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49870. private _raySelectionPredicate;
  49871. /**
  49872. * To be optionaly changed by user to define custom ray selection
  49873. */
  49874. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49875. /**
  49876. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49877. */
  49878. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49879. /**
  49880. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49881. */
  49882. teleportationEnabled: boolean;
  49883. private _defaultHeight;
  49884. private _teleportationInitialized;
  49885. private _interactionsEnabled;
  49886. private _interactionsRequested;
  49887. private _displayGaze;
  49888. private _displayLaserPointer;
  49889. /**
  49890. * The mesh used to display where the user is going to teleport.
  49891. */
  49892. get teleportationTarget(): Mesh;
  49893. /**
  49894. * Sets the mesh to be used to display where the user is going to teleport.
  49895. */
  49896. set teleportationTarget(value: Mesh);
  49897. /**
  49898. * 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
  49899. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49900. * See https://doc.babylonjs.com/resources/baking_transformations
  49901. */
  49902. get gazeTrackerMesh(): Mesh;
  49903. set gazeTrackerMesh(value: Mesh);
  49904. /**
  49905. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49906. */
  49907. updateGazeTrackerScale: boolean;
  49908. /**
  49909. * If the gaze trackers color should be updated when selecting meshes
  49910. */
  49911. updateGazeTrackerColor: boolean;
  49912. /**
  49913. * If the controller laser color should be updated when selecting meshes
  49914. */
  49915. updateControllerLaserColor: boolean;
  49916. /**
  49917. * The gaze tracking mesh corresponding to the left controller
  49918. */
  49919. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49920. /**
  49921. * The gaze tracking mesh corresponding to the right controller
  49922. */
  49923. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49924. /**
  49925. * If the ray of the gaze should be displayed.
  49926. */
  49927. get displayGaze(): boolean;
  49928. /**
  49929. * Sets if the ray of the gaze should be displayed.
  49930. */
  49931. set displayGaze(value: boolean);
  49932. /**
  49933. * If the ray of the LaserPointer should be displayed.
  49934. */
  49935. get displayLaserPointer(): boolean;
  49936. /**
  49937. * Sets if the ray of the LaserPointer should be displayed.
  49938. */
  49939. set displayLaserPointer(value: boolean);
  49940. /**
  49941. * The deviceOrientationCamera used as the camera when not in VR.
  49942. */
  49943. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49944. /**
  49945. * Based on the current WebVR support, returns the current VR camera used.
  49946. */
  49947. get currentVRCamera(): Nullable<Camera>;
  49948. /**
  49949. * The webVRCamera which is used when in VR.
  49950. */
  49951. get webVRCamera(): WebVRFreeCamera;
  49952. /**
  49953. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49954. */
  49955. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49956. /**
  49957. * The html button that is used to trigger entering into VR.
  49958. */
  49959. get vrButton(): Nullable<HTMLButtonElement>;
  49960. private get _teleportationRequestInitiated();
  49961. /**
  49962. * Defines whether or not Pointer lock should be requested when switching to
  49963. * full screen.
  49964. */
  49965. requestPointerLockOnFullScreen: boolean;
  49966. /**
  49967. * If asking to force XR, this will be populated with the default xr experience
  49968. */
  49969. xr: WebXRDefaultExperience;
  49970. /**
  49971. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49972. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49973. */
  49974. xrTestDone: boolean;
  49975. /**
  49976. * Instantiates a VRExperienceHelper.
  49977. * Helps to quickly add VR support to an existing scene.
  49978. * @param scene The scene the VRExperienceHelper belongs to.
  49979. * @param webVROptions Options to modify the vr experience helper's behavior.
  49980. */
  49981. constructor(scene: Scene,
  49982. /** Options to modify the vr experience helper's behavior. */
  49983. webVROptions?: VRExperienceHelperOptions);
  49984. private completeVRInit;
  49985. private _onDefaultMeshLoaded;
  49986. private _onResize;
  49987. private _onFullscreenChange;
  49988. /**
  49989. * Gets a value indicating if we are currently in VR mode.
  49990. */
  49991. get isInVRMode(): boolean;
  49992. private onVrDisplayPresentChange;
  49993. private onVRDisplayChanged;
  49994. private moveButtonToBottomRight;
  49995. private displayVRButton;
  49996. private updateButtonVisibility;
  49997. private _cachedAngularSensibility;
  49998. /**
  49999. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50000. * Otherwise, will use the fullscreen API.
  50001. */
  50002. enterVR(): void;
  50003. /**
  50004. * Attempt to exit VR, or fullscreen.
  50005. */
  50006. exitVR(): void;
  50007. /**
  50008. * The position of the vr experience helper.
  50009. */
  50010. get position(): Vector3;
  50011. /**
  50012. * Sets the position of the vr experience helper.
  50013. */
  50014. set position(value: Vector3);
  50015. /**
  50016. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50017. */
  50018. enableInteractions(): void;
  50019. private get _noControllerIsActive();
  50020. private beforeRender;
  50021. private _isTeleportationFloor;
  50022. /**
  50023. * Adds a floor mesh to be used for teleportation.
  50024. * @param floorMesh the mesh to be used for teleportation.
  50025. */
  50026. addFloorMesh(floorMesh: Mesh): void;
  50027. /**
  50028. * Removes a floor mesh from being used for teleportation.
  50029. * @param floorMesh the mesh to be removed.
  50030. */
  50031. removeFloorMesh(floorMesh: Mesh): void;
  50032. /**
  50033. * Enables interactions and teleportation using the VR controllers and gaze.
  50034. * @param vrTeleportationOptions options to modify teleportation behavior.
  50035. */
  50036. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50037. private _onNewGamepadConnected;
  50038. private _tryEnableInteractionOnController;
  50039. private _onNewGamepadDisconnected;
  50040. private _enableInteractionOnController;
  50041. private _checkTeleportWithRay;
  50042. private _checkRotate;
  50043. private _checkTeleportBackwards;
  50044. private _enableTeleportationOnController;
  50045. private _createTeleportationCircles;
  50046. private _displayTeleportationTarget;
  50047. private _hideTeleportationTarget;
  50048. private _rotateCamera;
  50049. private _moveTeleportationSelectorTo;
  50050. private _workingVector;
  50051. private _workingQuaternion;
  50052. private _workingMatrix;
  50053. /**
  50054. * Time Constant Teleportation Mode
  50055. */
  50056. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50057. /**
  50058. * Speed Constant Teleportation Mode
  50059. */
  50060. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50061. /**
  50062. * Teleports the users feet to the desired location
  50063. * @param location The location where the user's feet should be placed
  50064. */
  50065. teleportCamera(location: Vector3): void;
  50066. private _convertNormalToDirectionOfRay;
  50067. private _castRayAndSelectObject;
  50068. private _notifySelectedMeshUnselected;
  50069. /**
  50070. * Permanently set new colors for the laser pointer
  50071. * @param color the new laser color
  50072. * @param pickedColor the new laser color when picked mesh detected
  50073. */
  50074. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50075. /**
  50076. * Set lighting enabled / disabled on the laser pointer of both controllers
  50077. * @param enabled should the lighting be enabled on the laser pointer
  50078. */
  50079. setLaserLightingState(enabled?: boolean): void;
  50080. /**
  50081. * Permanently set new colors for the gaze pointer
  50082. * @param color the new gaze color
  50083. * @param pickedColor the new gaze color when picked mesh detected
  50084. */
  50085. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50086. /**
  50087. * Sets the color of the laser ray from the vr controllers.
  50088. * @param color new color for the ray.
  50089. */
  50090. changeLaserColor(color: Color3): void;
  50091. /**
  50092. * Sets the color of the ray from the vr headsets gaze.
  50093. * @param color new color for the ray.
  50094. */
  50095. changeGazeColor(color: Color3): void;
  50096. /**
  50097. * Exits VR and disposes of the vr experience helper
  50098. */
  50099. dispose(): void;
  50100. /**
  50101. * Gets the name of the VRExperienceHelper class
  50102. * @returns "VRExperienceHelper"
  50103. */
  50104. getClassName(): string;
  50105. }
  50106. }
  50107. declare module BABYLON {
  50108. /**
  50109. * Contains an array of blocks representing the octree
  50110. */
  50111. export interface IOctreeContainer<T> {
  50112. /**
  50113. * Blocks within the octree
  50114. */
  50115. blocks: Array<OctreeBlock<T>>;
  50116. }
  50117. /**
  50118. * Class used to store a cell in an octree
  50119. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50120. */
  50121. export class OctreeBlock<T> {
  50122. /**
  50123. * Gets the content of the current block
  50124. */
  50125. entries: T[];
  50126. /**
  50127. * Gets the list of block children
  50128. */
  50129. blocks: Array<OctreeBlock<T>>;
  50130. private _depth;
  50131. private _maxDepth;
  50132. private _capacity;
  50133. private _minPoint;
  50134. private _maxPoint;
  50135. private _boundingVectors;
  50136. private _creationFunc;
  50137. /**
  50138. * Creates a new block
  50139. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50140. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50141. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50142. * @param depth defines the current depth of this block in the octree
  50143. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50144. * @param creationFunc defines a callback to call when an element is added to the block
  50145. */
  50146. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50147. /**
  50148. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50149. */
  50150. get capacity(): number;
  50151. /**
  50152. * Gets the minimum vector (in world space) of the block's bounding box
  50153. */
  50154. get minPoint(): Vector3;
  50155. /**
  50156. * Gets the maximum vector (in world space) of the block's bounding box
  50157. */
  50158. get maxPoint(): Vector3;
  50159. /**
  50160. * Add a new element to this block
  50161. * @param entry defines the element to add
  50162. */
  50163. addEntry(entry: T): void;
  50164. /**
  50165. * Remove an element from this block
  50166. * @param entry defines the element to remove
  50167. */
  50168. removeEntry(entry: T): void;
  50169. /**
  50170. * Add an array of elements to this block
  50171. * @param entries defines the array of elements to add
  50172. */
  50173. addEntries(entries: T[]): void;
  50174. /**
  50175. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50176. * @param frustumPlanes defines the frustum planes to test
  50177. * @param selection defines the array to store current content if selection is positive
  50178. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50179. */
  50180. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50181. /**
  50182. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50183. * @param sphereCenter defines the bounding sphere center
  50184. * @param sphereRadius defines the bounding sphere radius
  50185. * @param selection defines the array to store current content if selection is positive
  50186. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50187. */
  50188. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50189. /**
  50190. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50191. * @param ray defines the ray to test with
  50192. * @param selection defines the array to store current content if selection is positive
  50193. */
  50194. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50195. /**
  50196. * Subdivide the content into child blocks (this block will then be empty)
  50197. */
  50198. createInnerBlocks(): void;
  50199. /**
  50200. * @hidden
  50201. */
  50202. 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;
  50203. }
  50204. }
  50205. declare module BABYLON {
  50206. /**
  50207. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50208. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50209. */
  50210. export class Octree<T> {
  50211. /** 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.) */
  50212. maxDepth: number;
  50213. /**
  50214. * Blocks within the octree containing objects
  50215. */
  50216. blocks: Array<OctreeBlock<T>>;
  50217. /**
  50218. * Content stored in the octree
  50219. */
  50220. dynamicContent: T[];
  50221. private _maxBlockCapacity;
  50222. private _selectionContent;
  50223. private _creationFunc;
  50224. /**
  50225. * Creates a octree
  50226. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50227. * @param creationFunc function to be used to instatiate the octree
  50228. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50229. * @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.)
  50230. */
  50231. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50232. /** 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.) */
  50233. maxDepth?: number);
  50234. /**
  50235. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50236. * @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);
  50237. * @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);
  50238. * @param entries meshes to be added to the octree blocks
  50239. */
  50240. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50241. /**
  50242. * Adds a mesh to the octree
  50243. * @param entry Mesh to add to the octree
  50244. */
  50245. addMesh(entry: T): void;
  50246. /**
  50247. * Remove an element from the octree
  50248. * @param entry defines the element to remove
  50249. */
  50250. removeMesh(entry: T): void;
  50251. /**
  50252. * Selects an array of meshes within the frustum
  50253. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50254. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50255. * @returns array of meshes within the frustum
  50256. */
  50257. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50258. /**
  50259. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50260. * @param sphereCenter defines the bounding sphere center
  50261. * @param sphereRadius defines the bounding sphere radius
  50262. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50263. * @returns an array of objects that intersect the sphere
  50264. */
  50265. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50266. /**
  50267. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50268. * @param ray defines the ray to test with
  50269. * @returns array of intersected objects
  50270. */
  50271. intersectsRay(ray: Ray): SmartArray<T>;
  50272. /**
  50273. * Adds a mesh into the octree block if it intersects the block
  50274. */
  50275. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50276. /**
  50277. * Adds a submesh into the octree block if it intersects the block
  50278. */
  50279. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50280. }
  50281. }
  50282. declare module BABYLON {
  50283. interface Scene {
  50284. /**
  50285. * @hidden
  50286. * Backing Filed
  50287. */
  50288. _selectionOctree: Octree<AbstractMesh>;
  50289. /**
  50290. * Gets the octree used to boost mesh selection (picking)
  50291. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50292. */
  50293. selectionOctree: Octree<AbstractMesh>;
  50294. /**
  50295. * Creates or updates the octree used to boost selection (picking)
  50296. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50297. * @param maxCapacity defines the maximum capacity per leaf
  50298. * @param maxDepth defines the maximum depth of the octree
  50299. * @returns an octree of AbstractMesh
  50300. */
  50301. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50302. }
  50303. interface AbstractMesh {
  50304. /**
  50305. * @hidden
  50306. * Backing Field
  50307. */
  50308. _submeshesOctree: Octree<SubMesh>;
  50309. /**
  50310. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50311. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50312. * @param maxCapacity defines the maximum size of each block (64 by default)
  50313. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50314. * @returns the new octree
  50315. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50316. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50317. */
  50318. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50319. }
  50320. /**
  50321. * Defines the octree scene component responsible to manage any octrees
  50322. * in a given scene.
  50323. */
  50324. export class OctreeSceneComponent {
  50325. /**
  50326. * The component name help to identify the component in the list of scene components.
  50327. */
  50328. readonly name: string;
  50329. /**
  50330. * The scene the component belongs to.
  50331. */
  50332. scene: Scene;
  50333. /**
  50334. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50335. */
  50336. readonly checksIsEnabled: boolean;
  50337. /**
  50338. * Creates a new instance of the component for the given scene
  50339. * @param scene Defines the scene to register the component in
  50340. */
  50341. constructor(scene: Scene);
  50342. /**
  50343. * Registers the component in a given scene
  50344. */
  50345. register(): void;
  50346. /**
  50347. * Return the list of active meshes
  50348. * @returns the list of active meshes
  50349. */
  50350. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50351. /**
  50352. * Return the list of active sub meshes
  50353. * @param mesh The mesh to get the candidates sub meshes from
  50354. * @returns the list of active sub meshes
  50355. */
  50356. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50357. private _tempRay;
  50358. /**
  50359. * Return the list of sub meshes intersecting with a given local ray
  50360. * @param mesh defines the mesh to find the submesh for
  50361. * @param localRay defines the ray in local space
  50362. * @returns the list of intersecting sub meshes
  50363. */
  50364. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50365. /**
  50366. * Return the list of sub meshes colliding with a collider
  50367. * @param mesh defines the mesh to find the submesh for
  50368. * @param collider defines the collider to evaluate the collision against
  50369. * @returns the list of colliding sub meshes
  50370. */
  50371. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50372. /**
  50373. * Rebuilds the elements related to this component in case of
  50374. * context lost for instance.
  50375. */
  50376. rebuild(): void;
  50377. /**
  50378. * Disposes the component and the associated ressources.
  50379. */
  50380. dispose(): void;
  50381. }
  50382. }
  50383. declare module BABYLON {
  50384. /**
  50385. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50386. */
  50387. export class Gizmo implements IDisposable {
  50388. /** The utility layer the gizmo will be added to */
  50389. gizmoLayer: UtilityLayerRenderer;
  50390. /**
  50391. * The root mesh of the gizmo
  50392. */
  50393. _rootMesh: Mesh;
  50394. private _attachedMesh;
  50395. private _attachedNode;
  50396. /**
  50397. * Ratio for the scale of the gizmo (Default: 1)
  50398. */
  50399. protected _scaleRatio: number;
  50400. /**
  50401. * Ratio for the scale of the gizmo (Default: 1)
  50402. */
  50403. set scaleRatio(value: number);
  50404. get scaleRatio(): number;
  50405. /**
  50406. * If a custom mesh has been set (Default: false)
  50407. */
  50408. protected _customMeshSet: boolean;
  50409. /**
  50410. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50411. * * When set, interactions will be enabled
  50412. */
  50413. get attachedMesh(): Nullable<AbstractMesh>;
  50414. set attachedMesh(value: Nullable<AbstractMesh>);
  50415. /**
  50416. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50417. * * When set, interactions will be enabled
  50418. */
  50419. get attachedNode(): Nullable<Node>;
  50420. set attachedNode(value: Nullable<Node>);
  50421. /**
  50422. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50423. * @param mesh The mesh to replace the default mesh of the gizmo
  50424. */
  50425. setCustomMesh(mesh: Mesh): void;
  50426. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50427. /**
  50428. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50429. */
  50430. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50431. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50432. /**
  50433. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50434. */
  50435. updateGizmoPositionToMatchAttachedMesh: boolean;
  50436. /**
  50437. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50438. */
  50439. updateScale: boolean;
  50440. protected _interactionsEnabled: boolean;
  50441. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50442. private _beforeRenderObserver;
  50443. private _tempQuaternion;
  50444. private _tempVector;
  50445. private _tempVector2;
  50446. private _tempMatrix1;
  50447. private _tempMatrix2;
  50448. private _rightHandtoLeftHandMatrix;
  50449. /**
  50450. * Creates a gizmo
  50451. * @param gizmoLayer The utility layer the gizmo will be added to
  50452. */
  50453. constructor(
  50454. /** The utility layer the gizmo will be added to */
  50455. gizmoLayer?: UtilityLayerRenderer);
  50456. /**
  50457. * Updates the gizmo to match the attached mesh's position/rotation
  50458. */
  50459. protected _update(): void;
  50460. /**
  50461. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50462. * @param value Node, TransformNode or mesh
  50463. */
  50464. protected _matrixChanged(): void;
  50465. /**
  50466. * Disposes of the gizmo
  50467. */
  50468. dispose(): void;
  50469. }
  50470. }
  50471. declare module BABYLON {
  50472. /**
  50473. * Single plane drag gizmo
  50474. */
  50475. export class PlaneDragGizmo extends Gizmo {
  50476. /**
  50477. * Drag behavior responsible for the gizmos dragging interactions
  50478. */
  50479. dragBehavior: PointerDragBehavior;
  50480. private _pointerObserver;
  50481. /**
  50482. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50483. */
  50484. snapDistance: number;
  50485. /**
  50486. * Event that fires each time the gizmo snaps to a new location.
  50487. * * snapDistance is the the change in distance
  50488. */
  50489. onSnapObservable: Observable<{
  50490. snapDistance: number;
  50491. }>;
  50492. private _plane;
  50493. private _coloredMaterial;
  50494. private _hoverMaterial;
  50495. private _isEnabled;
  50496. private _parent;
  50497. /** @hidden */
  50498. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50499. /** @hidden */
  50500. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50501. /**
  50502. * Creates a PlaneDragGizmo
  50503. * @param gizmoLayer The utility layer the gizmo will be added to
  50504. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50505. * @param color The color of the gizmo
  50506. */
  50507. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50508. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50509. /**
  50510. * If the gizmo is enabled
  50511. */
  50512. set isEnabled(value: boolean);
  50513. get isEnabled(): boolean;
  50514. /**
  50515. * Disposes of the gizmo
  50516. */
  50517. dispose(): void;
  50518. }
  50519. }
  50520. declare module BABYLON {
  50521. /**
  50522. * Gizmo that enables dragging a mesh along 3 axis
  50523. */
  50524. export class PositionGizmo extends Gizmo {
  50525. /**
  50526. * Internal gizmo used for interactions on the x axis
  50527. */
  50528. xGizmo: AxisDragGizmo;
  50529. /**
  50530. * Internal gizmo used for interactions on the y axis
  50531. */
  50532. yGizmo: AxisDragGizmo;
  50533. /**
  50534. * Internal gizmo used for interactions on the z axis
  50535. */
  50536. zGizmo: AxisDragGizmo;
  50537. /**
  50538. * Internal gizmo used for interactions on the yz plane
  50539. */
  50540. xPlaneGizmo: PlaneDragGizmo;
  50541. /**
  50542. * Internal gizmo used for interactions on the xz plane
  50543. */
  50544. yPlaneGizmo: PlaneDragGizmo;
  50545. /**
  50546. * Internal gizmo used for interactions on the xy plane
  50547. */
  50548. zPlaneGizmo: PlaneDragGizmo;
  50549. /**
  50550. * private variables
  50551. */
  50552. private _meshAttached;
  50553. private _nodeAttached;
  50554. private _snapDistance;
  50555. /** Fires an event when any of it's sub gizmos are dragged */
  50556. onDragStartObservable: Observable<unknown>;
  50557. /** Fires an event when any of it's sub gizmos are released from dragging */
  50558. onDragEndObservable: Observable<unknown>;
  50559. /**
  50560. * If set to true, planar drag is enabled
  50561. */
  50562. private _planarGizmoEnabled;
  50563. get attachedMesh(): Nullable<AbstractMesh>;
  50564. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50565. get attachedNode(): Nullable<Node>;
  50566. set attachedNode(node: Nullable<Node>);
  50567. /**
  50568. * Creates a PositionGizmo
  50569. * @param gizmoLayer The utility layer the gizmo will be added to
  50570. @param thickness display gizmo axis thickness
  50571. */
  50572. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50573. /**
  50574. * If the planar drag gizmo is enabled
  50575. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50576. */
  50577. set planarGizmoEnabled(value: boolean);
  50578. get planarGizmoEnabled(): boolean;
  50579. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50580. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50581. /**
  50582. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50583. */
  50584. set snapDistance(value: number);
  50585. get snapDistance(): number;
  50586. /**
  50587. * Ratio for the scale of the gizmo (Default: 1)
  50588. */
  50589. set scaleRatio(value: number);
  50590. get scaleRatio(): number;
  50591. /**
  50592. * Disposes of the gizmo
  50593. */
  50594. dispose(): void;
  50595. /**
  50596. * CustomMeshes are not supported by this gizmo
  50597. * @param mesh The mesh to replace the default mesh of the gizmo
  50598. */
  50599. setCustomMesh(mesh: Mesh): void;
  50600. }
  50601. }
  50602. declare module BABYLON {
  50603. /**
  50604. * Single axis drag gizmo
  50605. */
  50606. export class AxisDragGizmo extends Gizmo {
  50607. /**
  50608. * Drag behavior responsible for the gizmos dragging interactions
  50609. */
  50610. dragBehavior: PointerDragBehavior;
  50611. private _pointerObserver;
  50612. /**
  50613. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50614. */
  50615. snapDistance: number;
  50616. /**
  50617. * Event that fires each time the gizmo snaps to a new location.
  50618. * * snapDistance is the the change in distance
  50619. */
  50620. onSnapObservable: Observable<{
  50621. snapDistance: number;
  50622. }>;
  50623. private _isEnabled;
  50624. private _parent;
  50625. private _arrow;
  50626. private _coloredMaterial;
  50627. private _hoverMaterial;
  50628. /** @hidden */
  50629. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50630. /** @hidden */
  50631. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50632. /**
  50633. * Creates an AxisDragGizmo
  50634. * @param gizmoLayer The utility layer the gizmo will be added to
  50635. * @param dragAxis The axis which the gizmo will be able to drag on
  50636. * @param color The color of the gizmo
  50637. * @param thickness display gizmo axis thickness
  50638. */
  50639. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50640. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50641. /**
  50642. * If the gizmo is enabled
  50643. */
  50644. set isEnabled(value: boolean);
  50645. get isEnabled(): boolean;
  50646. /**
  50647. * Disposes of the gizmo
  50648. */
  50649. dispose(): void;
  50650. }
  50651. }
  50652. declare module BABYLON.Debug {
  50653. /**
  50654. * The Axes viewer will show 3 axes in a specific point in space
  50655. */
  50656. export class AxesViewer {
  50657. private _xAxis;
  50658. private _yAxis;
  50659. private _zAxis;
  50660. private _scaleLinesFactor;
  50661. private _instanced;
  50662. /**
  50663. * Gets the hosting scene
  50664. */
  50665. scene: Nullable<Scene>;
  50666. /**
  50667. * Gets or sets a number used to scale line length
  50668. */
  50669. scaleLines: number;
  50670. /** Gets the node hierarchy used to render x-axis */
  50671. get xAxis(): TransformNode;
  50672. /** Gets the node hierarchy used to render y-axis */
  50673. get yAxis(): TransformNode;
  50674. /** Gets the node hierarchy used to render z-axis */
  50675. get zAxis(): TransformNode;
  50676. /**
  50677. * Creates a new AxesViewer
  50678. * @param scene defines the hosting scene
  50679. * @param scaleLines defines a number used to scale line length (1 by default)
  50680. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50681. * @param xAxis defines the node hierarchy used to render the x-axis
  50682. * @param yAxis defines the node hierarchy used to render the y-axis
  50683. * @param zAxis defines the node hierarchy used to render the z-axis
  50684. */
  50685. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50686. /**
  50687. * Force the viewer to update
  50688. * @param position defines the position of the viewer
  50689. * @param xaxis defines the x axis of the viewer
  50690. * @param yaxis defines the y axis of the viewer
  50691. * @param zaxis defines the z axis of the viewer
  50692. */
  50693. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50694. /**
  50695. * Creates an instance of this axes viewer.
  50696. * @returns a new axes viewer with instanced meshes
  50697. */
  50698. createInstance(): AxesViewer;
  50699. /** Releases resources */
  50700. dispose(): void;
  50701. private static _SetRenderingGroupId;
  50702. }
  50703. }
  50704. declare module BABYLON.Debug {
  50705. /**
  50706. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50707. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50708. */
  50709. export class BoneAxesViewer extends AxesViewer {
  50710. /**
  50711. * Gets or sets the target mesh where to display the axes viewer
  50712. */
  50713. mesh: Nullable<Mesh>;
  50714. /**
  50715. * Gets or sets the target bone where to display the axes viewer
  50716. */
  50717. bone: Nullable<Bone>;
  50718. /** Gets current position */
  50719. pos: Vector3;
  50720. /** Gets direction of X axis */
  50721. xaxis: Vector3;
  50722. /** Gets direction of Y axis */
  50723. yaxis: Vector3;
  50724. /** Gets direction of Z axis */
  50725. zaxis: Vector3;
  50726. /**
  50727. * Creates a new BoneAxesViewer
  50728. * @param scene defines the hosting scene
  50729. * @param bone defines the target bone
  50730. * @param mesh defines the target mesh
  50731. * @param scaleLines defines a scaling factor for line length (1 by default)
  50732. */
  50733. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50734. /**
  50735. * Force the viewer to update
  50736. */
  50737. update(): void;
  50738. /** Releases resources */
  50739. dispose(): void;
  50740. }
  50741. }
  50742. declare module BABYLON {
  50743. /**
  50744. * Interface used to define scene explorer extensibility option
  50745. */
  50746. export interface IExplorerExtensibilityOption {
  50747. /**
  50748. * Define the option label
  50749. */
  50750. label: string;
  50751. /**
  50752. * Defines the action to execute on click
  50753. */
  50754. action: (entity: any) => void;
  50755. }
  50756. /**
  50757. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50758. */
  50759. export interface IExplorerExtensibilityGroup {
  50760. /**
  50761. * Defines a predicate to test if a given type mut be extended
  50762. */
  50763. predicate: (entity: any) => boolean;
  50764. /**
  50765. * Gets the list of options added to a type
  50766. */
  50767. entries: IExplorerExtensibilityOption[];
  50768. }
  50769. /**
  50770. * Interface used to define the options to use to create the Inspector
  50771. */
  50772. export interface IInspectorOptions {
  50773. /**
  50774. * Display in overlay mode (default: false)
  50775. */
  50776. overlay?: boolean;
  50777. /**
  50778. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50779. */
  50780. globalRoot?: HTMLElement;
  50781. /**
  50782. * Display the Scene explorer
  50783. */
  50784. showExplorer?: boolean;
  50785. /**
  50786. * Display the property inspector
  50787. */
  50788. showInspector?: boolean;
  50789. /**
  50790. * Display in embed mode (both panes on the right)
  50791. */
  50792. embedMode?: boolean;
  50793. /**
  50794. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50795. */
  50796. handleResize?: boolean;
  50797. /**
  50798. * Allow the panes to popup (default: true)
  50799. */
  50800. enablePopup?: boolean;
  50801. /**
  50802. * Allow the panes to be closed by users (default: true)
  50803. */
  50804. enableClose?: boolean;
  50805. /**
  50806. * Optional list of extensibility entries
  50807. */
  50808. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50809. /**
  50810. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50811. */
  50812. inspectorURL?: string;
  50813. /**
  50814. * Optional initial tab (default to DebugLayerTab.Properties)
  50815. */
  50816. initialTab?: DebugLayerTab;
  50817. }
  50818. interface Scene {
  50819. /**
  50820. * @hidden
  50821. * Backing field
  50822. */
  50823. _debugLayer: DebugLayer;
  50824. /**
  50825. * Gets the debug layer (aka Inspector) associated with the scene
  50826. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50827. */
  50828. debugLayer: DebugLayer;
  50829. }
  50830. /**
  50831. * Enum of inspector action tab
  50832. */
  50833. export enum DebugLayerTab {
  50834. /**
  50835. * Properties tag (default)
  50836. */
  50837. Properties = 0,
  50838. /**
  50839. * Debug tab
  50840. */
  50841. Debug = 1,
  50842. /**
  50843. * Statistics tab
  50844. */
  50845. Statistics = 2,
  50846. /**
  50847. * Tools tab
  50848. */
  50849. Tools = 3,
  50850. /**
  50851. * Settings tab
  50852. */
  50853. Settings = 4
  50854. }
  50855. /**
  50856. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50857. * what is happening in your scene
  50858. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50859. */
  50860. export class DebugLayer {
  50861. /**
  50862. * Define the url to get the inspector script from.
  50863. * By default it uses the babylonjs CDN.
  50864. * @ignoreNaming
  50865. */
  50866. static InspectorURL: string;
  50867. private _scene;
  50868. private BJSINSPECTOR;
  50869. private _onPropertyChangedObservable?;
  50870. /**
  50871. * Observable triggered when a property is changed through the inspector.
  50872. */
  50873. get onPropertyChangedObservable(): any;
  50874. /**
  50875. * Instantiates a new debug layer.
  50876. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50877. * what is happening in your scene
  50878. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50879. * @param scene Defines the scene to inspect
  50880. */
  50881. constructor(scene: Scene);
  50882. /** Creates the inspector window. */
  50883. private _createInspector;
  50884. /**
  50885. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50886. * @param entity defines the entity to select
  50887. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50888. */
  50889. select(entity: any, lineContainerTitles?: string | string[]): void;
  50890. /** Get the inspector from bundle or global */
  50891. private _getGlobalInspector;
  50892. /**
  50893. * Get if the inspector is visible or not.
  50894. * @returns true if visible otherwise, false
  50895. */
  50896. isVisible(): boolean;
  50897. /**
  50898. * Hide the inspector and close its window.
  50899. */
  50900. hide(): void;
  50901. /**
  50902. * Update the scene in the inspector
  50903. */
  50904. setAsActiveScene(): void;
  50905. /**
  50906. * Launch the debugLayer.
  50907. * @param config Define the configuration of the inspector
  50908. * @return a promise fulfilled when the debug layer is visible
  50909. */
  50910. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50911. }
  50912. }
  50913. declare module BABYLON {
  50914. /**
  50915. * Class containing static functions to help procedurally build meshes
  50916. */
  50917. export class BoxBuilder {
  50918. /**
  50919. * Creates a box mesh
  50920. * * The parameter `size` sets the size (float) of each box side (default 1)
  50921. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50922. * * 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)
  50923. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50925. * * 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
  50926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50927. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50928. * @param name defines the name of the mesh
  50929. * @param options defines the options used to create the mesh
  50930. * @param scene defines the hosting scene
  50931. * @returns the box mesh
  50932. */
  50933. static CreateBox(name: string, options: {
  50934. size?: number;
  50935. width?: number;
  50936. height?: number;
  50937. depth?: number;
  50938. faceUV?: Vector4[];
  50939. faceColors?: Color4[];
  50940. sideOrientation?: number;
  50941. frontUVs?: Vector4;
  50942. backUVs?: Vector4;
  50943. wrap?: boolean;
  50944. topBaseAt?: number;
  50945. bottomBaseAt?: number;
  50946. updatable?: boolean;
  50947. }, scene?: Nullable<Scene>): Mesh;
  50948. }
  50949. }
  50950. declare module BABYLON.Debug {
  50951. /**
  50952. * Used to show the physics impostor around the specific mesh
  50953. */
  50954. export class PhysicsViewer {
  50955. /** @hidden */
  50956. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50957. /** @hidden */
  50958. protected _meshes: Array<Nullable<AbstractMesh>>;
  50959. /** @hidden */
  50960. protected _scene: Nullable<Scene>;
  50961. /** @hidden */
  50962. protected _numMeshes: number;
  50963. /** @hidden */
  50964. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50965. private _renderFunction;
  50966. private _utilityLayer;
  50967. private _debugBoxMesh;
  50968. private _debugSphereMesh;
  50969. private _debugCylinderMesh;
  50970. private _debugMaterial;
  50971. private _debugMeshMeshes;
  50972. /**
  50973. * Creates a new PhysicsViewer
  50974. * @param scene defines the hosting scene
  50975. */
  50976. constructor(scene: Scene);
  50977. /** @hidden */
  50978. protected _updateDebugMeshes(): void;
  50979. /**
  50980. * Renders a specified physic impostor
  50981. * @param impostor defines the impostor to render
  50982. * @param targetMesh defines the mesh represented by the impostor
  50983. * @returns the new debug mesh used to render the impostor
  50984. */
  50985. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50986. /**
  50987. * Hides a specified physic impostor
  50988. * @param impostor defines the impostor to hide
  50989. */
  50990. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50991. private _getDebugMaterial;
  50992. private _getDebugBoxMesh;
  50993. private _getDebugSphereMesh;
  50994. private _getDebugCylinderMesh;
  50995. private _getDebugMeshMesh;
  50996. private _getDebugMesh;
  50997. /** Releases all resources */
  50998. dispose(): void;
  50999. }
  51000. }
  51001. declare module BABYLON {
  51002. /**
  51003. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51004. * in order to better appreciate the issue one might have.
  51005. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51006. */
  51007. export class RayHelper {
  51008. /**
  51009. * Defines the ray we are currently tryin to visualize.
  51010. */
  51011. ray: Nullable<Ray>;
  51012. private _renderPoints;
  51013. private _renderLine;
  51014. private _renderFunction;
  51015. private _scene;
  51016. private _onAfterRenderObserver;
  51017. private _onAfterStepObserver;
  51018. private _attachedToMesh;
  51019. private _meshSpaceDirection;
  51020. private _meshSpaceOrigin;
  51021. /**
  51022. * Helper function to create a colored helper in a scene in one line.
  51023. * @param ray Defines the ray we are currently tryin to visualize
  51024. * @param scene Defines the scene the ray is used in
  51025. * @param color Defines the color we want to see the ray in
  51026. * @returns The newly created ray helper.
  51027. */
  51028. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51029. /**
  51030. * Instantiate a new ray helper.
  51031. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51032. * in order to better appreciate the issue one might have.
  51033. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51034. * @param ray Defines the ray we are currently tryin to visualize
  51035. */
  51036. constructor(ray: Ray);
  51037. /**
  51038. * Shows the ray we are willing to debug.
  51039. * @param scene Defines the scene the ray needs to be rendered in
  51040. * @param color Defines the color the ray needs to be rendered in
  51041. */
  51042. show(scene: Scene, color?: Color3): void;
  51043. /**
  51044. * Hides the ray we are debugging.
  51045. */
  51046. hide(): void;
  51047. private _render;
  51048. /**
  51049. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51050. * @param mesh Defines the mesh we want the helper attached to
  51051. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51052. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51053. * @param length Defines the length of the ray
  51054. */
  51055. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51056. /**
  51057. * Detach the ray helper from the mesh it has previously been attached to.
  51058. */
  51059. detachFromMesh(): void;
  51060. private _updateToMesh;
  51061. /**
  51062. * Dispose the helper and release its associated resources.
  51063. */
  51064. dispose(): void;
  51065. }
  51066. }
  51067. declare module BABYLON {
  51068. /**
  51069. * Defines the options associated with the creation of a SkeletonViewer.
  51070. */
  51071. export interface ISkeletonViewerOptions {
  51072. /** Should the system pause animations before building the Viewer? */
  51073. pauseAnimations: boolean;
  51074. /** Should the system return the skeleton to rest before building? */
  51075. returnToRest: boolean;
  51076. /** public Display Mode of the Viewer */
  51077. displayMode: number;
  51078. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51079. displayOptions: ISkeletonViewerDisplayOptions;
  51080. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51081. computeBonesUsingShaders: boolean;
  51082. /** Flag ignore non weighted bones */
  51083. useAllBones: boolean;
  51084. }
  51085. /**
  51086. * Defines how to display the various bone meshes for the viewer.
  51087. */
  51088. export interface ISkeletonViewerDisplayOptions {
  51089. /** How far down to start tapering the bone spurs */
  51090. midStep?: number;
  51091. /** How big is the midStep? */
  51092. midStepFactor?: number;
  51093. /** Base for the Sphere Size */
  51094. sphereBaseSize?: number;
  51095. /** The ratio of the sphere to the longest bone in units */
  51096. sphereScaleUnit?: number;
  51097. /** Ratio for the Sphere Size */
  51098. sphereFactor?: number;
  51099. }
  51100. /**
  51101. * Defines the constructor options for the BoneWeight Shader.
  51102. */
  51103. export interface IBoneWeightShaderOptions {
  51104. /** Skeleton to Map */
  51105. skeleton: Skeleton;
  51106. /** Colors for Uninfluenced bones */
  51107. colorBase?: Color3;
  51108. /** Colors for 0.0-0.25 Weight bones */
  51109. colorZero?: Color3;
  51110. /** Color for 0.25-0.5 Weight Influence */
  51111. colorQuarter?: Color3;
  51112. /** Color for 0.5-0.75 Weight Influence */
  51113. colorHalf?: Color3;
  51114. /** Color for 0.75-1 Weight Influence */
  51115. colorFull?: Color3;
  51116. /** Color for Zero Weight Influence */
  51117. targetBoneIndex?: number;
  51118. }
  51119. /**
  51120. * Simple structure of the gradient steps for the Color Map.
  51121. */
  51122. export interface ISkeletonMapShaderColorMapKnot {
  51123. /** Color of the Knot */
  51124. color: Color3;
  51125. /** Location of the Knot */
  51126. location: number;
  51127. }
  51128. /**
  51129. * Defines the constructor options for the SkeletonMap Shader.
  51130. */
  51131. export interface ISkeletonMapShaderOptions {
  51132. /** Skeleton to Map */
  51133. skeleton: Skeleton;
  51134. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51135. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51136. }
  51137. }
  51138. declare module BABYLON {
  51139. /**
  51140. * Class containing static functions to help procedurally build meshes
  51141. */
  51142. export class RibbonBuilder {
  51143. /**
  51144. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51145. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51146. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51147. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51148. * * 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
  51149. * * 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
  51150. * * 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
  51151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51152. * * 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
  51153. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51154. * * 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
  51155. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51156. * * 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
  51157. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51159. * @param name defines the name of the mesh
  51160. * @param options defines the options used to create the mesh
  51161. * @param scene defines the hosting scene
  51162. * @returns the ribbon mesh
  51163. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51164. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51165. */
  51166. static CreateRibbon(name: string, options: {
  51167. pathArray: Vector3[][];
  51168. closeArray?: boolean;
  51169. closePath?: boolean;
  51170. offset?: number;
  51171. updatable?: boolean;
  51172. sideOrientation?: number;
  51173. frontUVs?: Vector4;
  51174. backUVs?: Vector4;
  51175. instance?: Mesh;
  51176. invertUV?: boolean;
  51177. uvs?: Vector2[];
  51178. colors?: Color4[];
  51179. }, scene?: Nullable<Scene>): Mesh;
  51180. }
  51181. }
  51182. declare module BABYLON {
  51183. /**
  51184. * Class containing static functions to help procedurally build meshes
  51185. */
  51186. export class ShapeBuilder {
  51187. /**
  51188. * 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.
  51189. * * 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.
  51190. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51191. * * 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.
  51192. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51193. * * 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
  51194. * * 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
  51195. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51197. * * 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
  51198. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51200. * @param name defines the name of the mesh
  51201. * @param options defines the options used to create the mesh
  51202. * @param scene defines the hosting scene
  51203. * @returns the extruded shape mesh
  51204. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51206. */
  51207. static ExtrudeShape(name: string, options: {
  51208. shape: Vector3[];
  51209. path: Vector3[];
  51210. scale?: number;
  51211. rotation?: number;
  51212. cap?: number;
  51213. updatable?: boolean;
  51214. sideOrientation?: number;
  51215. frontUVs?: Vector4;
  51216. backUVs?: Vector4;
  51217. instance?: Mesh;
  51218. invertUV?: boolean;
  51219. }, scene?: Nullable<Scene>): Mesh;
  51220. /**
  51221. * Creates an custom extruded shape mesh.
  51222. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51223. * * 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.
  51224. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51225. * * 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
  51226. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51227. * * 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
  51228. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51229. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51230. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51231. * * 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
  51232. * * 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
  51233. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51235. * * 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
  51236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51238. * @param name defines the name of the mesh
  51239. * @param options defines the options used to create the mesh
  51240. * @param scene defines the hosting scene
  51241. * @returns the custom extruded shape mesh
  51242. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51243. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51245. */
  51246. static ExtrudeShapeCustom(name: string, options: {
  51247. shape: Vector3[];
  51248. path: Vector3[];
  51249. scaleFunction?: any;
  51250. rotationFunction?: any;
  51251. ribbonCloseArray?: boolean;
  51252. ribbonClosePath?: boolean;
  51253. cap?: number;
  51254. updatable?: boolean;
  51255. sideOrientation?: number;
  51256. frontUVs?: Vector4;
  51257. backUVs?: Vector4;
  51258. instance?: Mesh;
  51259. invertUV?: boolean;
  51260. }, scene?: Nullable<Scene>): Mesh;
  51261. private static _ExtrudeShapeGeneric;
  51262. }
  51263. }
  51264. declare module BABYLON.Debug {
  51265. /**
  51266. * Class used to render a debug view of a given skeleton
  51267. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51268. */
  51269. export class SkeletonViewer {
  51270. /** defines the skeleton to render */
  51271. skeleton: Skeleton;
  51272. /** defines the mesh attached to the skeleton */
  51273. mesh: AbstractMesh;
  51274. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51275. autoUpdateBonesMatrices: boolean;
  51276. /** defines the rendering group id to use with the viewer */
  51277. renderingGroupId: number;
  51278. /** is the options for the viewer */
  51279. options: Partial<ISkeletonViewerOptions>;
  51280. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51281. static readonly DISPLAY_LINES: number;
  51282. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51283. static readonly DISPLAY_SPHERES: number;
  51284. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51285. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51286. /** public static method to create a BoneWeight Shader
  51287. * @param options The constructor options
  51288. * @param scene The scene that the shader is scoped to
  51289. * @returns The created ShaderMaterial
  51290. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51291. */
  51292. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51293. /** public static method to create a BoneWeight Shader
  51294. * @param options The constructor options
  51295. * @param scene The scene that the shader is scoped to
  51296. * @returns The created ShaderMaterial
  51297. */
  51298. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51299. /** private static method to create a BoneWeight Shader
  51300. * @param size The size of the buffer to create (usually the bone count)
  51301. * @param colorMap The gradient data to generate
  51302. * @param scene The scene that the shader is scoped to
  51303. * @returns an Array of floats from the color gradient values
  51304. */
  51305. private static _CreateBoneMapColorBuffer;
  51306. /** If SkeletonViewer scene scope. */
  51307. private _scene;
  51308. /** Gets or sets the color used to render the skeleton */
  51309. color: Color3;
  51310. /** Array of the points of the skeleton fo the line view. */
  51311. private _debugLines;
  51312. /** The SkeletonViewers Mesh. */
  51313. private _debugMesh;
  51314. /** If SkeletonViewer is enabled. */
  51315. private _isEnabled;
  51316. /** If SkeletonViewer is ready. */
  51317. private _ready;
  51318. /** SkeletonViewer render observable. */
  51319. private _obs;
  51320. /** The Utility Layer to render the gizmos in. */
  51321. private _utilityLayer;
  51322. private _boneIndices;
  51323. /** Gets the Scene. */
  51324. get scene(): Scene;
  51325. /** Gets the utilityLayer. */
  51326. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51327. /** Checks Ready Status. */
  51328. get isReady(): Boolean;
  51329. /** Sets Ready Status. */
  51330. set ready(value: boolean);
  51331. /** Gets the debugMesh */
  51332. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51333. /** Sets the debugMesh */
  51334. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51335. /** Gets the displayMode */
  51336. get displayMode(): number;
  51337. /** Sets the displayMode */
  51338. set displayMode(value: number);
  51339. /**
  51340. * Creates a new SkeletonViewer
  51341. * @param skeleton defines the skeleton to render
  51342. * @param mesh defines the mesh attached to the skeleton
  51343. * @param scene defines the hosting scene
  51344. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51345. * @param renderingGroupId defines the rendering group id to use with the viewer
  51346. * @param options All of the extra constructor options for the SkeletonViewer
  51347. */
  51348. constructor(
  51349. /** defines the skeleton to render */
  51350. skeleton: Skeleton,
  51351. /** defines the mesh attached to the skeleton */
  51352. mesh: AbstractMesh,
  51353. /** The Scene scope*/
  51354. scene: Scene,
  51355. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51356. autoUpdateBonesMatrices?: boolean,
  51357. /** defines the rendering group id to use with the viewer */
  51358. renderingGroupId?: number,
  51359. /** is the options for the viewer */
  51360. options?: Partial<ISkeletonViewerOptions>);
  51361. /** The Dynamic bindings for the update functions */
  51362. private _bindObs;
  51363. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51364. update(): void;
  51365. /** Gets or sets a boolean indicating if the viewer is enabled */
  51366. set isEnabled(value: boolean);
  51367. get isEnabled(): boolean;
  51368. private _getBonePosition;
  51369. private _getLinesForBonesWithLength;
  51370. private _getLinesForBonesNoLength;
  51371. /** function to revert the mesh and scene back to the initial state. */
  51372. private _revert;
  51373. /** function to build and bind sphere joint points and spur bone representations. */
  51374. private _buildSpheresAndSpurs;
  51375. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51376. private _displayLinesUpdate;
  51377. /** Changes the displayMode of the skeleton viewer
  51378. * @param mode The displayMode numerical value
  51379. */
  51380. changeDisplayMode(mode: number): void;
  51381. /** Changes the displayMode of the skeleton viewer
  51382. * @param option String of the option name
  51383. * @param value The numerical option value
  51384. */
  51385. changeDisplayOptions(option: string, value: number): void;
  51386. /** Release associated resources */
  51387. dispose(): void;
  51388. }
  51389. }
  51390. declare module BABYLON {
  51391. /**
  51392. * Enum for Device Types
  51393. */
  51394. export enum DeviceType {
  51395. /** Generic */
  51396. Generic = 0,
  51397. /** Keyboard */
  51398. Keyboard = 1,
  51399. /** Mouse */
  51400. Mouse = 2,
  51401. /** Touch Pointers */
  51402. Touch = 3,
  51403. /** PS4 Dual Shock */
  51404. DualShock = 4,
  51405. /** Xbox */
  51406. Xbox = 5,
  51407. /** Switch Controller */
  51408. Switch = 6
  51409. }
  51410. /**
  51411. * Enum for All Pointers (Touch/Mouse)
  51412. */
  51413. export enum PointerInput {
  51414. /** Horizontal Axis */
  51415. Horizontal = 0,
  51416. /** Vertical Axis */
  51417. Vertical = 1,
  51418. /** Left Click or Touch */
  51419. LeftClick = 2,
  51420. /** Middle Click */
  51421. MiddleClick = 3,
  51422. /** Right Click */
  51423. RightClick = 4,
  51424. /** Browser Back */
  51425. BrowserBack = 5,
  51426. /** Browser Forward */
  51427. BrowserForward = 6
  51428. }
  51429. /**
  51430. * Enum for Dual Shock Gamepad
  51431. */
  51432. export enum DualShockInput {
  51433. /** Cross */
  51434. Cross = 0,
  51435. /** Circle */
  51436. Circle = 1,
  51437. /** Square */
  51438. Square = 2,
  51439. /** Triangle */
  51440. Triangle = 3,
  51441. /** L1 */
  51442. L1 = 4,
  51443. /** R1 */
  51444. R1 = 5,
  51445. /** L2 */
  51446. L2 = 6,
  51447. /** R2 */
  51448. R2 = 7,
  51449. /** Share */
  51450. Share = 8,
  51451. /** Options */
  51452. Options = 9,
  51453. /** L3 */
  51454. L3 = 10,
  51455. /** R3 */
  51456. R3 = 11,
  51457. /** DPadUp */
  51458. DPadUp = 12,
  51459. /** DPadDown */
  51460. DPadDown = 13,
  51461. /** DPadLeft */
  51462. DPadLeft = 14,
  51463. /** DRight */
  51464. DPadRight = 15,
  51465. /** Home */
  51466. Home = 16,
  51467. /** TouchPad */
  51468. TouchPad = 17,
  51469. /** LStickXAxis */
  51470. LStickXAxis = 18,
  51471. /** LStickYAxis */
  51472. LStickYAxis = 19,
  51473. /** RStickXAxis */
  51474. RStickXAxis = 20,
  51475. /** RStickYAxis */
  51476. RStickYAxis = 21
  51477. }
  51478. /**
  51479. * Enum for Xbox Gamepad
  51480. */
  51481. export enum XboxInput {
  51482. /** A */
  51483. A = 0,
  51484. /** B */
  51485. B = 1,
  51486. /** X */
  51487. X = 2,
  51488. /** Y */
  51489. Y = 3,
  51490. /** LB */
  51491. LB = 4,
  51492. /** RB */
  51493. RB = 5,
  51494. /** LT */
  51495. LT = 6,
  51496. /** RT */
  51497. RT = 7,
  51498. /** Back */
  51499. Back = 8,
  51500. /** Start */
  51501. Start = 9,
  51502. /** LS */
  51503. LS = 10,
  51504. /** RS */
  51505. RS = 11,
  51506. /** DPadUp */
  51507. DPadUp = 12,
  51508. /** DPadDown */
  51509. DPadDown = 13,
  51510. /** DPadLeft */
  51511. DPadLeft = 14,
  51512. /** DRight */
  51513. DPadRight = 15,
  51514. /** Home */
  51515. Home = 16,
  51516. /** LStickXAxis */
  51517. LStickXAxis = 17,
  51518. /** LStickYAxis */
  51519. LStickYAxis = 18,
  51520. /** RStickXAxis */
  51521. RStickXAxis = 19,
  51522. /** RStickYAxis */
  51523. RStickYAxis = 20
  51524. }
  51525. /**
  51526. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51527. */
  51528. export enum SwitchInput {
  51529. /** B */
  51530. B = 0,
  51531. /** A */
  51532. A = 1,
  51533. /** Y */
  51534. Y = 2,
  51535. /** X */
  51536. X = 3,
  51537. /** L */
  51538. L = 4,
  51539. /** R */
  51540. R = 5,
  51541. /** ZL */
  51542. ZL = 6,
  51543. /** ZR */
  51544. ZR = 7,
  51545. /** Minus */
  51546. Minus = 8,
  51547. /** Plus */
  51548. Plus = 9,
  51549. /** LS */
  51550. LS = 10,
  51551. /** RS */
  51552. RS = 11,
  51553. /** DPadUp */
  51554. DPadUp = 12,
  51555. /** DPadDown */
  51556. DPadDown = 13,
  51557. /** DPadLeft */
  51558. DPadLeft = 14,
  51559. /** DRight */
  51560. DPadRight = 15,
  51561. /** Home */
  51562. Home = 16,
  51563. /** Capture */
  51564. Capture = 17,
  51565. /** LStickXAxis */
  51566. LStickXAxis = 18,
  51567. /** LStickYAxis */
  51568. LStickYAxis = 19,
  51569. /** RStickXAxis */
  51570. RStickXAxis = 20,
  51571. /** RStickYAxis */
  51572. RStickYAxis = 21
  51573. }
  51574. }
  51575. declare module BABYLON {
  51576. /**
  51577. * This class will take all inputs from Keyboard, Pointer, and
  51578. * any Gamepads and provide a polling system that all devices
  51579. * will use. This class assumes that there will only be one
  51580. * pointer device and one keyboard.
  51581. */
  51582. export class DeviceInputSystem implements IDisposable {
  51583. /**
  51584. * Callback to be triggered when a device is connected
  51585. */
  51586. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51587. /**
  51588. * Callback to be triggered when a device is disconnected
  51589. */
  51590. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51591. /**
  51592. * Callback to be triggered when event driven input is updated
  51593. */
  51594. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51595. private _inputs;
  51596. private _gamepads;
  51597. private _keyboardActive;
  51598. private _pointerActive;
  51599. private _elementToAttachTo;
  51600. private _keyboardDownEvent;
  51601. private _keyboardUpEvent;
  51602. private _pointerMoveEvent;
  51603. private _pointerDownEvent;
  51604. private _pointerUpEvent;
  51605. private _gamepadConnectedEvent;
  51606. private _gamepadDisconnectedEvent;
  51607. private static _MAX_KEYCODES;
  51608. private static _MAX_POINTER_INPUTS;
  51609. private constructor();
  51610. /**
  51611. * Creates a new DeviceInputSystem instance
  51612. * @param engine Engine to pull input element from
  51613. * @returns The new instance
  51614. */
  51615. static Create(engine: Engine): DeviceInputSystem;
  51616. /**
  51617. * Checks for current device input value, given an id and input index
  51618. * @param deviceName Id of connected device
  51619. * @param inputIndex Index of device input
  51620. * @returns Current value of input
  51621. */
  51622. /**
  51623. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51624. * @param deviceType Enum specifiying device type
  51625. * @param deviceSlot "Slot" or index that device is referenced in
  51626. * @param inputIndex Id of input to be checked
  51627. * @returns Current value of input
  51628. */
  51629. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51630. /**
  51631. * Dispose of all the eventlisteners
  51632. */
  51633. dispose(): void;
  51634. /**
  51635. * Add device and inputs to device array
  51636. * @param deviceType Enum specifiying device type
  51637. * @param deviceSlot "Slot" or index that device is referenced in
  51638. * @param numberOfInputs Number of input entries to create for given device
  51639. */
  51640. private _registerDevice;
  51641. /**
  51642. * Given a specific device name, remove that device from the device map
  51643. * @param deviceType Enum specifiying device type
  51644. * @param deviceSlot "Slot" or index that device is referenced in
  51645. */
  51646. private _unregisterDevice;
  51647. /**
  51648. * Handle all actions that come from keyboard interaction
  51649. */
  51650. private _handleKeyActions;
  51651. /**
  51652. * Handle all actions that come from pointer interaction
  51653. */
  51654. private _handlePointerActions;
  51655. /**
  51656. * Handle all actions that come from gamepad interaction
  51657. */
  51658. private _handleGamepadActions;
  51659. /**
  51660. * Update all non-event based devices with each frame
  51661. * @param deviceType Enum specifiying device type
  51662. * @param deviceSlot "Slot" or index that device is referenced in
  51663. * @param inputIndex Id of input to be checked
  51664. */
  51665. private _updateDevice;
  51666. /**
  51667. * Gets DeviceType from the device name
  51668. * @param deviceName Name of Device from DeviceInputSystem
  51669. * @returns DeviceType enum value
  51670. */
  51671. private _getGamepadDeviceType;
  51672. }
  51673. }
  51674. declare module BABYLON {
  51675. /**
  51676. * Type to handle enforcement of inputs
  51677. */
  51678. 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;
  51679. }
  51680. declare module BABYLON {
  51681. /**
  51682. * Class that handles all input for a specific device
  51683. */
  51684. export class DeviceSource<T extends DeviceType> {
  51685. /** Type of device */
  51686. readonly deviceType: DeviceType;
  51687. /** "Slot" or index that device is referenced in */
  51688. readonly deviceSlot: number;
  51689. /**
  51690. * Observable to handle device input changes per device
  51691. */
  51692. readonly onInputChangedObservable: Observable<{
  51693. inputIndex: DeviceInput<T>;
  51694. previousState: Nullable<number>;
  51695. currentState: Nullable<number>;
  51696. }>;
  51697. private readonly _deviceInputSystem;
  51698. /**
  51699. * Default Constructor
  51700. * @param deviceInputSystem Reference to DeviceInputSystem
  51701. * @param deviceType Type of device
  51702. * @param deviceSlot "Slot" or index that device is referenced in
  51703. */
  51704. constructor(deviceInputSystem: DeviceInputSystem,
  51705. /** Type of device */
  51706. deviceType: DeviceType,
  51707. /** "Slot" or index that device is referenced in */
  51708. deviceSlot?: number);
  51709. /**
  51710. * Get input for specific input
  51711. * @param inputIndex index of specific input on device
  51712. * @returns Input value from DeviceInputSystem
  51713. */
  51714. getInput(inputIndex: DeviceInput<T>): number;
  51715. }
  51716. /**
  51717. * Class to keep track of devices
  51718. */
  51719. export class DeviceSourceManager implements IDisposable {
  51720. /**
  51721. * Observable to be triggered when before a device is connected
  51722. */
  51723. readonly onBeforeDeviceConnectedObservable: Observable<{
  51724. deviceType: DeviceType;
  51725. deviceSlot: number;
  51726. }>;
  51727. /**
  51728. * Observable to be triggered when before a device is disconnected
  51729. */
  51730. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51731. deviceType: DeviceType;
  51732. deviceSlot: number;
  51733. }>;
  51734. /**
  51735. * Observable to be triggered when after a device is connected
  51736. */
  51737. readonly onAfterDeviceConnectedObservable: Observable<{
  51738. deviceType: DeviceType;
  51739. deviceSlot: number;
  51740. }>;
  51741. /**
  51742. * Observable to be triggered when after a device is disconnected
  51743. */
  51744. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51745. deviceType: DeviceType;
  51746. deviceSlot: number;
  51747. }>;
  51748. private readonly _devices;
  51749. private readonly _firstDevice;
  51750. private readonly _deviceInputSystem;
  51751. /**
  51752. * Default Constructor
  51753. * @param engine engine to pull input element from
  51754. */
  51755. constructor(engine: Engine);
  51756. /**
  51757. * Gets a DeviceSource, given a type and slot
  51758. * @param deviceType Enum specifying device type
  51759. * @param deviceSlot "Slot" or index that device is referenced in
  51760. * @returns DeviceSource object
  51761. */
  51762. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51763. /**
  51764. * Gets an array of DeviceSource objects for a given device type
  51765. * @param deviceType Enum specifying device type
  51766. * @returns Array of DeviceSource objects
  51767. */
  51768. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51769. /**
  51770. * Dispose of DeviceInputSystem and other parts
  51771. */
  51772. dispose(): void;
  51773. /**
  51774. * Function to add device name to device list
  51775. * @param deviceType Enum specifying device type
  51776. * @param deviceSlot "Slot" or index that device is referenced in
  51777. */
  51778. private _addDevice;
  51779. /**
  51780. * Function to remove device name to device list
  51781. * @param deviceType Enum specifying device type
  51782. * @param deviceSlot "Slot" or index that device is referenced in
  51783. */
  51784. private _removeDevice;
  51785. /**
  51786. * Updates array storing first connected device of each type
  51787. * @param type Type of Device
  51788. */
  51789. private _updateFirstDevices;
  51790. }
  51791. }
  51792. declare module BABYLON {
  51793. /**
  51794. * Options to create the null engine
  51795. */
  51796. export class NullEngineOptions {
  51797. /**
  51798. * Render width (Default: 512)
  51799. */
  51800. renderWidth: number;
  51801. /**
  51802. * Render height (Default: 256)
  51803. */
  51804. renderHeight: number;
  51805. /**
  51806. * Texture size (Default: 512)
  51807. */
  51808. textureSize: number;
  51809. /**
  51810. * If delta time between frames should be constant
  51811. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51812. */
  51813. deterministicLockstep: boolean;
  51814. /**
  51815. * Maximum about of steps between frames (Default: 4)
  51816. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51817. */
  51818. lockstepMaxSteps: number;
  51819. /**
  51820. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51821. */
  51822. useHighPrecisionMatrix?: boolean;
  51823. }
  51824. /**
  51825. * The null engine class provides support for headless version of babylon.js.
  51826. * This can be used in server side scenario or for testing purposes
  51827. */
  51828. export class NullEngine extends Engine {
  51829. private _options;
  51830. /**
  51831. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51832. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51833. * @returns true if engine is in deterministic lock step mode
  51834. */
  51835. isDeterministicLockStep(): boolean;
  51836. /**
  51837. * Gets the max steps when engine is running in deterministic lock step
  51838. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51839. * @returns the max steps
  51840. */
  51841. getLockstepMaxSteps(): number;
  51842. /**
  51843. * Gets the current hardware scaling level.
  51844. * By default the hardware scaling level is computed from the window device ratio.
  51845. * 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.
  51846. * @returns a number indicating the current hardware scaling level
  51847. */
  51848. getHardwareScalingLevel(): number;
  51849. constructor(options?: NullEngineOptions);
  51850. /**
  51851. * Creates a vertex buffer
  51852. * @param vertices the data for the vertex buffer
  51853. * @returns the new WebGL static buffer
  51854. */
  51855. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51856. /**
  51857. * Creates a new index buffer
  51858. * @param indices defines the content of the index buffer
  51859. * @param updatable defines if the index buffer must be updatable
  51860. * @returns a new webGL buffer
  51861. */
  51862. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51863. /**
  51864. * Clear the current render buffer or the current render target (if any is set up)
  51865. * @param color defines the color to use
  51866. * @param backBuffer defines if the back buffer must be cleared
  51867. * @param depth defines if the depth buffer must be cleared
  51868. * @param stencil defines if the stencil buffer must be cleared
  51869. */
  51870. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51871. /**
  51872. * Gets the current render width
  51873. * @param useScreen defines if screen size must be used (or the current render target if any)
  51874. * @returns a number defining the current render width
  51875. */
  51876. getRenderWidth(useScreen?: boolean): number;
  51877. /**
  51878. * Gets the current render height
  51879. * @param useScreen defines if screen size must be used (or the current render target if any)
  51880. * @returns a number defining the current render height
  51881. */
  51882. getRenderHeight(useScreen?: boolean): number;
  51883. /**
  51884. * Set the WebGL's viewport
  51885. * @param viewport defines the viewport element to be used
  51886. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51887. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51888. */
  51889. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51890. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51891. /**
  51892. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51893. * @param pipelineContext defines the pipeline context to use
  51894. * @param uniformsNames defines the list of uniform names
  51895. * @returns an array of webGL uniform locations
  51896. */
  51897. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51898. /**
  51899. * Gets the lsit of active attributes for a given webGL program
  51900. * @param pipelineContext defines the pipeline context to use
  51901. * @param attributesNames defines the list of attribute names to get
  51902. * @returns an array of indices indicating the offset of each attribute
  51903. */
  51904. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51905. /**
  51906. * Binds an effect to the webGL context
  51907. * @param effect defines the effect to bind
  51908. */
  51909. bindSamplers(effect: Effect): void;
  51910. /**
  51911. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51912. * @param effect defines the effect to activate
  51913. */
  51914. enableEffect(effect: Effect): void;
  51915. /**
  51916. * Set various states to the webGL context
  51917. * @param culling defines backface culling state
  51918. * @param zOffset defines the value to apply to zOffset (0 by default)
  51919. * @param force defines if states must be applied even if cache is up to date
  51920. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51921. */
  51922. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51923. /**
  51924. * Set the value of an uniform to an array of int32
  51925. * @param uniform defines the webGL uniform location where to store the value
  51926. * @param array defines the array of int32 to store
  51927. */
  51928. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51929. /**
  51930. * Set the value of an uniform to an array of int32 (stored as vec2)
  51931. * @param uniform defines the webGL uniform location where to store the value
  51932. * @param array defines the array of int32 to store
  51933. */
  51934. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51935. /**
  51936. * Set the value of an uniform to an array of int32 (stored as vec3)
  51937. * @param uniform defines the webGL uniform location where to store the value
  51938. * @param array defines the array of int32 to store
  51939. */
  51940. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51941. /**
  51942. * Set the value of an uniform to an array of int32 (stored as vec4)
  51943. * @param uniform defines the webGL uniform location where to store the value
  51944. * @param array defines the array of int32 to store
  51945. */
  51946. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51947. /**
  51948. * Set the value of an uniform to an array of float32
  51949. * @param uniform defines the webGL uniform location where to store the value
  51950. * @param array defines the array of float32 to store
  51951. */
  51952. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51953. /**
  51954. * Set the value of an uniform to an array of float32 (stored as vec2)
  51955. * @param uniform defines the webGL uniform location where to store the value
  51956. * @param array defines the array of float32 to store
  51957. */
  51958. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51959. /**
  51960. * Set the value of an uniform to an array of float32 (stored as vec3)
  51961. * @param uniform defines the webGL uniform location where to store the value
  51962. * @param array defines the array of float32 to store
  51963. */
  51964. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51965. /**
  51966. * Set the value of an uniform to an array of float32 (stored as vec4)
  51967. * @param uniform defines the webGL uniform location where to store the value
  51968. * @param array defines the array of float32 to store
  51969. */
  51970. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51971. /**
  51972. * Set the value of an uniform to an array of number
  51973. * @param uniform defines the webGL uniform location where to store the value
  51974. * @param array defines the array of number to store
  51975. */
  51976. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51977. /**
  51978. * Set the value of an uniform to an array of number (stored as vec2)
  51979. * @param uniform defines the webGL uniform location where to store the value
  51980. * @param array defines the array of number to store
  51981. */
  51982. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51983. /**
  51984. * Set the value of an uniform to an array of number (stored as vec3)
  51985. * @param uniform defines the webGL uniform location where to store the value
  51986. * @param array defines the array of number to store
  51987. */
  51988. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51989. /**
  51990. * Set the value of an uniform to an array of number (stored as vec4)
  51991. * @param uniform defines the webGL uniform location where to store the value
  51992. * @param array defines the array of number to store
  51993. */
  51994. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51995. /**
  51996. * Set the value of an uniform to an array of float32 (stored as matrices)
  51997. * @param uniform defines the webGL uniform location where to store the value
  51998. * @param matrices defines the array of float32 to store
  51999. */
  52000. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52001. /**
  52002. * Set the value of an uniform to a matrix (3x3)
  52003. * @param uniform defines the webGL uniform location where to store the value
  52004. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52005. */
  52006. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52007. /**
  52008. * Set the value of an uniform to a matrix (2x2)
  52009. * @param uniform defines the webGL uniform location where to store the value
  52010. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52011. */
  52012. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52013. /**
  52014. * Set the value of an uniform to a number (float)
  52015. * @param uniform defines the webGL uniform location where to store the value
  52016. * @param value defines the float number to store
  52017. */
  52018. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52019. /**
  52020. * Set the value of an uniform to a vec2
  52021. * @param uniform defines the webGL uniform location where to store the value
  52022. * @param x defines the 1st component of the value
  52023. * @param y defines the 2nd component of the value
  52024. */
  52025. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52026. /**
  52027. * Set the value of an uniform to a vec3
  52028. * @param uniform defines the webGL uniform location where to store the value
  52029. * @param x defines the 1st component of the value
  52030. * @param y defines the 2nd component of the value
  52031. * @param z defines the 3rd component of the value
  52032. */
  52033. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52034. /**
  52035. * Set the value of an uniform to a boolean
  52036. * @param uniform defines the webGL uniform location where to store the value
  52037. * @param bool defines the boolean to store
  52038. */
  52039. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52040. /**
  52041. * Set the value of an uniform to a vec4
  52042. * @param uniform defines the webGL uniform location where to store the value
  52043. * @param x defines the 1st component of the value
  52044. * @param y defines the 2nd component of the value
  52045. * @param z defines the 3rd component of the value
  52046. * @param w defines the 4th component of the value
  52047. */
  52048. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52049. /**
  52050. * Sets the current alpha mode
  52051. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52052. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52053. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52054. */
  52055. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52056. /**
  52057. * Bind webGl buffers directly to the webGL context
  52058. * @param vertexBuffers defines the vertex buffer to bind
  52059. * @param indexBuffer defines the index buffer to bind
  52060. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52061. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52062. * @param effect defines the effect associated with the vertex buffer
  52063. */
  52064. bindBuffers(vertexBuffers: {
  52065. [key: string]: VertexBuffer;
  52066. }, indexBuffer: DataBuffer, effect: Effect): void;
  52067. /**
  52068. * Force the entire cache to be cleared
  52069. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52070. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52071. */
  52072. wipeCaches(bruteForce?: boolean): void;
  52073. /**
  52074. * Send a draw order
  52075. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52076. * @param indexStart defines the starting index
  52077. * @param indexCount defines the number of index to draw
  52078. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52079. */
  52080. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52081. /**
  52082. * Draw a list of indexed primitives
  52083. * @param fillMode defines the primitive to use
  52084. * @param indexStart defines the starting index
  52085. * @param indexCount defines the number of index to draw
  52086. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52087. */
  52088. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52089. /**
  52090. * Draw a list of unindexed primitives
  52091. * @param fillMode defines the primitive to use
  52092. * @param verticesStart defines the index of first vertex to draw
  52093. * @param verticesCount defines the count of vertices to draw
  52094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52095. */
  52096. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52097. /** @hidden */
  52098. _createTexture(): WebGLTexture;
  52099. /** @hidden */
  52100. _releaseTexture(texture: InternalTexture): void;
  52101. /**
  52102. * Usually called from Texture.ts.
  52103. * Passed information to create a WebGLTexture
  52104. * @param urlArg defines a value which contains one of the following:
  52105. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52106. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52107. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52108. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52109. * @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)
  52110. * @param scene needed for loading to the correct scene
  52111. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52112. * @param onLoad optional callback to be called upon successful completion
  52113. * @param onError optional callback to be called upon failure
  52114. * @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
  52115. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52116. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52117. * @param forcedExtension defines the extension to use to pick the right loader
  52118. * @param mimeType defines an optional mime type
  52119. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52120. */
  52121. 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;
  52122. /**
  52123. * Creates a new render target texture
  52124. * @param size defines the size of the texture
  52125. * @param options defines the options used to create the texture
  52126. * @returns a new render target texture stored in an InternalTexture
  52127. */
  52128. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52129. /**
  52130. * Update the sampling mode of a given texture
  52131. * @param samplingMode defines the required sampling mode
  52132. * @param texture defines the texture to update
  52133. */
  52134. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52135. /**
  52136. * Binds the frame buffer to the specified texture.
  52137. * @param texture The texture to render to or null for the default canvas
  52138. * @param faceIndex The face of the texture to render to in case of cube texture
  52139. * @param requiredWidth The width of the target to render to
  52140. * @param requiredHeight The height of the target to render to
  52141. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52142. * @param lodLevel defines le lod level to bind to the frame buffer
  52143. */
  52144. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52145. /**
  52146. * Unbind the current render target texture from the webGL context
  52147. * @param texture defines the render target texture to unbind
  52148. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52149. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52150. */
  52151. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52152. /**
  52153. * Creates a dynamic vertex buffer
  52154. * @param vertices the data for the dynamic vertex buffer
  52155. * @returns the new WebGL dynamic buffer
  52156. */
  52157. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52158. /**
  52159. * Update the content of a dynamic texture
  52160. * @param texture defines the texture to update
  52161. * @param canvas defines the canvas containing the source
  52162. * @param invertY defines if data must be stored with Y axis inverted
  52163. * @param premulAlpha defines if alpha is stored as premultiplied
  52164. * @param format defines the format of the data
  52165. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52166. */
  52167. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52168. /**
  52169. * Gets a boolean indicating if all created effects are ready
  52170. * @returns true if all effects are ready
  52171. */
  52172. areAllEffectsReady(): boolean;
  52173. /**
  52174. * @hidden
  52175. * Get the current error code of the webGL context
  52176. * @returns the error code
  52177. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52178. */
  52179. getError(): number;
  52180. /** @hidden */
  52181. _getUnpackAlignement(): number;
  52182. /** @hidden */
  52183. _unpackFlipY(value: boolean): void;
  52184. /**
  52185. * Update a dynamic index buffer
  52186. * @param indexBuffer defines the target index buffer
  52187. * @param indices defines the data to update
  52188. * @param offset defines the offset in the target index buffer where update should start
  52189. */
  52190. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52191. /**
  52192. * Updates a dynamic vertex buffer.
  52193. * @param vertexBuffer the vertex buffer to update
  52194. * @param vertices the data used to update the vertex buffer
  52195. * @param byteOffset the byte offset of the data (optional)
  52196. * @param byteLength the byte length of the data (optional)
  52197. */
  52198. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52199. /** @hidden */
  52200. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52201. /** @hidden */
  52202. _bindTexture(channel: number, texture: InternalTexture): void;
  52203. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52204. /**
  52205. * 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
  52206. */
  52207. releaseEffects(): void;
  52208. displayLoadingUI(): void;
  52209. hideLoadingUI(): void;
  52210. /** @hidden */
  52211. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52212. /** @hidden */
  52213. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52214. /** @hidden */
  52215. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52216. /** @hidden */
  52217. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52218. }
  52219. }
  52220. declare module BABYLON {
  52221. /**
  52222. * @hidden
  52223. **/
  52224. export class _TimeToken {
  52225. _startTimeQuery: Nullable<WebGLQuery>;
  52226. _endTimeQuery: Nullable<WebGLQuery>;
  52227. _timeElapsedQuery: Nullable<WebGLQuery>;
  52228. _timeElapsedQueryEnded: boolean;
  52229. }
  52230. }
  52231. declare module BABYLON {
  52232. /** @hidden */
  52233. export class _OcclusionDataStorage {
  52234. /** @hidden */
  52235. occlusionInternalRetryCounter: number;
  52236. /** @hidden */
  52237. isOcclusionQueryInProgress: boolean;
  52238. /** @hidden */
  52239. isOccluded: boolean;
  52240. /** @hidden */
  52241. occlusionRetryCount: number;
  52242. /** @hidden */
  52243. occlusionType: number;
  52244. /** @hidden */
  52245. occlusionQueryAlgorithmType: number;
  52246. }
  52247. interface Engine {
  52248. /**
  52249. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52250. * @return the new query
  52251. */
  52252. createQuery(): WebGLQuery;
  52253. /**
  52254. * Delete and release a webGL query
  52255. * @param query defines the query to delete
  52256. * @return the current engine
  52257. */
  52258. deleteQuery(query: WebGLQuery): Engine;
  52259. /**
  52260. * Check if a given query has resolved and got its value
  52261. * @param query defines the query to check
  52262. * @returns true if the query got its value
  52263. */
  52264. isQueryResultAvailable(query: WebGLQuery): boolean;
  52265. /**
  52266. * Gets the value of a given query
  52267. * @param query defines the query to check
  52268. * @returns the value of the query
  52269. */
  52270. getQueryResult(query: WebGLQuery): number;
  52271. /**
  52272. * Initiates an occlusion query
  52273. * @param algorithmType defines the algorithm to use
  52274. * @param query defines the query to use
  52275. * @returns the current engine
  52276. * @see https://doc.babylonjs.com/features/occlusionquery
  52277. */
  52278. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52279. /**
  52280. * Ends an occlusion query
  52281. * @see https://doc.babylonjs.com/features/occlusionquery
  52282. * @param algorithmType defines the algorithm to use
  52283. * @returns the current engine
  52284. */
  52285. endOcclusionQuery(algorithmType: number): Engine;
  52286. /**
  52287. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52288. * Please note that only one query can be issued at a time
  52289. * @returns a time token used to track the time span
  52290. */
  52291. startTimeQuery(): Nullable<_TimeToken>;
  52292. /**
  52293. * Ends a time query
  52294. * @param token defines the token used to measure the time span
  52295. * @returns the time spent (in ns)
  52296. */
  52297. endTimeQuery(token: _TimeToken): int;
  52298. /** @hidden */
  52299. _currentNonTimestampToken: Nullable<_TimeToken>;
  52300. /** @hidden */
  52301. _createTimeQuery(): WebGLQuery;
  52302. /** @hidden */
  52303. _deleteTimeQuery(query: WebGLQuery): void;
  52304. /** @hidden */
  52305. _getGlAlgorithmType(algorithmType: number): number;
  52306. /** @hidden */
  52307. _getTimeQueryResult(query: WebGLQuery): any;
  52308. /** @hidden */
  52309. _getTimeQueryAvailability(query: WebGLQuery): any;
  52310. }
  52311. interface AbstractMesh {
  52312. /**
  52313. * Backing filed
  52314. * @hidden
  52315. */
  52316. __occlusionDataStorage: _OcclusionDataStorage;
  52317. /**
  52318. * Access property
  52319. * @hidden
  52320. */
  52321. _occlusionDataStorage: _OcclusionDataStorage;
  52322. /**
  52323. * 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.
  52324. * The default value is -1 which means don't break the query and wait till the result
  52325. * @see https://doc.babylonjs.com/features/occlusionquery
  52326. */
  52327. occlusionRetryCount: number;
  52328. /**
  52329. * 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:
  52330. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52331. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52332. * * 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.
  52333. * @see https://doc.babylonjs.com/features/occlusionquery
  52334. */
  52335. occlusionType: number;
  52336. /**
  52337. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52338. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52339. * * 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.
  52340. * @see https://doc.babylonjs.com/features/occlusionquery
  52341. */
  52342. occlusionQueryAlgorithmType: number;
  52343. /**
  52344. * 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
  52345. * @see https://doc.babylonjs.com/features/occlusionquery
  52346. */
  52347. isOccluded: boolean;
  52348. /**
  52349. * Flag to check the progress status of the query
  52350. * @see https://doc.babylonjs.com/features/occlusionquery
  52351. */
  52352. isOcclusionQueryInProgress: boolean;
  52353. }
  52354. }
  52355. declare module BABYLON {
  52356. /** @hidden */
  52357. export var _forceTransformFeedbackToBundle: boolean;
  52358. interface Engine {
  52359. /**
  52360. * Creates a webGL transform feedback object
  52361. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52362. * @returns the webGL transform feedback object
  52363. */
  52364. createTransformFeedback(): WebGLTransformFeedback;
  52365. /**
  52366. * Delete a webGL transform feedback object
  52367. * @param value defines the webGL transform feedback object to delete
  52368. */
  52369. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52370. /**
  52371. * Bind a webGL transform feedback object to the webgl context
  52372. * @param value defines the webGL transform feedback object to bind
  52373. */
  52374. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52375. /**
  52376. * Begins a transform feedback operation
  52377. * @param usePoints defines if points or triangles must be used
  52378. */
  52379. beginTransformFeedback(usePoints: boolean): void;
  52380. /**
  52381. * Ends a transform feedback operation
  52382. */
  52383. endTransformFeedback(): void;
  52384. /**
  52385. * Specify the varyings to use with transform feedback
  52386. * @param program defines the associated webGL program
  52387. * @param value defines the list of strings representing the varying names
  52388. */
  52389. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52390. /**
  52391. * Bind a webGL buffer for a transform feedback operation
  52392. * @param value defines the webGL buffer to bind
  52393. */
  52394. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52395. }
  52396. }
  52397. declare module BABYLON {
  52398. /**
  52399. * Class used to define an additional view for the engine
  52400. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52401. */
  52402. export class EngineView {
  52403. /** Defines the canvas where to render the view */
  52404. target: HTMLCanvasElement;
  52405. /** Defines an optional camera used to render the view (will use active camera else) */
  52406. camera?: Camera;
  52407. }
  52408. interface Engine {
  52409. /**
  52410. * Gets or sets the HTML element to use for attaching events
  52411. */
  52412. inputElement: Nullable<HTMLElement>;
  52413. /**
  52414. * Gets the current engine view
  52415. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52416. */
  52417. activeView: Nullable<EngineView>;
  52418. /** Gets or sets the list of views */
  52419. views: EngineView[];
  52420. /**
  52421. * Register a new child canvas
  52422. * @param canvas defines the canvas to register
  52423. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52424. * @returns the associated view
  52425. */
  52426. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52427. /**
  52428. * Remove a registered child canvas
  52429. * @param canvas defines the canvas to remove
  52430. * @returns the current engine
  52431. */
  52432. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52433. }
  52434. }
  52435. declare module BABYLON {
  52436. interface Engine {
  52437. /** @hidden */
  52438. _excludedCompressedTextures: string[];
  52439. /** @hidden */
  52440. _textureFormatInUse: string;
  52441. /**
  52442. * Gets the list of texture formats supported
  52443. */
  52444. readonly texturesSupported: Array<string>;
  52445. /**
  52446. * Gets the texture format in use
  52447. */
  52448. readonly textureFormatInUse: Nullable<string>;
  52449. /**
  52450. * Set the compressed texture extensions or file names to skip.
  52451. *
  52452. * @param skippedFiles defines the list of those texture files you want to skip
  52453. * Example: [".dds", ".env", "myfile.png"]
  52454. */
  52455. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52456. /**
  52457. * Set the compressed texture format to use, based on the formats you have, and the formats
  52458. * supported by the hardware / browser.
  52459. *
  52460. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52461. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52462. * to API arguments needed to compressed textures. This puts the burden on the container
  52463. * generator to house the arcane code for determining these for current & future formats.
  52464. *
  52465. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52466. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52467. *
  52468. * Note: The result of this call is not taken into account when a texture is base64.
  52469. *
  52470. * @param formatsAvailable defines the list of those format families you have created
  52471. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52472. *
  52473. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52474. * @returns The extension selected.
  52475. */
  52476. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52477. }
  52478. }
  52479. declare module BABYLON {
  52480. /**
  52481. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52482. */
  52483. export interface CubeMapInfo {
  52484. /**
  52485. * The pixel array for the front face.
  52486. * This is stored in format, left to right, up to down format.
  52487. */
  52488. front: Nullable<ArrayBufferView>;
  52489. /**
  52490. * The pixel array for the back face.
  52491. * This is stored in format, left to right, up to down format.
  52492. */
  52493. back: Nullable<ArrayBufferView>;
  52494. /**
  52495. * The pixel array for the left face.
  52496. * This is stored in format, left to right, up to down format.
  52497. */
  52498. left: Nullable<ArrayBufferView>;
  52499. /**
  52500. * The pixel array for the right face.
  52501. * This is stored in format, left to right, up to down format.
  52502. */
  52503. right: Nullable<ArrayBufferView>;
  52504. /**
  52505. * The pixel array for the up face.
  52506. * This is stored in format, left to right, up to down format.
  52507. */
  52508. up: Nullable<ArrayBufferView>;
  52509. /**
  52510. * The pixel array for the down face.
  52511. * This is stored in format, left to right, up to down format.
  52512. */
  52513. down: Nullable<ArrayBufferView>;
  52514. /**
  52515. * The size of the cubemap stored.
  52516. *
  52517. * Each faces will be size * size pixels.
  52518. */
  52519. size: number;
  52520. /**
  52521. * The format of the texture.
  52522. *
  52523. * RGBA, RGB.
  52524. */
  52525. format: number;
  52526. /**
  52527. * The type of the texture data.
  52528. *
  52529. * UNSIGNED_INT, FLOAT.
  52530. */
  52531. type: number;
  52532. /**
  52533. * Specifies whether the texture is in gamma space.
  52534. */
  52535. gammaSpace: boolean;
  52536. }
  52537. /**
  52538. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52539. */
  52540. export class PanoramaToCubeMapTools {
  52541. private static FACE_LEFT;
  52542. private static FACE_RIGHT;
  52543. private static FACE_FRONT;
  52544. private static FACE_BACK;
  52545. private static FACE_DOWN;
  52546. private static FACE_UP;
  52547. /**
  52548. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52549. *
  52550. * @param float32Array The source data.
  52551. * @param inputWidth The width of the input panorama.
  52552. * @param inputHeight The height of the input panorama.
  52553. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52554. * @return The cubemap data
  52555. */
  52556. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52557. private static CreateCubemapTexture;
  52558. private static CalcProjectionSpherical;
  52559. }
  52560. }
  52561. declare module BABYLON {
  52562. /**
  52563. * Helper class dealing with the extraction of spherical polynomial dataArray
  52564. * from a cube map.
  52565. */
  52566. export class CubeMapToSphericalPolynomialTools {
  52567. private static FileFaces;
  52568. /**
  52569. * Converts a texture to the according Spherical Polynomial data.
  52570. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52571. *
  52572. * @param texture The texture to extract the information from.
  52573. * @return The Spherical Polynomial data.
  52574. */
  52575. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52576. /**
  52577. * Converts a cubemap to the according Spherical Polynomial data.
  52578. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52579. *
  52580. * @param cubeInfo The Cube map to extract the information from.
  52581. * @return The Spherical Polynomial data.
  52582. */
  52583. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52584. }
  52585. }
  52586. declare module BABYLON {
  52587. interface BaseTexture {
  52588. /**
  52589. * Get the polynomial representation of the texture data.
  52590. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52591. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52592. */
  52593. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52594. }
  52595. }
  52596. declare module BABYLON {
  52597. /** @hidden */
  52598. export var rgbdEncodePixelShader: {
  52599. name: string;
  52600. shader: string;
  52601. };
  52602. }
  52603. declare module BABYLON {
  52604. /** @hidden */
  52605. export var rgbdDecodePixelShader: {
  52606. name: string;
  52607. shader: string;
  52608. };
  52609. }
  52610. declare module BABYLON {
  52611. /**
  52612. * Raw texture data and descriptor sufficient for WebGL texture upload
  52613. */
  52614. export interface EnvironmentTextureInfo {
  52615. /**
  52616. * Version of the environment map
  52617. */
  52618. version: number;
  52619. /**
  52620. * Width of image
  52621. */
  52622. width: number;
  52623. /**
  52624. * Irradiance information stored in the file.
  52625. */
  52626. irradiance: any;
  52627. /**
  52628. * Specular information stored in the file.
  52629. */
  52630. specular: any;
  52631. }
  52632. /**
  52633. * Defines One Image in the file. It requires only the position in the file
  52634. * as well as the length.
  52635. */
  52636. interface BufferImageData {
  52637. /**
  52638. * Length of the image data.
  52639. */
  52640. length: number;
  52641. /**
  52642. * Position of the data from the null terminator delimiting the end of the JSON.
  52643. */
  52644. position: number;
  52645. }
  52646. /**
  52647. * Defines the specular data enclosed in the file.
  52648. * This corresponds to the version 1 of the data.
  52649. */
  52650. export interface EnvironmentTextureSpecularInfoV1 {
  52651. /**
  52652. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52653. */
  52654. specularDataPosition?: number;
  52655. /**
  52656. * This contains all the images data needed to reconstruct the cubemap.
  52657. */
  52658. mipmaps: Array<BufferImageData>;
  52659. /**
  52660. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52661. */
  52662. lodGenerationScale: number;
  52663. }
  52664. /**
  52665. * Sets of helpers addressing the serialization and deserialization of environment texture
  52666. * stored in a BabylonJS env file.
  52667. * Those files are usually stored as .env files.
  52668. */
  52669. export class EnvironmentTextureTools {
  52670. /**
  52671. * Magic number identifying the env file.
  52672. */
  52673. private static _MagicBytes;
  52674. /**
  52675. * Gets the environment info from an env file.
  52676. * @param data The array buffer containing the .env bytes.
  52677. * @returns the environment file info (the json header) if successfully parsed.
  52678. */
  52679. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52680. /**
  52681. * Creates an environment texture from a loaded cube texture.
  52682. * @param texture defines the cube texture to convert in env file
  52683. * @return a promise containing the environment data if succesfull.
  52684. */
  52685. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52686. /**
  52687. * Creates a JSON representation of the spherical data.
  52688. * @param texture defines the texture containing the polynomials
  52689. * @return the JSON representation of the spherical info
  52690. */
  52691. private static _CreateEnvTextureIrradiance;
  52692. /**
  52693. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52694. * @param data the image data
  52695. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52696. * @return the views described by info providing access to the underlying buffer
  52697. */
  52698. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52699. /**
  52700. * Uploads the texture info contained in the env file to the GPU.
  52701. * @param texture defines the internal texture to upload to
  52702. * @param data defines the data to load
  52703. * @param info defines the texture info retrieved through the GetEnvInfo method
  52704. * @returns a promise
  52705. */
  52706. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52707. private static _OnImageReadyAsync;
  52708. /**
  52709. * Uploads the levels of image data to the GPU.
  52710. * @param texture defines the internal texture to upload to
  52711. * @param imageData defines the array buffer views of image data [mipmap][face]
  52712. * @returns a promise
  52713. */
  52714. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52715. /**
  52716. * Uploads spherical polynomials information to the texture.
  52717. * @param texture defines the texture we are trying to upload the information to
  52718. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52719. */
  52720. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52721. /** @hidden */
  52722. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52723. }
  52724. }
  52725. declare module BABYLON {
  52726. /**
  52727. * Class used to inline functions in shader code
  52728. */
  52729. export class ShaderCodeInliner {
  52730. private static readonly _RegexpFindFunctionNameAndType;
  52731. private _sourceCode;
  52732. private _functionDescr;
  52733. private _numMaxIterations;
  52734. /** Gets or sets the token used to mark the functions to inline */
  52735. inlineToken: string;
  52736. /** Gets or sets the debug mode */
  52737. debug: boolean;
  52738. /** Gets the code after the inlining process */
  52739. get code(): string;
  52740. /**
  52741. * Initializes the inliner
  52742. * @param sourceCode shader code source to inline
  52743. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52744. */
  52745. constructor(sourceCode: string, numMaxIterations?: number);
  52746. /**
  52747. * Start the processing of the shader code
  52748. */
  52749. processCode(): void;
  52750. private _collectFunctions;
  52751. private _processInlining;
  52752. private _extractBetweenMarkers;
  52753. private _skipWhitespaces;
  52754. private _removeComments;
  52755. private _replaceFunctionCallsByCode;
  52756. private _findBackward;
  52757. private _escapeRegExp;
  52758. private _replaceNames;
  52759. }
  52760. }
  52761. declare module BABYLON {
  52762. /**
  52763. * Container for accessors for natively-stored mesh data buffers.
  52764. */
  52765. class NativeDataBuffer extends DataBuffer {
  52766. /**
  52767. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52768. */
  52769. nativeIndexBuffer?: any;
  52770. /**
  52771. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52772. */
  52773. nativeVertexBuffer?: any;
  52774. }
  52775. /** @hidden */
  52776. class NativeTexture extends InternalTexture {
  52777. getInternalTexture(): InternalTexture;
  52778. getViewCount(): number;
  52779. }
  52780. /** @hidden */
  52781. export class NativeEngine extends Engine {
  52782. private readonly _native;
  52783. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52784. private readonly INVALID_HANDLE;
  52785. private _boundBuffersVertexArray;
  52786. getHardwareScalingLevel(): number;
  52787. constructor();
  52788. dispose(): void;
  52789. /**
  52790. * Can be used to override the current requestAnimationFrame requester.
  52791. * @hidden
  52792. */
  52793. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52794. /**
  52795. * Override default engine behavior.
  52796. * @param color
  52797. * @param backBuffer
  52798. * @param depth
  52799. * @param stencil
  52800. */
  52801. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52802. /**
  52803. * Gets host document
  52804. * @returns the host document object
  52805. */
  52806. getHostDocument(): Nullable<Document>;
  52807. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52808. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52809. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52810. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52811. [key: string]: VertexBuffer;
  52812. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52813. bindBuffers(vertexBuffers: {
  52814. [key: string]: VertexBuffer;
  52815. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52816. recordVertexArrayObject(vertexBuffers: {
  52817. [key: string]: VertexBuffer;
  52818. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52819. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52820. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52821. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52822. /**
  52823. * Draw a list of indexed primitives
  52824. * @param fillMode defines the primitive to use
  52825. * @param indexStart defines the starting index
  52826. * @param indexCount defines the number of index to draw
  52827. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52828. */
  52829. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52830. /**
  52831. * Draw a list of unindexed primitives
  52832. * @param fillMode defines the primitive to use
  52833. * @param verticesStart defines the index of first vertex to draw
  52834. * @param verticesCount defines the count of vertices to draw
  52835. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52836. */
  52837. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52838. createPipelineContext(): IPipelineContext;
  52839. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52840. /** @hidden */
  52841. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52842. /** @hidden */
  52843. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52844. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52845. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52846. protected _setProgram(program: WebGLProgram): void;
  52847. _releaseEffect(effect: Effect): void;
  52848. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52849. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52850. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52851. bindSamplers(effect: Effect): void;
  52852. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52853. getRenderWidth(useScreen?: boolean): number;
  52854. getRenderHeight(useScreen?: boolean): number;
  52855. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52856. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52857. /**
  52858. * Set the z offset to apply to current rendering
  52859. * @param value defines the offset to apply
  52860. */
  52861. setZOffset(value: number): void;
  52862. /**
  52863. * Gets the current value of the zOffset
  52864. * @returns the current zOffset state
  52865. */
  52866. getZOffset(): number;
  52867. /**
  52868. * Enable or disable depth buffering
  52869. * @param enable defines the state to set
  52870. */
  52871. setDepthBuffer(enable: boolean): void;
  52872. /**
  52873. * Gets a boolean indicating if depth writing is enabled
  52874. * @returns the current depth writing state
  52875. */
  52876. getDepthWrite(): boolean;
  52877. /**
  52878. * Enable or disable depth writing
  52879. * @param enable defines the state to set
  52880. */
  52881. setDepthWrite(enable: boolean): void;
  52882. /**
  52883. * Enable or disable color writing
  52884. * @param enable defines the state to set
  52885. */
  52886. setColorWrite(enable: boolean): void;
  52887. /**
  52888. * Gets a boolean indicating if color writing is enabled
  52889. * @returns the current color writing state
  52890. */
  52891. getColorWrite(): boolean;
  52892. /**
  52893. * Sets alpha constants used by some alpha blending modes
  52894. * @param r defines the red component
  52895. * @param g defines the green component
  52896. * @param b defines the blue component
  52897. * @param a defines the alpha component
  52898. */
  52899. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52900. /**
  52901. * Sets the current alpha mode
  52902. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52903. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52904. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52905. */
  52906. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52907. /**
  52908. * Gets the current alpha mode
  52909. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52910. * @returns the current alpha mode
  52911. */
  52912. getAlphaMode(): number;
  52913. setInt(uniform: WebGLUniformLocation, int: number): void;
  52914. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52915. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52916. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52917. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52918. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52919. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52920. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52921. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52922. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52923. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52924. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52925. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52926. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52927. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52928. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52929. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52930. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52931. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52932. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52933. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52934. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52935. wipeCaches(bruteForce?: boolean): void;
  52936. _createTexture(): WebGLTexture;
  52937. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52938. /**
  52939. * Usually called from Texture.ts.
  52940. * Passed information to create a WebGLTexture
  52941. * @param url defines a value which contains one of the following:
  52942. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52943. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52944. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52945. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52946. * @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)
  52947. * @param scene needed for loading to the correct scene
  52948. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52949. * @param onLoad optional callback to be called upon successful completion
  52950. * @param onError optional callback to be called upon failure
  52951. * @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
  52952. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52953. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52954. * @param forcedExtension defines the extension to use to pick the right loader
  52955. * @param mimeType defines an optional mime type
  52956. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52957. */
  52958. 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;
  52959. /**
  52960. * Creates a cube texture
  52961. * @param rootUrl defines the url where the files to load is located
  52962. * @param scene defines the current scene
  52963. * @param files defines the list of files to load (1 per face)
  52964. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52965. * @param onLoad defines an optional callback raised when the texture is loaded
  52966. * @param onError defines an optional callback raised if there is an issue to load the texture
  52967. * @param format defines the format of the data
  52968. * @param forcedExtension defines the extension to use to pick the right loader
  52969. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52970. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52971. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52972. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52973. * @returns the cube texture as an InternalTexture
  52974. */
  52975. 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;
  52976. private _getSamplingFilter;
  52977. private static _GetNativeTextureFormat;
  52978. createRenderTargetTexture(size: number | {
  52979. width: number;
  52980. height: number;
  52981. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52982. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52983. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52984. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52985. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52986. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52987. /**
  52988. * Updates a dynamic vertex buffer.
  52989. * @param vertexBuffer the vertex buffer to update
  52990. * @param data the data used to update the vertex buffer
  52991. * @param byteOffset the byte offset of the data (optional)
  52992. * @param byteLength the byte length of the data (optional)
  52993. */
  52994. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52995. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52996. private _updateAnisotropicLevel;
  52997. private _getAddressMode;
  52998. /** @hidden */
  52999. _bindTexture(channel: number, texture: InternalTexture): void;
  53000. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53001. releaseEffects(): void;
  53002. /** @hidden */
  53003. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53004. /** @hidden */
  53005. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53006. /** @hidden */
  53007. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53008. /** @hidden */
  53009. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53010. }
  53011. }
  53012. declare module BABYLON {
  53013. /**
  53014. * Gather the list of clipboard event types as constants.
  53015. */
  53016. export class ClipboardEventTypes {
  53017. /**
  53018. * The clipboard event is fired when a copy command is active (pressed).
  53019. */
  53020. static readonly COPY: number;
  53021. /**
  53022. * The clipboard event is fired when a cut command is active (pressed).
  53023. */
  53024. static readonly CUT: number;
  53025. /**
  53026. * The clipboard event is fired when a paste command is active (pressed).
  53027. */
  53028. static readonly PASTE: number;
  53029. }
  53030. /**
  53031. * This class is used to store clipboard related info for the onClipboardObservable event.
  53032. */
  53033. export class ClipboardInfo {
  53034. /**
  53035. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53036. */
  53037. type: number;
  53038. /**
  53039. * Defines the related dom event
  53040. */
  53041. event: ClipboardEvent;
  53042. /**
  53043. *Creates an instance of ClipboardInfo.
  53044. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53045. * @param event Defines the related dom event
  53046. */
  53047. constructor(
  53048. /**
  53049. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53050. */
  53051. type: number,
  53052. /**
  53053. * Defines the related dom event
  53054. */
  53055. event: ClipboardEvent);
  53056. /**
  53057. * Get the clipboard event's type from the keycode.
  53058. * @param keyCode Defines the keyCode for the current keyboard event.
  53059. * @return {number}
  53060. */
  53061. static GetTypeFromCharacter(keyCode: number): number;
  53062. }
  53063. }
  53064. declare module BABYLON {
  53065. /**
  53066. * Google Daydream controller
  53067. */
  53068. export class DaydreamController extends WebVRController {
  53069. /**
  53070. * Base Url for the controller model.
  53071. */
  53072. static MODEL_BASE_URL: string;
  53073. /**
  53074. * File name for the controller model.
  53075. */
  53076. static MODEL_FILENAME: string;
  53077. /**
  53078. * Gamepad Id prefix used to identify Daydream Controller.
  53079. */
  53080. static readonly GAMEPAD_ID_PREFIX: string;
  53081. /**
  53082. * Creates a new DaydreamController from a gamepad
  53083. * @param vrGamepad the gamepad that the controller should be created from
  53084. */
  53085. constructor(vrGamepad: any);
  53086. /**
  53087. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53088. * @param scene scene in which to add meshes
  53089. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53090. */
  53091. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53092. /**
  53093. * Called once for each button that changed state since the last frame
  53094. * @param buttonIdx Which button index changed
  53095. * @param state New state of the button
  53096. * @param changes Which properties on the state changed since last frame
  53097. */
  53098. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53099. }
  53100. }
  53101. declare module BABYLON {
  53102. /**
  53103. * Gear VR Controller
  53104. */
  53105. export class GearVRController extends WebVRController {
  53106. /**
  53107. * Base Url for the controller model.
  53108. */
  53109. static MODEL_BASE_URL: string;
  53110. /**
  53111. * File name for the controller model.
  53112. */
  53113. static MODEL_FILENAME: string;
  53114. /**
  53115. * Gamepad Id prefix used to identify this controller.
  53116. */
  53117. static readonly GAMEPAD_ID_PREFIX: string;
  53118. private readonly _buttonIndexToObservableNameMap;
  53119. /**
  53120. * Creates a new GearVRController from a gamepad
  53121. * @param vrGamepad the gamepad that the controller should be created from
  53122. */
  53123. constructor(vrGamepad: any);
  53124. /**
  53125. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53126. * @param scene scene in which to add meshes
  53127. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53128. */
  53129. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53130. /**
  53131. * Called once for each button that changed state since the last frame
  53132. * @param buttonIdx Which button index changed
  53133. * @param state New state of the button
  53134. * @param changes Which properties on the state changed since last frame
  53135. */
  53136. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53137. }
  53138. }
  53139. declare module BABYLON {
  53140. /**
  53141. * Generic Controller
  53142. */
  53143. export class GenericController extends WebVRController {
  53144. /**
  53145. * Base Url for the controller model.
  53146. */
  53147. static readonly MODEL_BASE_URL: string;
  53148. /**
  53149. * File name for the controller model.
  53150. */
  53151. static readonly MODEL_FILENAME: string;
  53152. /**
  53153. * Creates a new GenericController from a gamepad
  53154. * @param vrGamepad the gamepad that the controller should be created from
  53155. */
  53156. constructor(vrGamepad: any);
  53157. /**
  53158. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53159. * @param scene scene in which to add meshes
  53160. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53161. */
  53162. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53163. /**
  53164. * Called once for each button that changed state since the last frame
  53165. * @param buttonIdx Which button index changed
  53166. * @param state New state of the button
  53167. * @param changes Which properties on the state changed since last frame
  53168. */
  53169. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53170. }
  53171. }
  53172. declare module BABYLON {
  53173. /**
  53174. * Oculus Touch Controller
  53175. */
  53176. export class OculusTouchController extends WebVRController {
  53177. /**
  53178. * Base Url for the controller model.
  53179. */
  53180. static MODEL_BASE_URL: string;
  53181. /**
  53182. * File name for the left controller model.
  53183. */
  53184. static MODEL_LEFT_FILENAME: string;
  53185. /**
  53186. * File name for the right controller model.
  53187. */
  53188. static MODEL_RIGHT_FILENAME: string;
  53189. /**
  53190. * Base Url for the Quest controller model.
  53191. */
  53192. static QUEST_MODEL_BASE_URL: string;
  53193. /**
  53194. * @hidden
  53195. * If the controllers are running on a device that needs the updated Quest controller models
  53196. */
  53197. static _IsQuest: boolean;
  53198. /**
  53199. * Fired when the secondary trigger on this controller is modified
  53200. */
  53201. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53202. /**
  53203. * Fired when the thumb rest on this controller is modified
  53204. */
  53205. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53206. /**
  53207. * Creates a new OculusTouchController from a gamepad
  53208. * @param vrGamepad the gamepad that the controller should be created from
  53209. */
  53210. constructor(vrGamepad: any);
  53211. /**
  53212. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53213. * @param scene scene in which to add meshes
  53214. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53215. */
  53216. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53217. /**
  53218. * Fired when the A button on this controller is modified
  53219. */
  53220. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53221. /**
  53222. * Fired when the B button on this controller is modified
  53223. */
  53224. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53225. /**
  53226. * Fired when the X button on this controller is modified
  53227. */
  53228. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53229. /**
  53230. * Fired when the Y button on this controller is modified
  53231. */
  53232. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53233. /**
  53234. * Called once for each button that changed state since the last frame
  53235. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53236. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53237. * 2) secondary trigger (same)
  53238. * 3) A (right) X (left), touch, pressed = value
  53239. * 4) B / Y
  53240. * 5) thumb rest
  53241. * @param buttonIdx Which button index changed
  53242. * @param state New state of the button
  53243. * @param changes Which properties on the state changed since last frame
  53244. */
  53245. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53246. }
  53247. }
  53248. declare module BABYLON {
  53249. /**
  53250. * Vive Controller
  53251. */
  53252. export class ViveController extends WebVRController {
  53253. /**
  53254. * Base Url for the controller model.
  53255. */
  53256. static MODEL_BASE_URL: string;
  53257. /**
  53258. * File name for the controller model.
  53259. */
  53260. static MODEL_FILENAME: string;
  53261. /**
  53262. * Creates a new ViveController from a gamepad
  53263. * @param vrGamepad the gamepad that the controller should be created from
  53264. */
  53265. constructor(vrGamepad: any);
  53266. /**
  53267. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53268. * @param scene scene in which to add meshes
  53269. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53270. */
  53271. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53272. /**
  53273. * Fired when the left button on this controller is modified
  53274. */
  53275. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53276. /**
  53277. * Fired when the right button on this controller is modified
  53278. */
  53279. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53280. /**
  53281. * Fired when the menu button on this controller is modified
  53282. */
  53283. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53284. /**
  53285. * Called once for each button that changed state since the last frame
  53286. * Vive mapping:
  53287. * 0: touchpad
  53288. * 1: trigger
  53289. * 2: left AND right buttons
  53290. * 3: menu button
  53291. * @param buttonIdx Which button index changed
  53292. * @param state New state of the button
  53293. * @param changes Which properties on the state changed since last frame
  53294. */
  53295. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53296. }
  53297. }
  53298. declare module BABYLON {
  53299. /**
  53300. * Defines the WindowsMotionController object that the state of the windows motion controller
  53301. */
  53302. export class WindowsMotionController extends WebVRController {
  53303. /**
  53304. * The base url used to load the left and right controller models
  53305. */
  53306. static MODEL_BASE_URL: string;
  53307. /**
  53308. * The name of the left controller model file
  53309. */
  53310. static MODEL_LEFT_FILENAME: string;
  53311. /**
  53312. * The name of the right controller model file
  53313. */
  53314. static MODEL_RIGHT_FILENAME: string;
  53315. /**
  53316. * The controller name prefix for this controller type
  53317. */
  53318. static readonly GAMEPAD_ID_PREFIX: string;
  53319. /**
  53320. * The controller id pattern for this controller type
  53321. */
  53322. private static readonly GAMEPAD_ID_PATTERN;
  53323. private _loadedMeshInfo;
  53324. protected readonly _mapping: {
  53325. buttons: string[];
  53326. buttonMeshNames: {
  53327. trigger: string;
  53328. menu: string;
  53329. grip: string;
  53330. thumbstick: string;
  53331. trackpad: string;
  53332. };
  53333. buttonObservableNames: {
  53334. trigger: string;
  53335. menu: string;
  53336. grip: string;
  53337. thumbstick: string;
  53338. trackpad: string;
  53339. };
  53340. axisMeshNames: string[];
  53341. pointingPoseMeshName: string;
  53342. };
  53343. /**
  53344. * Fired when the trackpad on this controller is clicked
  53345. */
  53346. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53347. /**
  53348. * Fired when the trackpad on this controller is modified
  53349. */
  53350. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53351. /**
  53352. * The current x and y values of this controller's trackpad
  53353. */
  53354. trackpad: StickValues;
  53355. /**
  53356. * Creates a new WindowsMotionController from a gamepad
  53357. * @param vrGamepad the gamepad that the controller should be created from
  53358. */
  53359. constructor(vrGamepad: any);
  53360. /**
  53361. * Fired when the trigger on this controller is modified
  53362. */
  53363. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53364. /**
  53365. * Fired when the menu button on this controller is modified
  53366. */
  53367. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53368. /**
  53369. * Fired when the grip button on this controller is modified
  53370. */
  53371. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53372. /**
  53373. * Fired when the thumbstick button on this controller is modified
  53374. */
  53375. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53376. /**
  53377. * Fired when the touchpad button on this controller is modified
  53378. */
  53379. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53380. /**
  53381. * Fired when the touchpad values on this controller are modified
  53382. */
  53383. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53384. protected _updateTrackpad(): void;
  53385. /**
  53386. * Called once per frame by the engine.
  53387. */
  53388. update(): void;
  53389. /**
  53390. * Called once for each button that changed state since the last frame
  53391. * @param buttonIdx Which button index changed
  53392. * @param state New state of the button
  53393. * @param changes Which properties on the state changed since last frame
  53394. */
  53395. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53396. /**
  53397. * Moves the buttons on the controller mesh based on their current state
  53398. * @param buttonName the name of the button to move
  53399. * @param buttonValue the value of the button which determines the buttons new position
  53400. */
  53401. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53402. /**
  53403. * Moves the axis on the controller mesh based on its current state
  53404. * @param axis the index of the axis
  53405. * @param axisValue the value of the axis which determines the meshes new position
  53406. * @hidden
  53407. */
  53408. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53409. /**
  53410. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53411. * @param scene scene in which to add meshes
  53412. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53413. */
  53414. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53415. /**
  53416. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53417. * can be transformed by button presses and axes values, based on this._mapping.
  53418. *
  53419. * @param scene scene in which the meshes exist
  53420. * @param meshes list of meshes that make up the controller model to process
  53421. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53422. */
  53423. private processModel;
  53424. private createMeshInfo;
  53425. /**
  53426. * Gets the ray of the controller in the direction the controller is pointing
  53427. * @param length the length the resulting ray should be
  53428. * @returns a ray in the direction the controller is pointing
  53429. */
  53430. getForwardRay(length?: number): Ray;
  53431. /**
  53432. * Disposes of the controller
  53433. */
  53434. dispose(): void;
  53435. }
  53436. /**
  53437. * This class represents a new windows motion controller in XR.
  53438. */
  53439. export class XRWindowsMotionController extends WindowsMotionController {
  53440. /**
  53441. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53442. */
  53443. protected readonly _mapping: {
  53444. buttons: string[];
  53445. buttonMeshNames: {
  53446. trigger: string;
  53447. menu: string;
  53448. grip: string;
  53449. thumbstick: string;
  53450. trackpad: string;
  53451. };
  53452. buttonObservableNames: {
  53453. trigger: string;
  53454. menu: string;
  53455. grip: string;
  53456. thumbstick: string;
  53457. trackpad: string;
  53458. };
  53459. axisMeshNames: string[];
  53460. pointingPoseMeshName: string;
  53461. };
  53462. /**
  53463. * Construct a new XR-Based windows motion controller
  53464. *
  53465. * @param gamepadInfo the gamepad object from the browser
  53466. */
  53467. constructor(gamepadInfo: any);
  53468. /**
  53469. * holds the thumbstick values (X,Y)
  53470. */
  53471. thumbstickValues: StickValues;
  53472. /**
  53473. * Fired when the thumbstick on this controller is clicked
  53474. */
  53475. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53476. /**
  53477. * Fired when the thumbstick on this controller is modified
  53478. */
  53479. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53480. /**
  53481. * Fired when the touchpad button on this controller is modified
  53482. */
  53483. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53484. /**
  53485. * Fired when the touchpad values on this controller are modified
  53486. */
  53487. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53488. /**
  53489. * Fired when the thumbstick button on this controller is modified
  53490. * here to prevent breaking changes
  53491. */
  53492. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53493. /**
  53494. * updating the thumbstick(!) and not the trackpad.
  53495. * This is named this way due to the difference between WebVR and XR and to avoid
  53496. * changing the parent class.
  53497. */
  53498. protected _updateTrackpad(): void;
  53499. /**
  53500. * Disposes the class with joy
  53501. */
  53502. dispose(): void;
  53503. }
  53504. }
  53505. declare module BABYLON {
  53506. /**
  53507. * Class containing static functions to help procedurally build meshes
  53508. */
  53509. export class PolyhedronBuilder {
  53510. /**
  53511. * Creates a polyhedron mesh
  53512. * * 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
  53513. * * The parameter `size` (positive float, default 1) sets the polygon size
  53514. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53515. * * 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`
  53516. * * 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
  53517. * * 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)`)
  53518. * * 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
  53519. * * 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
  53520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53521. * * 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
  53522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53523. * @param name defines the name of the mesh
  53524. * @param options defines the options used to create the mesh
  53525. * @param scene defines the hosting scene
  53526. * @returns the polyhedron mesh
  53527. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53528. */
  53529. static CreatePolyhedron(name: string, options: {
  53530. type?: number;
  53531. size?: number;
  53532. sizeX?: number;
  53533. sizeY?: number;
  53534. sizeZ?: number;
  53535. custom?: any;
  53536. faceUV?: Vector4[];
  53537. faceColors?: Color4[];
  53538. flat?: boolean;
  53539. updatable?: boolean;
  53540. sideOrientation?: number;
  53541. frontUVs?: Vector4;
  53542. backUVs?: Vector4;
  53543. }, scene?: Nullable<Scene>): Mesh;
  53544. }
  53545. }
  53546. declare module BABYLON {
  53547. /**
  53548. * Gizmo that enables scaling a mesh along 3 axis
  53549. */
  53550. export class ScaleGizmo extends Gizmo {
  53551. /**
  53552. * Internal gizmo used for interactions on the x axis
  53553. */
  53554. xGizmo: AxisScaleGizmo;
  53555. /**
  53556. * Internal gizmo used for interactions on the y axis
  53557. */
  53558. yGizmo: AxisScaleGizmo;
  53559. /**
  53560. * Internal gizmo used for interactions on the z axis
  53561. */
  53562. zGizmo: AxisScaleGizmo;
  53563. /**
  53564. * Internal gizmo used to scale all axis equally
  53565. */
  53566. uniformScaleGizmo: AxisScaleGizmo;
  53567. private _meshAttached;
  53568. private _nodeAttached;
  53569. private _snapDistance;
  53570. private _uniformScalingMesh;
  53571. private _octahedron;
  53572. private _sensitivity;
  53573. /** Fires an event when any of it's sub gizmos are dragged */
  53574. onDragStartObservable: Observable<unknown>;
  53575. /** Fires an event when any of it's sub gizmos are released from dragging */
  53576. onDragEndObservable: Observable<unknown>;
  53577. get attachedMesh(): Nullable<AbstractMesh>;
  53578. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53579. get attachedNode(): Nullable<Node>;
  53580. set attachedNode(node: Nullable<Node>);
  53581. /**
  53582. * Creates a ScaleGizmo
  53583. * @param gizmoLayer The utility layer the gizmo will be added to
  53584. * @param thickness display gizmo axis thickness
  53585. */
  53586. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53587. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53588. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53589. /**
  53590. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53591. */
  53592. set snapDistance(value: number);
  53593. get snapDistance(): number;
  53594. /**
  53595. * Ratio for the scale of the gizmo (Default: 1)
  53596. */
  53597. set scaleRatio(value: number);
  53598. get scaleRatio(): number;
  53599. /**
  53600. * Sensitivity factor for dragging (Default: 1)
  53601. */
  53602. set sensitivity(value: number);
  53603. get sensitivity(): number;
  53604. /**
  53605. * Disposes of the gizmo
  53606. */
  53607. dispose(): void;
  53608. }
  53609. }
  53610. declare module BABYLON {
  53611. /**
  53612. * Single axis scale gizmo
  53613. */
  53614. export class AxisScaleGizmo extends Gizmo {
  53615. /**
  53616. * Drag behavior responsible for the gizmos dragging interactions
  53617. */
  53618. dragBehavior: PointerDragBehavior;
  53619. private _pointerObserver;
  53620. /**
  53621. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53622. */
  53623. snapDistance: number;
  53624. /**
  53625. * Event that fires each time the gizmo snaps to a new location.
  53626. * * snapDistance is the the change in distance
  53627. */
  53628. onSnapObservable: Observable<{
  53629. snapDistance: number;
  53630. }>;
  53631. /**
  53632. * If the scaling operation should be done on all axis (default: false)
  53633. */
  53634. uniformScaling: boolean;
  53635. /**
  53636. * Custom sensitivity value for the drag strength
  53637. */
  53638. sensitivity: number;
  53639. private _isEnabled;
  53640. private _parent;
  53641. private _arrow;
  53642. private _coloredMaterial;
  53643. private _hoverMaterial;
  53644. /**
  53645. * Creates an AxisScaleGizmo
  53646. * @param gizmoLayer The utility layer the gizmo will be added to
  53647. * @param dragAxis The axis which the gizmo will be able to scale on
  53648. * @param color The color of the gizmo
  53649. * @param thickness display gizmo axis thickness
  53650. */
  53651. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53652. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53653. /**
  53654. * If the gizmo is enabled
  53655. */
  53656. set isEnabled(value: boolean);
  53657. get isEnabled(): boolean;
  53658. /**
  53659. * Disposes of the gizmo
  53660. */
  53661. dispose(): void;
  53662. /**
  53663. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53664. * @param mesh The mesh to replace the default mesh of the gizmo
  53665. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53666. */
  53667. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53668. }
  53669. }
  53670. declare module BABYLON {
  53671. /**
  53672. * Bounding box gizmo
  53673. */
  53674. export class BoundingBoxGizmo extends Gizmo {
  53675. private _lineBoundingBox;
  53676. private _rotateSpheresParent;
  53677. private _scaleBoxesParent;
  53678. private _boundingDimensions;
  53679. private _renderObserver;
  53680. private _pointerObserver;
  53681. private _scaleDragSpeed;
  53682. private _tmpQuaternion;
  53683. private _tmpVector;
  53684. private _tmpRotationMatrix;
  53685. /**
  53686. * 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)
  53687. */
  53688. ignoreChildren: boolean;
  53689. /**
  53690. * 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)
  53691. */
  53692. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53693. /**
  53694. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53695. */
  53696. rotationSphereSize: number;
  53697. /**
  53698. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53699. */
  53700. scaleBoxSize: number;
  53701. /**
  53702. * 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)
  53703. */
  53704. fixedDragMeshScreenSize: boolean;
  53705. /**
  53706. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53707. */
  53708. fixedDragMeshScreenSizeDistanceFactor: number;
  53709. /**
  53710. * Fired when a rotation sphere or scale box is dragged
  53711. */
  53712. onDragStartObservable: Observable<{}>;
  53713. /**
  53714. * Fired when a scale box is dragged
  53715. */
  53716. onScaleBoxDragObservable: Observable<{}>;
  53717. /**
  53718. * Fired when a scale box drag is ended
  53719. */
  53720. onScaleBoxDragEndObservable: Observable<{}>;
  53721. /**
  53722. * Fired when a rotation sphere is dragged
  53723. */
  53724. onRotationSphereDragObservable: Observable<{}>;
  53725. /**
  53726. * Fired when a rotation sphere drag is ended
  53727. */
  53728. onRotationSphereDragEndObservable: Observable<{}>;
  53729. /**
  53730. * 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)
  53731. */
  53732. scalePivot: Nullable<Vector3>;
  53733. /**
  53734. * Mesh used as a pivot to rotate the attached node
  53735. */
  53736. private _anchorMesh;
  53737. private _existingMeshScale;
  53738. private _dragMesh;
  53739. private pointerDragBehavior;
  53740. private coloredMaterial;
  53741. private hoverColoredMaterial;
  53742. /**
  53743. * Sets the color of the bounding box gizmo
  53744. * @param color the color to set
  53745. */
  53746. setColor(color: Color3): void;
  53747. /**
  53748. * Creates an BoundingBoxGizmo
  53749. * @param gizmoLayer The utility layer the gizmo will be added to
  53750. * @param color The color of the gizmo
  53751. */
  53752. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53753. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53754. private _selectNode;
  53755. /**
  53756. * Updates the bounding box information for the Gizmo
  53757. */
  53758. updateBoundingBox(): void;
  53759. private _updateRotationSpheres;
  53760. private _updateScaleBoxes;
  53761. /**
  53762. * Enables rotation on the specified axis and disables rotation on the others
  53763. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53764. */
  53765. setEnabledRotationAxis(axis: string): void;
  53766. /**
  53767. * Enables/disables scaling
  53768. * @param enable if scaling should be enabled
  53769. * @param homogeneousScaling defines if scaling should only be homogeneous
  53770. */
  53771. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53772. private _updateDummy;
  53773. /**
  53774. * Enables a pointer drag behavior on the bounding box of the gizmo
  53775. */
  53776. enableDragBehavior(): void;
  53777. /**
  53778. * Disposes of the gizmo
  53779. */
  53780. dispose(): void;
  53781. /**
  53782. * 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)
  53783. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53784. * @returns the bounding box mesh with the passed in mesh as a child
  53785. */
  53786. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53787. /**
  53788. * CustomMeshes are not supported by this gizmo
  53789. * @param mesh The mesh to replace the default mesh of the gizmo
  53790. */
  53791. setCustomMesh(mesh: Mesh): void;
  53792. }
  53793. }
  53794. declare module BABYLON {
  53795. /**
  53796. * Single plane rotation gizmo
  53797. */
  53798. export class PlaneRotationGizmo extends Gizmo {
  53799. /**
  53800. * Drag behavior responsible for the gizmos dragging interactions
  53801. */
  53802. dragBehavior: PointerDragBehavior;
  53803. private _pointerObserver;
  53804. /**
  53805. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53806. */
  53807. snapDistance: number;
  53808. /**
  53809. * Event that fires each time the gizmo snaps to a new location.
  53810. * * snapDistance is the the change in distance
  53811. */
  53812. onSnapObservable: Observable<{
  53813. snapDistance: number;
  53814. }>;
  53815. private _isEnabled;
  53816. private _parent;
  53817. /**
  53818. * Creates a PlaneRotationGizmo
  53819. * @param gizmoLayer The utility layer the gizmo will be added to
  53820. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53821. * @param color The color of the gizmo
  53822. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53823. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53824. * @param thickness display gizmo axis thickness
  53825. */
  53826. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53827. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53828. /**
  53829. * If the gizmo is enabled
  53830. */
  53831. set isEnabled(value: boolean);
  53832. get isEnabled(): boolean;
  53833. /**
  53834. * Disposes of the gizmo
  53835. */
  53836. dispose(): void;
  53837. }
  53838. }
  53839. declare module BABYLON {
  53840. /**
  53841. * Gizmo that enables rotating a mesh along 3 axis
  53842. */
  53843. export class RotationGizmo extends Gizmo {
  53844. /**
  53845. * Internal gizmo used for interactions on the x axis
  53846. */
  53847. xGizmo: PlaneRotationGizmo;
  53848. /**
  53849. * Internal gizmo used for interactions on the y axis
  53850. */
  53851. yGizmo: PlaneRotationGizmo;
  53852. /**
  53853. * Internal gizmo used for interactions on the z axis
  53854. */
  53855. zGizmo: PlaneRotationGizmo;
  53856. /** Fires an event when any of it's sub gizmos are dragged */
  53857. onDragStartObservable: Observable<unknown>;
  53858. /** Fires an event when any of it's sub gizmos are released from dragging */
  53859. onDragEndObservable: Observable<unknown>;
  53860. private _meshAttached;
  53861. private _nodeAttached;
  53862. get attachedMesh(): Nullable<AbstractMesh>;
  53863. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53864. get attachedNode(): Nullable<Node>;
  53865. set attachedNode(node: Nullable<Node>);
  53866. /**
  53867. * Creates a RotationGizmo
  53868. * @param gizmoLayer The utility layer the gizmo will be added to
  53869. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53870. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53871. * @param thickness display gizmo axis thickness
  53872. */
  53873. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53874. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53875. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53876. /**
  53877. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53878. */
  53879. set snapDistance(value: number);
  53880. get snapDistance(): number;
  53881. /**
  53882. * Ratio for the scale of the gizmo (Default: 1)
  53883. */
  53884. set scaleRatio(value: number);
  53885. get scaleRatio(): number;
  53886. /**
  53887. * Disposes of the gizmo
  53888. */
  53889. dispose(): void;
  53890. /**
  53891. * CustomMeshes are not supported by this gizmo
  53892. * @param mesh The mesh to replace the default mesh of the gizmo
  53893. */
  53894. setCustomMesh(mesh: Mesh): void;
  53895. }
  53896. }
  53897. declare module BABYLON {
  53898. /**
  53899. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53900. */
  53901. export class GizmoManager implements IDisposable {
  53902. private scene;
  53903. /**
  53904. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53905. */
  53906. gizmos: {
  53907. positionGizmo: Nullable<PositionGizmo>;
  53908. rotationGizmo: Nullable<RotationGizmo>;
  53909. scaleGizmo: Nullable<ScaleGizmo>;
  53910. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53911. };
  53912. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53913. clearGizmoOnEmptyPointerEvent: boolean;
  53914. /** Fires an event when the manager is attached to a mesh */
  53915. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53916. /** Fires an event when the manager is attached to a node */
  53917. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  53918. private _gizmosEnabled;
  53919. private _pointerObserver;
  53920. private _attachedMesh;
  53921. private _attachedNode;
  53922. private _boundingBoxColor;
  53923. private _defaultUtilityLayer;
  53924. private _defaultKeepDepthUtilityLayer;
  53925. private _thickness;
  53926. /**
  53927. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53928. */
  53929. boundingBoxDragBehavior: SixDofDragBehavior;
  53930. /**
  53931. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53932. */
  53933. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53934. /**
  53935. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  53936. */
  53937. attachableNodes: Nullable<Array<Node>>;
  53938. /**
  53939. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  53940. */
  53941. usePointerToAttachGizmos: boolean;
  53942. /**
  53943. * Utility layer that the bounding box gizmo belongs to
  53944. */
  53945. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53946. /**
  53947. * Utility layer that all gizmos besides bounding box belong to
  53948. */
  53949. get utilityLayer(): UtilityLayerRenderer;
  53950. /**
  53951. * Instatiates a gizmo manager
  53952. * @param scene the scene to overlay the gizmos on top of
  53953. * @param thickness display gizmo axis thickness
  53954. */
  53955. constructor(scene: Scene, thickness?: number);
  53956. /**
  53957. * Attaches a set of gizmos to the specified mesh
  53958. * @param mesh The mesh the gizmo's should be attached to
  53959. */
  53960. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53961. /**
  53962. * Attaches a set of gizmos to the specified node
  53963. * @param node The node the gizmo's should be attached to
  53964. */
  53965. attachToNode(node: Nullable<Node>): void;
  53966. /**
  53967. * If the position gizmo is enabled
  53968. */
  53969. set positionGizmoEnabled(value: boolean);
  53970. get positionGizmoEnabled(): boolean;
  53971. /**
  53972. * If the rotation gizmo is enabled
  53973. */
  53974. set rotationGizmoEnabled(value: boolean);
  53975. get rotationGizmoEnabled(): boolean;
  53976. /**
  53977. * If the scale gizmo is enabled
  53978. */
  53979. set scaleGizmoEnabled(value: boolean);
  53980. get scaleGizmoEnabled(): boolean;
  53981. /**
  53982. * If the boundingBox gizmo is enabled
  53983. */
  53984. set boundingBoxGizmoEnabled(value: boolean);
  53985. get boundingBoxGizmoEnabled(): boolean;
  53986. /**
  53987. * Disposes of the gizmo manager
  53988. */
  53989. dispose(): void;
  53990. }
  53991. }
  53992. declare module BABYLON {
  53993. /**
  53994. * A directional light is defined by a direction (what a surprise!).
  53995. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53996. * 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.
  53997. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53998. */
  53999. export class DirectionalLight extends ShadowLight {
  54000. private _shadowFrustumSize;
  54001. /**
  54002. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54003. */
  54004. get shadowFrustumSize(): number;
  54005. /**
  54006. * Specifies a fix frustum size for the shadow generation.
  54007. */
  54008. set shadowFrustumSize(value: number);
  54009. private _shadowOrthoScale;
  54010. /**
  54011. * Gets the shadow projection scale against the optimal computed one.
  54012. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54013. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54014. */
  54015. get shadowOrthoScale(): number;
  54016. /**
  54017. * Sets the shadow projection scale against the optimal computed one.
  54018. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54019. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54020. */
  54021. set shadowOrthoScale(value: number);
  54022. /**
  54023. * Automatically compute the projection matrix to best fit (including all the casters)
  54024. * on each frame.
  54025. */
  54026. autoUpdateExtends: boolean;
  54027. /**
  54028. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54029. * on each frame. autoUpdateExtends must be set to true for this to work
  54030. */
  54031. autoCalcShadowZBounds: boolean;
  54032. private _orthoLeft;
  54033. private _orthoRight;
  54034. private _orthoTop;
  54035. private _orthoBottom;
  54036. /**
  54037. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54038. * The directional light is emitted from everywhere in the given direction.
  54039. * It can cast shadows.
  54040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54041. * @param name The friendly name of the light
  54042. * @param direction The direction of the light
  54043. * @param scene The scene the light belongs to
  54044. */
  54045. constructor(name: string, direction: Vector3, scene: Scene);
  54046. /**
  54047. * Returns the string "DirectionalLight".
  54048. * @return The class name
  54049. */
  54050. getClassName(): string;
  54051. /**
  54052. * Returns the integer 1.
  54053. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54054. */
  54055. getTypeID(): number;
  54056. /**
  54057. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54058. * Returns the DirectionalLight Shadow projection matrix.
  54059. */
  54060. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54061. /**
  54062. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54063. * Returns the DirectionalLight Shadow projection matrix.
  54064. */
  54065. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54066. /**
  54067. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54068. * Returns the DirectionalLight Shadow projection matrix.
  54069. */
  54070. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54071. protected _buildUniformLayout(): void;
  54072. /**
  54073. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54074. * @param effect The effect to update
  54075. * @param lightIndex The index of the light in the effect to update
  54076. * @returns The directional light
  54077. */
  54078. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54079. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54080. /**
  54081. * Gets the minZ used for shadow according to both the scene and the light.
  54082. *
  54083. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54084. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54085. * @param activeCamera The camera we are returning the min for
  54086. * @returns the depth min z
  54087. */
  54088. getDepthMinZ(activeCamera: Camera): number;
  54089. /**
  54090. * Gets the maxZ used for shadow according to both the scene and the light.
  54091. *
  54092. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54093. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54094. * @param activeCamera The camera we are returning the max for
  54095. * @returns the depth max z
  54096. */
  54097. getDepthMaxZ(activeCamera: Camera): number;
  54098. /**
  54099. * Prepares the list of defines specific to the light type.
  54100. * @param defines the list of defines
  54101. * @param lightIndex defines the index of the light for the effect
  54102. */
  54103. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54104. }
  54105. }
  54106. declare module BABYLON {
  54107. /**
  54108. * Class containing static functions to help procedurally build meshes
  54109. */
  54110. export class HemisphereBuilder {
  54111. /**
  54112. * Creates a hemisphere mesh
  54113. * @param name defines the name of the mesh
  54114. * @param options defines the options used to create the mesh
  54115. * @param scene defines the hosting scene
  54116. * @returns the hemisphere mesh
  54117. */
  54118. static CreateHemisphere(name: string, options: {
  54119. segments?: number;
  54120. diameter?: number;
  54121. sideOrientation?: number;
  54122. }, scene: any): Mesh;
  54123. }
  54124. }
  54125. declare module BABYLON {
  54126. /**
  54127. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54128. * These values define a cone of light starting from the position, emitting toward the direction.
  54129. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54130. * and the exponent defines the speed of the decay of the light with distance (reach).
  54131. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54132. */
  54133. export class SpotLight extends ShadowLight {
  54134. private _angle;
  54135. private _innerAngle;
  54136. private _cosHalfAngle;
  54137. private _lightAngleScale;
  54138. private _lightAngleOffset;
  54139. /**
  54140. * Gets the cone angle of the spot light in Radians.
  54141. */
  54142. get angle(): number;
  54143. /**
  54144. * Sets the cone angle of the spot light in Radians.
  54145. */
  54146. set angle(value: number);
  54147. /**
  54148. * Only used in gltf falloff mode, this defines the angle where
  54149. * the directional falloff will start before cutting at angle which could be seen
  54150. * as outer angle.
  54151. */
  54152. get innerAngle(): number;
  54153. /**
  54154. * Only used in gltf falloff mode, this defines the angle where
  54155. * the directional falloff will start before cutting at angle which could be seen
  54156. * as outer angle.
  54157. */
  54158. set innerAngle(value: number);
  54159. private _shadowAngleScale;
  54160. /**
  54161. * Allows scaling the angle of the light for shadow generation only.
  54162. */
  54163. get shadowAngleScale(): number;
  54164. /**
  54165. * Allows scaling the angle of the light for shadow generation only.
  54166. */
  54167. set shadowAngleScale(value: number);
  54168. /**
  54169. * The light decay speed with the distance from the emission spot.
  54170. */
  54171. exponent: number;
  54172. private _projectionTextureMatrix;
  54173. /**
  54174. * Allows reading the projecton texture
  54175. */
  54176. get projectionTextureMatrix(): Matrix;
  54177. protected _projectionTextureLightNear: number;
  54178. /**
  54179. * Gets the near clip of the Spotlight for texture projection.
  54180. */
  54181. get projectionTextureLightNear(): number;
  54182. /**
  54183. * Sets the near clip of the Spotlight for texture projection.
  54184. */
  54185. set projectionTextureLightNear(value: number);
  54186. protected _projectionTextureLightFar: number;
  54187. /**
  54188. * Gets the far clip of the Spotlight for texture projection.
  54189. */
  54190. get projectionTextureLightFar(): number;
  54191. /**
  54192. * Sets the far clip of the Spotlight for texture projection.
  54193. */
  54194. set projectionTextureLightFar(value: number);
  54195. protected _projectionTextureUpDirection: Vector3;
  54196. /**
  54197. * Gets the Up vector of the Spotlight for texture projection.
  54198. */
  54199. get projectionTextureUpDirection(): Vector3;
  54200. /**
  54201. * Sets the Up vector of the Spotlight for texture projection.
  54202. */
  54203. set projectionTextureUpDirection(value: Vector3);
  54204. private _projectionTexture;
  54205. /**
  54206. * Gets the projection texture of the light.
  54207. */
  54208. get projectionTexture(): Nullable<BaseTexture>;
  54209. /**
  54210. * Sets the projection texture of the light.
  54211. */
  54212. set projectionTexture(value: Nullable<BaseTexture>);
  54213. private _projectionTextureViewLightDirty;
  54214. private _projectionTextureProjectionLightDirty;
  54215. private _projectionTextureDirty;
  54216. private _projectionTextureViewTargetVector;
  54217. private _projectionTextureViewLightMatrix;
  54218. private _projectionTextureProjectionLightMatrix;
  54219. private _projectionTextureScalingMatrix;
  54220. /**
  54221. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54222. * It can cast shadows.
  54223. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54224. * @param name The light friendly name
  54225. * @param position The position of the spot light in the scene
  54226. * @param direction The direction of the light in the scene
  54227. * @param angle The cone angle of the light in Radians
  54228. * @param exponent The light decay speed with the distance from the emission spot
  54229. * @param scene The scene the lights belongs to
  54230. */
  54231. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54232. /**
  54233. * Returns the string "SpotLight".
  54234. * @returns the class name
  54235. */
  54236. getClassName(): string;
  54237. /**
  54238. * Returns the integer 2.
  54239. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54240. */
  54241. getTypeID(): number;
  54242. /**
  54243. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54244. */
  54245. protected _setDirection(value: Vector3): void;
  54246. /**
  54247. * Overrides the position setter to recompute the projection texture view light Matrix.
  54248. */
  54249. protected _setPosition(value: Vector3): void;
  54250. /**
  54251. * 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.
  54252. * Returns the SpotLight.
  54253. */
  54254. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54255. protected _computeProjectionTextureViewLightMatrix(): void;
  54256. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54257. /**
  54258. * Main function for light texture projection matrix computing.
  54259. */
  54260. protected _computeProjectionTextureMatrix(): void;
  54261. protected _buildUniformLayout(): void;
  54262. private _computeAngleValues;
  54263. /**
  54264. * Sets the passed Effect "effect" with the Light textures.
  54265. * @param effect The effect to update
  54266. * @param lightIndex The index of the light in the effect to update
  54267. * @returns The light
  54268. */
  54269. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54270. /**
  54271. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54272. * @param effect The effect to update
  54273. * @param lightIndex The index of the light in the effect to update
  54274. * @returns The spot light
  54275. */
  54276. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54277. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54278. /**
  54279. * Disposes the light and the associated resources.
  54280. */
  54281. dispose(): void;
  54282. /**
  54283. * Prepares the list of defines specific to the light type.
  54284. * @param defines the list of defines
  54285. * @param lightIndex defines the index of the light for the effect
  54286. */
  54287. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54288. }
  54289. }
  54290. declare module BABYLON {
  54291. /**
  54292. * Gizmo that enables viewing a light
  54293. */
  54294. export class LightGizmo extends Gizmo {
  54295. private _lightMesh;
  54296. private _material;
  54297. private _cachedPosition;
  54298. private _cachedForward;
  54299. private _attachedMeshParent;
  54300. private _pointerObserver;
  54301. /**
  54302. * Event that fires each time the gizmo is clicked
  54303. */
  54304. onClickedObservable: Observable<Light>;
  54305. /**
  54306. * Creates a LightGizmo
  54307. * @param gizmoLayer The utility layer the gizmo will be added to
  54308. */
  54309. constructor(gizmoLayer?: UtilityLayerRenderer);
  54310. private _light;
  54311. /**
  54312. * The light that the gizmo is attached to
  54313. */
  54314. set light(light: Nullable<Light>);
  54315. get light(): Nullable<Light>;
  54316. /**
  54317. * Gets the material used to render the light gizmo
  54318. */
  54319. get material(): StandardMaterial;
  54320. /**
  54321. * @hidden
  54322. * Updates the gizmo to match the attached mesh's position/rotation
  54323. */
  54324. protected _update(): void;
  54325. private static _Scale;
  54326. /**
  54327. * Creates the lines for a light mesh
  54328. */
  54329. private static _CreateLightLines;
  54330. /**
  54331. * Disposes of the light gizmo
  54332. */
  54333. dispose(): void;
  54334. private static _CreateHemisphericLightMesh;
  54335. private static _CreatePointLightMesh;
  54336. private static _CreateSpotLightMesh;
  54337. private static _CreateDirectionalLightMesh;
  54338. }
  54339. }
  54340. declare module BABYLON {
  54341. /**
  54342. * Gizmo that enables viewing a camera
  54343. */
  54344. export class CameraGizmo extends Gizmo {
  54345. private _cameraMesh;
  54346. private _cameraLinesMesh;
  54347. private _material;
  54348. private _pointerObserver;
  54349. /**
  54350. * Event that fires each time the gizmo is clicked
  54351. */
  54352. onClickedObservable: Observable<Camera>;
  54353. /**
  54354. * Creates a CameraGizmo
  54355. * @param gizmoLayer The utility layer the gizmo will be added to
  54356. */
  54357. constructor(gizmoLayer?: UtilityLayerRenderer);
  54358. private _camera;
  54359. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54360. get displayFrustum(): boolean;
  54361. set displayFrustum(value: boolean);
  54362. /**
  54363. * The camera that the gizmo is attached to
  54364. */
  54365. set camera(camera: Nullable<Camera>);
  54366. get camera(): Nullable<Camera>;
  54367. /**
  54368. * Gets the material used to render the camera gizmo
  54369. */
  54370. get material(): StandardMaterial;
  54371. /**
  54372. * @hidden
  54373. * Updates the gizmo to match the attached mesh's position/rotation
  54374. */
  54375. protected _update(): void;
  54376. private static _Scale;
  54377. private _invProjection;
  54378. /**
  54379. * Disposes of the camera gizmo
  54380. */
  54381. dispose(): void;
  54382. private static _CreateCameraMesh;
  54383. private static _CreateCameraFrustum;
  54384. }
  54385. }
  54386. declare module BABYLON {
  54387. /** @hidden */
  54388. export var backgroundFragmentDeclaration: {
  54389. name: string;
  54390. shader: string;
  54391. };
  54392. }
  54393. declare module BABYLON {
  54394. /** @hidden */
  54395. export var backgroundUboDeclaration: {
  54396. name: string;
  54397. shader: string;
  54398. };
  54399. }
  54400. declare module BABYLON {
  54401. /** @hidden */
  54402. export var backgroundPixelShader: {
  54403. name: string;
  54404. shader: string;
  54405. };
  54406. }
  54407. declare module BABYLON {
  54408. /** @hidden */
  54409. export var backgroundVertexDeclaration: {
  54410. name: string;
  54411. shader: string;
  54412. };
  54413. }
  54414. declare module BABYLON {
  54415. /** @hidden */
  54416. export var backgroundVertexShader: {
  54417. name: string;
  54418. shader: string;
  54419. };
  54420. }
  54421. declare module BABYLON {
  54422. /**
  54423. * Background material used to create an efficient environement around your scene.
  54424. */
  54425. export class BackgroundMaterial extends PushMaterial {
  54426. /**
  54427. * Standard reflectance value at parallel view angle.
  54428. */
  54429. static StandardReflectance0: number;
  54430. /**
  54431. * Standard reflectance value at grazing angle.
  54432. */
  54433. static StandardReflectance90: number;
  54434. protected _primaryColor: Color3;
  54435. /**
  54436. * Key light Color (multiply against the environement texture)
  54437. */
  54438. primaryColor: Color3;
  54439. protected __perceptualColor: Nullable<Color3>;
  54440. /**
  54441. * Experimental Internal Use Only.
  54442. *
  54443. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54444. * This acts as a helper to set the primary color to a more "human friendly" value.
  54445. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54446. * output color as close as possible from the chosen value.
  54447. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54448. * part of lighting setup.)
  54449. */
  54450. get _perceptualColor(): Nullable<Color3>;
  54451. set _perceptualColor(value: Nullable<Color3>);
  54452. protected _primaryColorShadowLevel: float;
  54453. /**
  54454. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54455. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54456. */
  54457. get primaryColorShadowLevel(): float;
  54458. set primaryColorShadowLevel(value: float);
  54459. protected _primaryColorHighlightLevel: float;
  54460. /**
  54461. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54462. * The primary color is used at the level chosen to define what the white area would look.
  54463. */
  54464. get primaryColorHighlightLevel(): float;
  54465. set primaryColorHighlightLevel(value: float);
  54466. protected _reflectionTexture: Nullable<BaseTexture>;
  54467. /**
  54468. * Reflection Texture used in the material.
  54469. * Should be author in a specific way for the best result (refer to the documentation).
  54470. */
  54471. reflectionTexture: Nullable<BaseTexture>;
  54472. protected _reflectionBlur: float;
  54473. /**
  54474. * Reflection Texture level of blur.
  54475. *
  54476. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54477. * texture twice.
  54478. */
  54479. reflectionBlur: float;
  54480. protected _diffuseTexture: Nullable<BaseTexture>;
  54481. /**
  54482. * Diffuse Texture used in the material.
  54483. * Should be author in a specific way for the best result (refer to the documentation).
  54484. */
  54485. diffuseTexture: Nullable<BaseTexture>;
  54486. protected _shadowLights: Nullable<IShadowLight[]>;
  54487. /**
  54488. * Specify the list of lights casting shadow on the material.
  54489. * All scene shadow lights will be included if null.
  54490. */
  54491. shadowLights: Nullable<IShadowLight[]>;
  54492. protected _shadowLevel: float;
  54493. /**
  54494. * Helps adjusting the shadow to a softer level if required.
  54495. * 0 means black shadows and 1 means no shadows.
  54496. */
  54497. shadowLevel: float;
  54498. protected _sceneCenter: Vector3;
  54499. /**
  54500. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54501. * It is usually zero but might be interesting to modify according to your setup.
  54502. */
  54503. sceneCenter: Vector3;
  54504. protected _opacityFresnel: boolean;
  54505. /**
  54506. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54507. * This helps ensuring a nice transition when the camera goes under the ground.
  54508. */
  54509. opacityFresnel: boolean;
  54510. protected _reflectionFresnel: boolean;
  54511. /**
  54512. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54513. * This helps adding a mirror texture on the ground.
  54514. */
  54515. reflectionFresnel: boolean;
  54516. protected _reflectionFalloffDistance: number;
  54517. /**
  54518. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54519. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54520. */
  54521. reflectionFalloffDistance: number;
  54522. protected _reflectionAmount: number;
  54523. /**
  54524. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54525. */
  54526. reflectionAmount: number;
  54527. protected _reflectionReflectance0: number;
  54528. /**
  54529. * This specifies the weight of the reflection at grazing angle.
  54530. */
  54531. reflectionReflectance0: number;
  54532. protected _reflectionReflectance90: number;
  54533. /**
  54534. * This specifies the weight of the reflection at a perpendicular point of view.
  54535. */
  54536. reflectionReflectance90: number;
  54537. /**
  54538. * Sets the reflection reflectance fresnel values according to the default standard
  54539. * empirically know to work well :-)
  54540. */
  54541. set reflectionStandardFresnelWeight(value: number);
  54542. protected _useRGBColor: boolean;
  54543. /**
  54544. * Helps to directly use the maps channels instead of their level.
  54545. */
  54546. useRGBColor: boolean;
  54547. protected _enableNoise: boolean;
  54548. /**
  54549. * This helps reducing the banding effect that could occur on the background.
  54550. */
  54551. enableNoise: boolean;
  54552. /**
  54553. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54554. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54555. * Recommended to be keep at 1.0 except for special cases.
  54556. */
  54557. get fovMultiplier(): number;
  54558. set fovMultiplier(value: number);
  54559. private _fovMultiplier;
  54560. /**
  54561. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54562. */
  54563. useEquirectangularFOV: boolean;
  54564. private _maxSimultaneousLights;
  54565. /**
  54566. * Number of Simultaneous lights allowed on the material.
  54567. */
  54568. maxSimultaneousLights: int;
  54569. private _shadowOnly;
  54570. /**
  54571. * Make the material only render shadows
  54572. */
  54573. shadowOnly: boolean;
  54574. /**
  54575. * Default configuration related to image processing available in the Background Material.
  54576. */
  54577. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54578. /**
  54579. * Keep track of the image processing observer to allow dispose and replace.
  54580. */
  54581. private _imageProcessingObserver;
  54582. /**
  54583. * Attaches a new image processing configuration to the PBR Material.
  54584. * @param configuration (if null the scene configuration will be use)
  54585. */
  54586. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54587. /**
  54588. * Gets the image processing configuration used either in this material.
  54589. */
  54590. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54591. /**
  54592. * Sets the Default image processing configuration used either in the this material.
  54593. *
  54594. * If sets to null, the scene one is in use.
  54595. */
  54596. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54597. /**
  54598. * Gets wether the color curves effect is enabled.
  54599. */
  54600. get cameraColorCurvesEnabled(): boolean;
  54601. /**
  54602. * Sets wether the color curves effect is enabled.
  54603. */
  54604. set cameraColorCurvesEnabled(value: boolean);
  54605. /**
  54606. * Gets wether the color grading effect is enabled.
  54607. */
  54608. get cameraColorGradingEnabled(): boolean;
  54609. /**
  54610. * Gets wether the color grading effect is enabled.
  54611. */
  54612. set cameraColorGradingEnabled(value: boolean);
  54613. /**
  54614. * Gets wether tonemapping is enabled or not.
  54615. */
  54616. get cameraToneMappingEnabled(): boolean;
  54617. /**
  54618. * Sets wether tonemapping is enabled or not
  54619. */
  54620. set cameraToneMappingEnabled(value: boolean);
  54621. /**
  54622. * The camera exposure used on this material.
  54623. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54624. * This corresponds to a photographic exposure.
  54625. */
  54626. get cameraExposure(): float;
  54627. /**
  54628. * The camera exposure used on this material.
  54629. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54630. * This corresponds to a photographic exposure.
  54631. */
  54632. set cameraExposure(value: float);
  54633. /**
  54634. * Gets The camera contrast used on this material.
  54635. */
  54636. get cameraContrast(): float;
  54637. /**
  54638. * Sets The camera contrast used on this material.
  54639. */
  54640. set cameraContrast(value: float);
  54641. /**
  54642. * Gets the Color Grading 2D Lookup Texture.
  54643. */
  54644. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54645. /**
  54646. * Sets the Color Grading 2D Lookup Texture.
  54647. */
  54648. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54649. /**
  54650. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54651. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54652. * 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;
  54653. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54654. */
  54655. get cameraColorCurves(): Nullable<ColorCurves>;
  54656. /**
  54657. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54658. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54659. * 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;
  54660. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54661. */
  54662. set cameraColorCurves(value: Nullable<ColorCurves>);
  54663. /**
  54664. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54665. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54666. */
  54667. switchToBGR: boolean;
  54668. private _renderTargets;
  54669. private _reflectionControls;
  54670. private _white;
  54671. private _primaryShadowColor;
  54672. private _primaryHighlightColor;
  54673. /**
  54674. * Instantiates a Background Material in the given scene
  54675. * @param name The friendly name of the material
  54676. * @param scene The scene to add the material to
  54677. */
  54678. constructor(name: string, scene: Scene);
  54679. /**
  54680. * Gets a boolean indicating that current material needs to register RTT
  54681. */
  54682. get hasRenderTargetTextures(): boolean;
  54683. /**
  54684. * The entire material has been created in order to prevent overdraw.
  54685. * @returns false
  54686. */
  54687. needAlphaTesting(): boolean;
  54688. /**
  54689. * The entire material has been created in order to prevent overdraw.
  54690. * @returns true if blending is enable
  54691. */
  54692. needAlphaBlending(): boolean;
  54693. /**
  54694. * Checks wether the material is ready to be rendered for a given mesh.
  54695. * @param mesh The mesh to render
  54696. * @param subMesh The submesh to check against
  54697. * @param useInstances Specify wether or not the material is used with instances
  54698. * @returns true if all the dependencies are ready (Textures, Effects...)
  54699. */
  54700. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54701. /**
  54702. * Compute the primary color according to the chosen perceptual color.
  54703. */
  54704. private _computePrimaryColorFromPerceptualColor;
  54705. /**
  54706. * Compute the highlights and shadow colors according to their chosen levels.
  54707. */
  54708. private _computePrimaryColors;
  54709. /**
  54710. * Build the uniform buffer used in the material.
  54711. */
  54712. buildUniformLayout(): void;
  54713. /**
  54714. * Unbind the material.
  54715. */
  54716. unbind(): void;
  54717. /**
  54718. * Bind only the world matrix to the material.
  54719. * @param world The world matrix to bind.
  54720. */
  54721. bindOnlyWorldMatrix(world: Matrix): void;
  54722. /**
  54723. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54724. * @param world The world matrix to bind.
  54725. * @param subMesh The submesh to bind for.
  54726. */
  54727. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54728. /**
  54729. * Checks to see if a texture is used in the material.
  54730. * @param texture - Base texture to use.
  54731. * @returns - Boolean specifying if a texture is used in the material.
  54732. */
  54733. hasTexture(texture: BaseTexture): boolean;
  54734. /**
  54735. * Dispose the material.
  54736. * @param forceDisposeEffect Force disposal of the associated effect.
  54737. * @param forceDisposeTextures Force disposal of the associated textures.
  54738. */
  54739. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54740. /**
  54741. * Clones the material.
  54742. * @param name The cloned name.
  54743. * @returns The cloned material.
  54744. */
  54745. clone(name: string): BackgroundMaterial;
  54746. /**
  54747. * Serializes the current material to its JSON representation.
  54748. * @returns The JSON representation.
  54749. */
  54750. serialize(): any;
  54751. /**
  54752. * Gets the class name of the material
  54753. * @returns "BackgroundMaterial"
  54754. */
  54755. getClassName(): string;
  54756. /**
  54757. * Parse a JSON input to create back a background material.
  54758. * @param source The JSON data to parse
  54759. * @param scene The scene to create the parsed material in
  54760. * @param rootUrl The root url of the assets the material depends upon
  54761. * @returns the instantiated BackgroundMaterial.
  54762. */
  54763. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54764. }
  54765. }
  54766. declare module BABYLON {
  54767. /**
  54768. * Represents the different options available during the creation of
  54769. * a Environment helper.
  54770. *
  54771. * This can control the default ground, skybox and image processing setup of your scene.
  54772. */
  54773. export interface IEnvironmentHelperOptions {
  54774. /**
  54775. * Specifies whether or not to create a ground.
  54776. * True by default.
  54777. */
  54778. createGround: boolean;
  54779. /**
  54780. * Specifies the ground size.
  54781. * 15 by default.
  54782. */
  54783. groundSize: number;
  54784. /**
  54785. * The texture used on the ground for the main color.
  54786. * Comes from the BabylonJS CDN by default.
  54787. *
  54788. * Remarks: Can be either a texture or a url.
  54789. */
  54790. groundTexture: string | BaseTexture;
  54791. /**
  54792. * The color mixed in the ground texture by default.
  54793. * BabylonJS clearColor by default.
  54794. */
  54795. groundColor: Color3;
  54796. /**
  54797. * Specifies the ground opacity.
  54798. * 1 by default.
  54799. */
  54800. groundOpacity: number;
  54801. /**
  54802. * Enables the ground to receive shadows.
  54803. * True by default.
  54804. */
  54805. enableGroundShadow: boolean;
  54806. /**
  54807. * Helps preventing the shadow to be fully black on the ground.
  54808. * 0.5 by default.
  54809. */
  54810. groundShadowLevel: number;
  54811. /**
  54812. * Creates a mirror texture attach to the ground.
  54813. * false by default.
  54814. */
  54815. enableGroundMirror: boolean;
  54816. /**
  54817. * Specifies the ground mirror size ratio.
  54818. * 0.3 by default as the default kernel is 64.
  54819. */
  54820. groundMirrorSizeRatio: number;
  54821. /**
  54822. * Specifies the ground mirror blur kernel size.
  54823. * 64 by default.
  54824. */
  54825. groundMirrorBlurKernel: number;
  54826. /**
  54827. * Specifies the ground mirror visibility amount.
  54828. * 1 by default
  54829. */
  54830. groundMirrorAmount: number;
  54831. /**
  54832. * Specifies the ground mirror reflectance weight.
  54833. * This uses the standard weight of the background material to setup the fresnel effect
  54834. * of the mirror.
  54835. * 1 by default.
  54836. */
  54837. groundMirrorFresnelWeight: number;
  54838. /**
  54839. * Specifies the ground mirror Falloff distance.
  54840. * This can helps reducing the size of the reflection.
  54841. * 0 by Default.
  54842. */
  54843. groundMirrorFallOffDistance: number;
  54844. /**
  54845. * Specifies the ground mirror texture type.
  54846. * Unsigned Int by Default.
  54847. */
  54848. groundMirrorTextureType: number;
  54849. /**
  54850. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54851. * the shown objects.
  54852. */
  54853. groundYBias: number;
  54854. /**
  54855. * Specifies whether or not to create a skybox.
  54856. * True by default.
  54857. */
  54858. createSkybox: boolean;
  54859. /**
  54860. * Specifies the skybox size.
  54861. * 20 by default.
  54862. */
  54863. skyboxSize: number;
  54864. /**
  54865. * The texture used on the skybox for the main color.
  54866. * Comes from the BabylonJS CDN by default.
  54867. *
  54868. * Remarks: Can be either a texture or a url.
  54869. */
  54870. skyboxTexture: string | BaseTexture;
  54871. /**
  54872. * The color mixed in the skybox texture by default.
  54873. * BabylonJS clearColor by default.
  54874. */
  54875. skyboxColor: Color3;
  54876. /**
  54877. * The background rotation around the Y axis of the scene.
  54878. * This helps aligning the key lights of your scene with the background.
  54879. * 0 by default.
  54880. */
  54881. backgroundYRotation: number;
  54882. /**
  54883. * Compute automatically the size of the elements to best fit with the scene.
  54884. */
  54885. sizeAuto: boolean;
  54886. /**
  54887. * Default position of the rootMesh if autoSize is not true.
  54888. */
  54889. rootPosition: Vector3;
  54890. /**
  54891. * Sets up the image processing in the scene.
  54892. * true by default.
  54893. */
  54894. setupImageProcessing: boolean;
  54895. /**
  54896. * The texture used as your environment texture in the scene.
  54897. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54898. *
  54899. * Remarks: Can be either a texture or a url.
  54900. */
  54901. environmentTexture: string | BaseTexture;
  54902. /**
  54903. * The value of the exposure to apply to the scene.
  54904. * 0.6 by default if setupImageProcessing is true.
  54905. */
  54906. cameraExposure: number;
  54907. /**
  54908. * The value of the contrast to apply to the scene.
  54909. * 1.6 by default if setupImageProcessing is true.
  54910. */
  54911. cameraContrast: number;
  54912. /**
  54913. * Specifies whether or not tonemapping should be enabled in the scene.
  54914. * true by default if setupImageProcessing is true.
  54915. */
  54916. toneMappingEnabled: boolean;
  54917. }
  54918. /**
  54919. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54920. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54921. * It also helps with the default setup of your imageProcessing configuration.
  54922. */
  54923. export class EnvironmentHelper {
  54924. /**
  54925. * Default ground texture URL.
  54926. */
  54927. private static _groundTextureCDNUrl;
  54928. /**
  54929. * Default skybox texture URL.
  54930. */
  54931. private static _skyboxTextureCDNUrl;
  54932. /**
  54933. * Default environment texture URL.
  54934. */
  54935. private static _environmentTextureCDNUrl;
  54936. /**
  54937. * Creates the default options for the helper.
  54938. */
  54939. private static _getDefaultOptions;
  54940. private _rootMesh;
  54941. /**
  54942. * Gets the root mesh created by the helper.
  54943. */
  54944. get rootMesh(): Mesh;
  54945. private _skybox;
  54946. /**
  54947. * Gets the skybox created by the helper.
  54948. */
  54949. get skybox(): Nullable<Mesh>;
  54950. private _skyboxTexture;
  54951. /**
  54952. * Gets the skybox texture created by the helper.
  54953. */
  54954. get skyboxTexture(): Nullable<BaseTexture>;
  54955. private _skyboxMaterial;
  54956. /**
  54957. * Gets the skybox material created by the helper.
  54958. */
  54959. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54960. private _ground;
  54961. /**
  54962. * Gets the ground mesh created by the helper.
  54963. */
  54964. get ground(): Nullable<Mesh>;
  54965. private _groundTexture;
  54966. /**
  54967. * Gets the ground texture created by the helper.
  54968. */
  54969. get groundTexture(): Nullable<BaseTexture>;
  54970. private _groundMirror;
  54971. /**
  54972. * Gets the ground mirror created by the helper.
  54973. */
  54974. get groundMirror(): Nullable<MirrorTexture>;
  54975. /**
  54976. * Gets the ground mirror render list to helps pushing the meshes
  54977. * you wish in the ground reflection.
  54978. */
  54979. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54980. private _groundMaterial;
  54981. /**
  54982. * Gets the ground material created by the helper.
  54983. */
  54984. get groundMaterial(): Nullable<BackgroundMaterial>;
  54985. /**
  54986. * Stores the creation options.
  54987. */
  54988. private readonly _scene;
  54989. private _options;
  54990. /**
  54991. * This observable will be notified with any error during the creation of the environment,
  54992. * mainly texture creation errors.
  54993. */
  54994. onErrorObservable: Observable<{
  54995. message?: string;
  54996. exception?: any;
  54997. }>;
  54998. /**
  54999. * constructor
  55000. * @param options Defines the options we want to customize the helper
  55001. * @param scene The scene to add the material to
  55002. */
  55003. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55004. /**
  55005. * Updates the background according to the new options
  55006. * @param options
  55007. */
  55008. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55009. /**
  55010. * Sets the primary color of all the available elements.
  55011. * @param color the main color to affect to the ground and the background
  55012. */
  55013. setMainColor(color: Color3): void;
  55014. /**
  55015. * Setup the image processing according to the specified options.
  55016. */
  55017. private _setupImageProcessing;
  55018. /**
  55019. * Setup the environment texture according to the specified options.
  55020. */
  55021. private _setupEnvironmentTexture;
  55022. /**
  55023. * Setup the background according to the specified options.
  55024. */
  55025. private _setupBackground;
  55026. /**
  55027. * Get the scene sizes according to the setup.
  55028. */
  55029. private _getSceneSize;
  55030. /**
  55031. * Setup the ground according to the specified options.
  55032. */
  55033. private _setupGround;
  55034. /**
  55035. * Setup the ground material according to the specified options.
  55036. */
  55037. private _setupGroundMaterial;
  55038. /**
  55039. * Setup the ground diffuse texture according to the specified options.
  55040. */
  55041. private _setupGroundDiffuseTexture;
  55042. /**
  55043. * Setup the ground mirror texture according to the specified options.
  55044. */
  55045. private _setupGroundMirrorTexture;
  55046. /**
  55047. * Setup the ground to receive the mirror texture.
  55048. */
  55049. private _setupMirrorInGroundMaterial;
  55050. /**
  55051. * Setup the skybox according to the specified options.
  55052. */
  55053. private _setupSkybox;
  55054. /**
  55055. * Setup the skybox material according to the specified options.
  55056. */
  55057. private _setupSkyboxMaterial;
  55058. /**
  55059. * Setup the skybox reflection texture according to the specified options.
  55060. */
  55061. private _setupSkyboxReflectionTexture;
  55062. private _errorHandler;
  55063. /**
  55064. * Dispose all the elements created by the Helper.
  55065. */
  55066. dispose(): void;
  55067. }
  55068. }
  55069. declare module BABYLON {
  55070. /**
  55071. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55072. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55073. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55074. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55075. */
  55076. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55077. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55078. /**
  55079. * Define the source as a Monoscopic panoramic 360/180.
  55080. */
  55081. static readonly MODE_MONOSCOPIC: number;
  55082. /**
  55083. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55084. */
  55085. static readonly MODE_TOPBOTTOM: number;
  55086. /**
  55087. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55088. */
  55089. static readonly MODE_SIDEBYSIDE: number;
  55090. private _halfDome;
  55091. protected _useDirectMapping: boolean;
  55092. /**
  55093. * The texture being displayed on the sphere
  55094. */
  55095. protected _texture: T;
  55096. /**
  55097. * Gets the texture being displayed on the sphere
  55098. */
  55099. get texture(): T;
  55100. /**
  55101. * Sets the texture being displayed on the sphere
  55102. */
  55103. set texture(newTexture: T);
  55104. /**
  55105. * The skybox material
  55106. */
  55107. protected _material: BackgroundMaterial;
  55108. /**
  55109. * The surface used for the dome
  55110. */
  55111. protected _mesh: Mesh;
  55112. /**
  55113. * Gets the mesh used for the dome.
  55114. */
  55115. get mesh(): Mesh;
  55116. /**
  55117. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55118. */
  55119. private _halfDomeMask;
  55120. /**
  55121. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55122. * Also see the options.resolution property.
  55123. */
  55124. get fovMultiplier(): number;
  55125. set fovMultiplier(value: number);
  55126. protected _textureMode: number;
  55127. /**
  55128. * Gets or set the current texture mode for the texture. It can be:
  55129. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55130. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55131. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55132. */
  55133. get textureMode(): number;
  55134. /**
  55135. * Sets the current texture mode for the texture. It can be:
  55136. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55137. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55138. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55139. */
  55140. set textureMode(value: number);
  55141. /**
  55142. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55143. */
  55144. get halfDome(): boolean;
  55145. /**
  55146. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55147. */
  55148. set halfDome(enabled: boolean);
  55149. /**
  55150. * Oberserver used in Stereoscopic VR Mode.
  55151. */
  55152. private _onBeforeCameraRenderObserver;
  55153. /**
  55154. * Observable raised when an error occured while loading the 360 image
  55155. */
  55156. onLoadErrorObservable: Observable<string>;
  55157. /**
  55158. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55159. * @param name Element's name, child elements will append suffixes for their own names.
  55160. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55161. * @param options An object containing optional or exposed sub element properties
  55162. */
  55163. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55164. resolution?: number;
  55165. clickToPlay?: boolean;
  55166. autoPlay?: boolean;
  55167. loop?: boolean;
  55168. size?: number;
  55169. poster?: string;
  55170. faceForward?: boolean;
  55171. useDirectMapping?: boolean;
  55172. halfDomeMode?: boolean;
  55173. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55174. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55175. protected _changeTextureMode(value: number): void;
  55176. /**
  55177. * Releases resources associated with this node.
  55178. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55179. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55180. */
  55181. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55182. }
  55183. }
  55184. declare module BABYLON {
  55185. /**
  55186. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55187. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55188. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55189. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55190. */
  55191. export class PhotoDome extends TextureDome<Texture> {
  55192. /**
  55193. * Define the image as a Monoscopic panoramic 360 image.
  55194. */
  55195. static readonly MODE_MONOSCOPIC: number;
  55196. /**
  55197. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55198. */
  55199. static readonly MODE_TOPBOTTOM: number;
  55200. /**
  55201. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55202. */
  55203. static readonly MODE_SIDEBYSIDE: number;
  55204. /**
  55205. * Gets or sets the texture being displayed on the sphere
  55206. */
  55207. get photoTexture(): Texture;
  55208. /**
  55209. * sets the texture being displayed on the sphere
  55210. */
  55211. set photoTexture(value: Texture);
  55212. /**
  55213. * Gets the current video mode for the video. It can be:
  55214. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55215. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55216. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55217. */
  55218. get imageMode(): number;
  55219. /**
  55220. * Sets the current video mode for the video. It can be:
  55221. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55222. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55223. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55224. */
  55225. set imageMode(value: number);
  55226. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55227. }
  55228. }
  55229. declare module BABYLON {
  55230. /**
  55231. * Class used to host RGBD texture specific utilities
  55232. */
  55233. export class RGBDTextureTools {
  55234. /**
  55235. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55236. * @param texture the texture to expand.
  55237. */
  55238. static ExpandRGBDTexture(texture: Texture): void;
  55239. }
  55240. }
  55241. declare module BABYLON {
  55242. /**
  55243. * Class used to host texture specific utilities
  55244. */
  55245. export class BRDFTextureTools {
  55246. /**
  55247. * Prevents texture cache collision
  55248. */
  55249. private static _instanceNumber;
  55250. /**
  55251. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55252. * @param scene defines the hosting scene
  55253. * @returns the environment BRDF texture
  55254. */
  55255. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55256. private static _environmentBRDFBase64Texture;
  55257. }
  55258. }
  55259. declare module BABYLON {
  55260. /**
  55261. * @hidden
  55262. */
  55263. export interface IMaterialClearCoatDefines {
  55264. CLEARCOAT: boolean;
  55265. CLEARCOAT_DEFAULTIOR: boolean;
  55266. CLEARCOAT_TEXTURE: boolean;
  55267. CLEARCOAT_TEXTUREDIRECTUV: number;
  55268. CLEARCOAT_BUMP: boolean;
  55269. CLEARCOAT_BUMPDIRECTUV: number;
  55270. CLEARCOAT_TINT: boolean;
  55271. CLEARCOAT_TINT_TEXTURE: boolean;
  55272. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55273. /** @hidden */
  55274. _areTexturesDirty: boolean;
  55275. }
  55276. /**
  55277. * Define the code related to the clear coat parameters of the pbr material.
  55278. */
  55279. export class PBRClearCoatConfiguration {
  55280. /**
  55281. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55282. * The default fits with a polyurethane material.
  55283. */
  55284. private static readonly _DefaultIndexOfRefraction;
  55285. private _isEnabled;
  55286. /**
  55287. * Defines if the clear coat is enabled in the material.
  55288. */
  55289. isEnabled: boolean;
  55290. /**
  55291. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55292. */
  55293. intensity: number;
  55294. /**
  55295. * Defines the clear coat layer roughness.
  55296. */
  55297. roughness: number;
  55298. private _indexOfRefraction;
  55299. /**
  55300. * Defines the index of refraction of the clear coat.
  55301. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55302. * The default fits with a polyurethane material.
  55303. * Changing the default value is more performance intensive.
  55304. */
  55305. indexOfRefraction: number;
  55306. private _texture;
  55307. /**
  55308. * Stores the clear coat values in a texture.
  55309. */
  55310. texture: Nullable<BaseTexture>;
  55311. private _bumpTexture;
  55312. /**
  55313. * Define the clear coat specific bump texture.
  55314. */
  55315. bumpTexture: Nullable<BaseTexture>;
  55316. private _isTintEnabled;
  55317. /**
  55318. * Defines if the clear coat tint is enabled in the material.
  55319. */
  55320. isTintEnabled: boolean;
  55321. /**
  55322. * Defines the clear coat tint of the material.
  55323. * This is only use if tint is enabled
  55324. */
  55325. tintColor: Color3;
  55326. /**
  55327. * Defines the distance at which the tint color should be found in the
  55328. * clear coat media.
  55329. * This is only use if tint is enabled
  55330. */
  55331. tintColorAtDistance: number;
  55332. /**
  55333. * Defines the clear coat layer thickness.
  55334. * This is only use if tint is enabled
  55335. */
  55336. tintThickness: number;
  55337. private _tintTexture;
  55338. /**
  55339. * Stores the clear tint values in a texture.
  55340. * rgb is tint
  55341. * a is a thickness factor
  55342. */
  55343. tintTexture: Nullable<BaseTexture>;
  55344. /** @hidden */
  55345. private _internalMarkAllSubMeshesAsTexturesDirty;
  55346. /** @hidden */
  55347. _markAllSubMeshesAsTexturesDirty(): void;
  55348. /**
  55349. * Instantiate a new istance of clear coat configuration.
  55350. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55351. */
  55352. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55353. /**
  55354. * Gets wehter the submesh is ready to be used or not.
  55355. * @param defines the list of "defines" to update.
  55356. * @param scene defines the scene the material belongs to.
  55357. * @param engine defines the engine the material belongs to.
  55358. * @param disableBumpMap defines wether the material disables bump or not.
  55359. * @returns - boolean indicating that the submesh is ready or not.
  55360. */
  55361. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55362. /**
  55363. * Checks to see if a texture is used in the material.
  55364. * @param defines the list of "defines" to update.
  55365. * @param scene defines the scene to the material belongs to.
  55366. */
  55367. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55368. /**
  55369. * Binds the material data.
  55370. * @param uniformBuffer defines the Uniform buffer to fill in.
  55371. * @param scene defines the scene the material belongs to.
  55372. * @param engine defines the engine the material belongs to.
  55373. * @param disableBumpMap defines wether the material disables bump or not.
  55374. * @param isFrozen defines wether the material is frozen or not.
  55375. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55376. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55377. */
  55378. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55379. /**
  55380. * Checks to see if a texture is used in the material.
  55381. * @param texture - Base texture to use.
  55382. * @returns - Boolean specifying if a texture is used in the material.
  55383. */
  55384. hasTexture(texture: BaseTexture): boolean;
  55385. /**
  55386. * Returns an array of the actively used textures.
  55387. * @param activeTextures Array of BaseTextures
  55388. */
  55389. getActiveTextures(activeTextures: BaseTexture[]): void;
  55390. /**
  55391. * Returns the animatable textures.
  55392. * @param animatables Array of animatable textures.
  55393. */
  55394. getAnimatables(animatables: IAnimatable[]): void;
  55395. /**
  55396. * Disposes the resources of the material.
  55397. * @param forceDisposeTextures - Forces the disposal of all textures.
  55398. */
  55399. dispose(forceDisposeTextures?: boolean): void;
  55400. /**
  55401. * Get the current class name of the texture useful for serialization or dynamic coding.
  55402. * @returns "PBRClearCoatConfiguration"
  55403. */
  55404. getClassName(): string;
  55405. /**
  55406. * Add fallbacks to the effect fallbacks list.
  55407. * @param defines defines the Base texture to use.
  55408. * @param fallbacks defines the current fallback list.
  55409. * @param currentRank defines the current fallback rank.
  55410. * @returns the new fallback rank.
  55411. */
  55412. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55413. /**
  55414. * Add the required uniforms to the current list.
  55415. * @param uniforms defines the current uniform list.
  55416. */
  55417. static AddUniforms(uniforms: string[]): void;
  55418. /**
  55419. * Add the required samplers to the current list.
  55420. * @param samplers defines the current sampler list.
  55421. */
  55422. static AddSamplers(samplers: string[]): void;
  55423. /**
  55424. * Add the required uniforms to the current buffer.
  55425. * @param uniformBuffer defines the current uniform buffer.
  55426. */
  55427. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55428. /**
  55429. * Makes a duplicate of the current configuration into another one.
  55430. * @param clearCoatConfiguration define the config where to copy the info
  55431. */
  55432. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55433. /**
  55434. * Serializes this clear coat configuration.
  55435. * @returns - An object with the serialized config.
  55436. */
  55437. serialize(): any;
  55438. /**
  55439. * Parses a anisotropy Configuration from a serialized object.
  55440. * @param source - Serialized object.
  55441. * @param scene Defines the scene we are parsing for
  55442. * @param rootUrl Defines the rootUrl to load from
  55443. */
  55444. parse(source: any, scene: Scene, rootUrl: string): void;
  55445. }
  55446. }
  55447. declare module BABYLON {
  55448. /**
  55449. * @hidden
  55450. */
  55451. export interface IMaterialAnisotropicDefines {
  55452. ANISOTROPIC: boolean;
  55453. ANISOTROPIC_TEXTURE: boolean;
  55454. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55455. MAINUV1: boolean;
  55456. _areTexturesDirty: boolean;
  55457. _needUVs: boolean;
  55458. }
  55459. /**
  55460. * Define the code related to the anisotropic parameters of the pbr material.
  55461. */
  55462. export class PBRAnisotropicConfiguration {
  55463. private _isEnabled;
  55464. /**
  55465. * Defines if the anisotropy is enabled in the material.
  55466. */
  55467. isEnabled: boolean;
  55468. /**
  55469. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55470. */
  55471. intensity: number;
  55472. /**
  55473. * Defines if the effect is along the tangents, bitangents or in between.
  55474. * By default, the effect is "strectching" the highlights along the tangents.
  55475. */
  55476. direction: Vector2;
  55477. private _texture;
  55478. /**
  55479. * Stores the anisotropy values in a texture.
  55480. * rg is direction (like normal from -1 to 1)
  55481. * b is a intensity
  55482. */
  55483. texture: Nullable<BaseTexture>;
  55484. /** @hidden */
  55485. private _internalMarkAllSubMeshesAsTexturesDirty;
  55486. /** @hidden */
  55487. _markAllSubMeshesAsTexturesDirty(): void;
  55488. /**
  55489. * Instantiate a new istance of anisotropy configuration.
  55490. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55491. */
  55492. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55493. /**
  55494. * Specifies that the submesh is ready to be used.
  55495. * @param defines the list of "defines" to update.
  55496. * @param scene defines the scene the material belongs to.
  55497. * @returns - boolean indicating that the submesh is ready or not.
  55498. */
  55499. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55500. /**
  55501. * Checks to see if a texture is used in the material.
  55502. * @param defines the list of "defines" to update.
  55503. * @param mesh the mesh we are preparing the defines for.
  55504. * @param scene defines the scene the material belongs to.
  55505. */
  55506. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55507. /**
  55508. * Binds the material data.
  55509. * @param uniformBuffer defines the Uniform buffer to fill in.
  55510. * @param scene defines the scene the material belongs to.
  55511. * @param isFrozen defines wether the material is frozen or not.
  55512. */
  55513. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55514. /**
  55515. * Checks to see if a texture is used in the material.
  55516. * @param texture - Base texture to use.
  55517. * @returns - Boolean specifying if a texture is used in the material.
  55518. */
  55519. hasTexture(texture: BaseTexture): boolean;
  55520. /**
  55521. * Returns an array of the actively used textures.
  55522. * @param activeTextures Array of BaseTextures
  55523. */
  55524. getActiveTextures(activeTextures: BaseTexture[]): void;
  55525. /**
  55526. * Returns the animatable textures.
  55527. * @param animatables Array of animatable textures.
  55528. */
  55529. getAnimatables(animatables: IAnimatable[]): void;
  55530. /**
  55531. * Disposes the resources of the material.
  55532. * @param forceDisposeTextures - Forces the disposal of all textures.
  55533. */
  55534. dispose(forceDisposeTextures?: boolean): void;
  55535. /**
  55536. * Get the current class name of the texture useful for serialization or dynamic coding.
  55537. * @returns "PBRAnisotropicConfiguration"
  55538. */
  55539. getClassName(): string;
  55540. /**
  55541. * Add fallbacks to the effect fallbacks list.
  55542. * @param defines defines the Base texture to use.
  55543. * @param fallbacks defines the current fallback list.
  55544. * @param currentRank defines the current fallback rank.
  55545. * @returns the new fallback rank.
  55546. */
  55547. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55548. /**
  55549. * Add the required uniforms to the current list.
  55550. * @param uniforms defines the current uniform list.
  55551. */
  55552. static AddUniforms(uniforms: string[]): void;
  55553. /**
  55554. * Add the required uniforms to the current buffer.
  55555. * @param uniformBuffer defines the current uniform buffer.
  55556. */
  55557. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55558. /**
  55559. * Add the required samplers to the current list.
  55560. * @param samplers defines the current sampler list.
  55561. */
  55562. static AddSamplers(samplers: string[]): void;
  55563. /**
  55564. * Makes a duplicate of the current configuration into another one.
  55565. * @param anisotropicConfiguration define the config where to copy the info
  55566. */
  55567. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55568. /**
  55569. * Serializes this anisotropy configuration.
  55570. * @returns - An object with the serialized config.
  55571. */
  55572. serialize(): any;
  55573. /**
  55574. * Parses a anisotropy Configuration from a serialized object.
  55575. * @param source - Serialized object.
  55576. * @param scene Defines the scene we are parsing for
  55577. * @param rootUrl Defines the rootUrl to load from
  55578. */
  55579. parse(source: any, scene: Scene, rootUrl: string): void;
  55580. }
  55581. }
  55582. declare module BABYLON {
  55583. /**
  55584. * @hidden
  55585. */
  55586. export interface IMaterialBRDFDefines {
  55587. BRDF_V_HEIGHT_CORRELATED: boolean;
  55588. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55589. SPHERICAL_HARMONICS: boolean;
  55590. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55591. /** @hidden */
  55592. _areMiscDirty: boolean;
  55593. }
  55594. /**
  55595. * Define the code related to the BRDF parameters of the pbr material.
  55596. */
  55597. export class PBRBRDFConfiguration {
  55598. /**
  55599. * Default value used for the energy conservation.
  55600. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55601. */
  55602. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55603. /**
  55604. * Default value used for the Smith Visibility Height Correlated mode.
  55605. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55606. */
  55607. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55608. /**
  55609. * Default value used for the IBL diffuse part.
  55610. * This can help switching back to the polynomials mode globally which is a tiny bit
  55611. * less GPU intensive at the drawback of a lower quality.
  55612. */
  55613. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55614. /**
  55615. * Default value used for activating energy conservation for the specular workflow.
  55616. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55617. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55618. */
  55619. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55620. private _useEnergyConservation;
  55621. /**
  55622. * Defines if the material uses energy conservation.
  55623. */
  55624. useEnergyConservation: boolean;
  55625. private _useSmithVisibilityHeightCorrelated;
  55626. /**
  55627. * LEGACY Mode set to false
  55628. * Defines if the material uses height smith correlated visibility term.
  55629. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55630. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55631. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55632. * Not relying on height correlated will also disable energy conservation.
  55633. */
  55634. useSmithVisibilityHeightCorrelated: boolean;
  55635. private _useSphericalHarmonics;
  55636. /**
  55637. * LEGACY Mode set to false
  55638. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55639. * diffuse part of the IBL.
  55640. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55641. * to the ground truth.
  55642. */
  55643. useSphericalHarmonics: boolean;
  55644. private _useSpecularGlossinessInputEnergyConservation;
  55645. /**
  55646. * Defines if the material uses energy conservation, when the specular workflow is active.
  55647. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55648. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55649. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55650. */
  55651. useSpecularGlossinessInputEnergyConservation: boolean;
  55652. /** @hidden */
  55653. private _internalMarkAllSubMeshesAsMiscDirty;
  55654. /** @hidden */
  55655. _markAllSubMeshesAsMiscDirty(): void;
  55656. /**
  55657. * Instantiate a new istance of clear coat configuration.
  55658. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55659. */
  55660. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55661. /**
  55662. * Checks to see if a texture is used in the material.
  55663. * @param defines the list of "defines" to update.
  55664. */
  55665. prepareDefines(defines: IMaterialBRDFDefines): void;
  55666. /**
  55667. * Get the current class name of the texture useful for serialization or dynamic coding.
  55668. * @returns "PBRClearCoatConfiguration"
  55669. */
  55670. getClassName(): string;
  55671. /**
  55672. * Makes a duplicate of the current configuration into another one.
  55673. * @param brdfConfiguration define the config where to copy the info
  55674. */
  55675. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55676. /**
  55677. * Serializes this BRDF configuration.
  55678. * @returns - An object with the serialized config.
  55679. */
  55680. serialize(): any;
  55681. /**
  55682. * Parses a anisotropy Configuration from a serialized object.
  55683. * @param source - Serialized object.
  55684. * @param scene Defines the scene we are parsing for
  55685. * @param rootUrl Defines the rootUrl to load from
  55686. */
  55687. parse(source: any, scene: Scene, rootUrl: string): void;
  55688. }
  55689. }
  55690. declare module BABYLON {
  55691. /**
  55692. * @hidden
  55693. */
  55694. export interface IMaterialSheenDefines {
  55695. SHEEN: boolean;
  55696. SHEEN_TEXTURE: boolean;
  55697. SHEEN_TEXTUREDIRECTUV: number;
  55698. SHEEN_LINKWITHALBEDO: boolean;
  55699. SHEEN_ROUGHNESS: boolean;
  55700. SHEEN_ALBEDOSCALING: boolean;
  55701. /** @hidden */
  55702. _areTexturesDirty: boolean;
  55703. }
  55704. /**
  55705. * Define the code related to the Sheen parameters of the pbr material.
  55706. */
  55707. export class PBRSheenConfiguration {
  55708. private _isEnabled;
  55709. /**
  55710. * Defines if the material uses sheen.
  55711. */
  55712. isEnabled: boolean;
  55713. private _linkSheenWithAlbedo;
  55714. /**
  55715. * Defines if the sheen is linked to the sheen color.
  55716. */
  55717. linkSheenWithAlbedo: boolean;
  55718. /**
  55719. * Defines the sheen intensity.
  55720. */
  55721. intensity: number;
  55722. /**
  55723. * Defines the sheen color.
  55724. */
  55725. color: Color3;
  55726. private _texture;
  55727. /**
  55728. * Stores the sheen tint values in a texture.
  55729. * rgb is tint
  55730. * a is a intensity or roughness if roughness has been defined
  55731. */
  55732. texture: Nullable<BaseTexture>;
  55733. private _roughness;
  55734. /**
  55735. * Defines the sheen roughness.
  55736. * It is not taken into account if linkSheenWithAlbedo is true.
  55737. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55738. */
  55739. roughness: Nullable<number>;
  55740. private _albedoScaling;
  55741. /**
  55742. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55743. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55744. * making it easier to setup and tweak the effect
  55745. */
  55746. albedoScaling: boolean;
  55747. /** @hidden */
  55748. private _internalMarkAllSubMeshesAsTexturesDirty;
  55749. /** @hidden */
  55750. _markAllSubMeshesAsTexturesDirty(): void;
  55751. /**
  55752. * Instantiate a new istance of clear coat configuration.
  55753. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55754. */
  55755. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55756. /**
  55757. * Specifies that the submesh is ready to be used.
  55758. * @param defines the list of "defines" to update.
  55759. * @param scene defines the scene the material belongs to.
  55760. * @returns - boolean indicating that the submesh is ready or not.
  55761. */
  55762. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55763. /**
  55764. * Checks to see if a texture is used in the material.
  55765. * @param defines the list of "defines" to update.
  55766. * @param scene defines the scene the material belongs to.
  55767. */
  55768. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55769. /**
  55770. * Binds the material data.
  55771. * @param uniformBuffer defines the Uniform buffer to fill in.
  55772. * @param scene defines the scene the material belongs to.
  55773. * @param isFrozen defines wether the material is frozen or not.
  55774. */
  55775. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55776. /**
  55777. * Checks to see if a texture is used in the material.
  55778. * @param texture - Base texture to use.
  55779. * @returns - Boolean specifying if a texture is used in the material.
  55780. */
  55781. hasTexture(texture: BaseTexture): boolean;
  55782. /**
  55783. * Returns an array of the actively used textures.
  55784. * @param activeTextures Array of BaseTextures
  55785. */
  55786. getActiveTextures(activeTextures: BaseTexture[]): void;
  55787. /**
  55788. * Returns the animatable textures.
  55789. * @param animatables Array of animatable textures.
  55790. */
  55791. getAnimatables(animatables: IAnimatable[]): void;
  55792. /**
  55793. * Disposes the resources of the material.
  55794. * @param forceDisposeTextures - Forces the disposal of all textures.
  55795. */
  55796. dispose(forceDisposeTextures?: boolean): void;
  55797. /**
  55798. * Get the current class name of the texture useful for serialization or dynamic coding.
  55799. * @returns "PBRSheenConfiguration"
  55800. */
  55801. getClassName(): string;
  55802. /**
  55803. * Add fallbacks to the effect fallbacks list.
  55804. * @param defines defines the Base texture to use.
  55805. * @param fallbacks defines the current fallback list.
  55806. * @param currentRank defines the current fallback rank.
  55807. * @returns the new fallback rank.
  55808. */
  55809. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55810. /**
  55811. * Add the required uniforms to the current list.
  55812. * @param uniforms defines the current uniform list.
  55813. */
  55814. static AddUniforms(uniforms: string[]): void;
  55815. /**
  55816. * Add the required uniforms to the current buffer.
  55817. * @param uniformBuffer defines the current uniform buffer.
  55818. */
  55819. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55820. /**
  55821. * Add the required samplers to the current list.
  55822. * @param samplers defines the current sampler list.
  55823. */
  55824. static AddSamplers(samplers: string[]): void;
  55825. /**
  55826. * Makes a duplicate of the current configuration into another one.
  55827. * @param sheenConfiguration define the config where to copy the info
  55828. */
  55829. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55830. /**
  55831. * Serializes this BRDF configuration.
  55832. * @returns - An object with the serialized config.
  55833. */
  55834. serialize(): any;
  55835. /**
  55836. * Parses a anisotropy Configuration from a serialized object.
  55837. * @param source - Serialized object.
  55838. * @param scene Defines the scene we are parsing for
  55839. * @param rootUrl Defines the rootUrl to load from
  55840. */
  55841. parse(source: any, scene: Scene, rootUrl: string): void;
  55842. }
  55843. }
  55844. declare module BABYLON {
  55845. /**
  55846. * @hidden
  55847. */
  55848. export interface IMaterialSubSurfaceDefines {
  55849. SUBSURFACE: boolean;
  55850. SS_REFRACTION: boolean;
  55851. SS_TRANSLUCENCY: boolean;
  55852. SS_SCATTERING: boolean;
  55853. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55854. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55855. SS_REFRACTIONMAP_3D: boolean;
  55856. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55857. SS_LODINREFRACTIONALPHA: boolean;
  55858. SS_GAMMAREFRACTION: boolean;
  55859. SS_RGBDREFRACTION: boolean;
  55860. SS_LINEARSPECULARREFRACTION: boolean;
  55861. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55862. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55863. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55864. /** @hidden */
  55865. _areTexturesDirty: boolean;
  55866. }
  55867. /**
  55868. * Define the code related to the sub surface parameters of the pbr material.
  55869. */
  55870. export class PBRSubSurfaceConfiguration {
  55871. private _isRefractionEnabled;
  55872. /**
  55873. * Defines if the refraction is enabled in the material.
  55874. */
  55875. isRefractionEnabled: boolean;
  55876. private _isTranslucencyEnabled;
  55877. /**
  55878. * Defines if the translucency is enabled in the material.
  55879. */
  55880. isTranslucencyEnabled: boolean;
  55881. private _isScatteringEnabled;
  55882. /**
  55883. * Defines if the sub surface scattering is enabled in the material.
  55884. */
  55885. isScatteringEnabled: boolean;
  55886. private _scatteringDiffusionProfileIndex;
  55887. /**
  55888. * Diffusion profile for subsurface scattering.
  55889. * Useful for better scattering in the skins or foliages.
  55890. */
  55891. get scatteringDiffusionProfile(): Nullable<Color3>;
  55892. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55893. /**
  55894. * Defines the refraction intensity of the material.
  55895. * The refraction when enabled replaces the Diffuse part of the material.
  55896. * The intensity helps transitionning between diffuse and refraction.
  55897. */
  55898. refractionIntensity: number;
  55899. /**
  55900. * Defines the translucency intensity of the material.
  55901. * When translucency has been enabled, this defines how much of the "translucency"
  55902. * is addded to the diffuse part of the material.
  55903. */
  55904. translucencyIntensity: number;
  55905. /**
  55906. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55907. */
  55908. useAlbedoToTintRefraction: boolean;
  55909. private _thicknessTexture;
  55910. /**
  55911. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55912. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55913. * 0 would mean minimumThickness
  55914. * 1 would mean maximumThickness
  55915. * The other channels might be use as a mask to vary the different effects intensity.
  55916. */
  55917. thicknessTexture: Nullable<BaseTexture>;
  55918. private _refractionTexture;
  55919. /**
  55920. * Defines the texture to use for refraction.
  55921. */
  55922. refractionTexture: Nullable<BaseTexture>;
  55923. private _indexOfRefraction;
  55924. /**
  55925. * Index of refraction of the material base layer.
  55926. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55927. *
  55928. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55929. *
  55930. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55931. */
  55932. indexOfRefraction: number;
  55933. private _volumeIndexOfRefraction;
  55934. /**
  55935. * Index of refraction of the material's volume.
  55936. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55937. *
  55938. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55939. * the volume will use the same IOR as the surface.
  55940. */
  55941. get volumeIndexOfRefraction(): number;
  55942. set volumeIndexOfRefraction(value: number);
  55943. private _invertRefractionY;
  55944. /**
  55945. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55946. */
  55947. invertRefractionY: boolean;
  55948. private _linkRefractionWithTransparency;
  55949. /**
  55950. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55951. * Materials half opaque for instance using refraction could benefit from this control.
  55952. */
  55953. linkRefractionWithTransparency: boolean;
  55954. /**
  55955. * Defines the minimum thickness stored in the thickness map.
  55956. * If no thickness map is defined, this value will be used to simulate thickness.
  55957. */
  55958. minimumThickness: number;
  55959. /**
  55960. * Defines the maximum thickness stored in the thickness map.
  55961. */
  55962. maximumThickness: number;
  55963. /**
  55964. * Defines the volume tint of the material.
  55965. * This is used for both translucency and scattering.
  55966. */
  55967. tintColor: Color3;
  55968. /**
  55969. * Defines the distance at which the tint color should be found in the media.
  55970. * This is used for refraction only.
  55971. */
  55972. tintColorAtDistance: number;
  55973. /**
  55974. * Defines how far each channel transmit through the media.
  55975. * It is defined as a color to simplify it selection.
  55976. */
  55977. diffusionDistance: Color3;
  55978. private _useMaskFromThicknessTexture;
  55979. /**
  55980. * Stores the intensity of the different subsurface effects in the thickness texture.
  55981. * * the green channel is the translucency intensity.
  55982. * * the blue channel is the scattering intensity.
  55983. * * the alpha channel is the refraction intensity.
  55984. */
  55985. useMaskFromThicknessTexture: boolean;
  55986. private _scene;
  55987. /** @hidden */
  55988. private _internalMarkAllSubMeshesAsTexturesDirty;
  55989. private _internalMarkScenePrePassDirty;
  55990. /** @hidden */
  55991. _markAllSubMeshesAsTexturesDirty(): void;
  55992. /** @hidden */
  55993. _markScenePrePassDirty(): void;
  55994. /**
  55995. * Instantiate a new istance of sub surface configuration.
  55996. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55997. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55998. * @param scene The scene
  55999. */
  56000. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  56001. /**
  56002. * Gets wehter the submesh is ready to be used or not.
  56003. * @param defines the list of "defines" to update.
  56004. * @param scene defines the scene the material belongs to.
  56005. * @returns - boolean indicating that the submesh is ready or not.
  56006. */
  56007. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56008. /**
  56009. * Checks to see if a texture is used in the material.
  56010. * @param defines the list of "defines" to update.
  56011. * @param scene defines the scene to the material belongs to.
  56012. */
  56013. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56014. /**
  56015. * Binds the material data.
  56016. * @param uniformBuffer defines the Uniform buffer to fill in.
  56017. * @param scene defines the scene the material belongs to.
  56018. * @param engine defines the engine the material belongs to.
  56019. * @param isFrozen defines whether the material is frozen or not.
  56020. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56021. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56022. */
  56023. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56024. /**
  56025. * Unbinds the material from the mesh.
  56026. * @param activeEffect defines the effect that should be unbound from.
  56027. * @returns true if unbound, otherwise false
  56028. */
  56029. unbind(activeEffect: Effect): boolean;
  56030. /**
  56031. * Returns the texture used for refraction or null if none is used.
  56032. * @param scene defines the scene the material belongs to.
  56033. * @returns - Refraction texture if present. If no refraction texture and refraction
  56034. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56035. */
  56036. private _getRefractionTexture;
  56037. /**
  56038. * Returns true if alpha blending should be disabled.
  56039. */
  56040. get disableAlphaBlending(): boolean;
  56041. /**
  56042. * Fills the list of render target textures.
  56043. * @param renderTargets the list of render targets to update
  56044. */
  56045. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56046. /**
  56047. * Checks to see if a texture is used in the material.
  56048. * @param texture - Base texture to use.
  56049. * @returns - Boolean specifying if a texture is used in the material.
  56050. */
  56051. hasTexture(texture: BaseTexture): boolean;
  56052. /**
  56053. * Gets a boolean indicating that current material needs to register RTT
  56054. * @returns true if this uses a render target otherwise false.
  56055. */
  56056. hasRenderTargetTextures(): boolean;
  56057. /**
  56058. * Returns an array of the actively used textures.
  56059. * @param activeTextures Array of BaseTextures
  56060. */
  56061. getActiveTextures(activeTextures: BaseTexture[]): void;
  56062. /**
  56063. * Returns the animatable textures.
  56064. * @param animatables Array of animatable textures.
  56065. */
  56066. getAnimatables(animatables: IAnimatable[]): void;
  56067. /**
  56068. * Disposes the resources of the material.
  56069. * @param forceDisposeTextures - Forces the disposal of all textures.
  56070. */
  56071. dispose(forceDisposeTextures?: boolean): void;
  56072. /**
  56073. * Get the current class name of the texture useful for serialization or dynamic coding.
  56074. * @returns "PBRSubSurfaceConfiguration"
  56075. */
  56076. getClassName(): string;
  56077. /**
  56078. * Add fallbacks to the effect fallbacks list.
  56079. * @param defines defines the Base texture to use.
  56080. * @param fallbacks defines the current fallback list.
  56081. * @param currentRank defines the current fallback rank.
  56082. * @returns the new fallback rank.
  56083. */
  56084. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56085. /**
  56086. * Add the required uniforms to the current list.
  56087. * @param uniforms defines the current uniform list.
  56088. */
  56089. static AddUniforms(uniforms: string[]): void;
  56090. /**
  56091. * Add the required samplers to the current list.
  56092. * @param samplers defines the current sampler list.
  56093. */
  56094. static AddSamplers(samplers: string[]): void;
  56095. /**
  56096. * Add the required uniforms to the current buffer.
  56097. * @param uniformBuffer defines the current uniform buffer.
  56098. */
  56099. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56100. /**
  56101. * Makes a duplicate of the current configuration into another one.
  56102. * @param configuration define the config where to copy the info
  56103. */
  56104. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56105. /**
  56106. * Serializes this Sub Surface configuration.
  56107. * @returns - An object with the serialized config.
  56108. */
  56109. serialize(): any;
  56110. /**
  56111. * Parses a anisotropy Configuration from a serialized object.
  56112. * @param source - Serialized object.
  56113. * @param scene Defines the scene we are parsing for
  56114. * @param rootUrl Defines the rootUrl to load from
  56115. */
  56116. parse(source: any, scene: Scene, rootUrl: string): void;
  56117. }
  56118. }
  56119. declare module BABYLON {
  56120. /** @hidden */
  56121. export var pbrFragmentDeclaration: {
  56122. name: string;
  56123. shader: string;
  56124. };
  56125. }
  56126. declare module BABYLON {
  56127. /** @hidden */
  56128. export var pbrUboDeclaration: {
  56129. name: string;
  56130. shader: string;
  56131. };
  56132. }
  56133. declare module BABYLON {
  56134. /** @hidden */
  56135. export var pbrFragmentExtraDeclaration: {
  56136. name: string;
  56137. shader: string;
  56138. };
  56139. }
  56140. declare module BABYLON {
  56141. /** @hidden */
  56142. export var pbrFragmentSamplersDeclaration: {
  56143. name: string;
  56144. shader: string;
  56145. };
  56146. }
  56147. declare module BABYLON {
  56148. /** @hidden */
  56149. export var importanceSampling: {
  56150. name: string;
  56151. shader: string;
  56152. };
  56153. }
  56154. declare module BABYLON {
  56155. /** @hidden */
  56156. export var pbrHelperFunctions: {
  56157. name: string;
  56158. shader: string;
  56159. };
  56160. }
  56161. declare module BABYLON {
  56162. /** @hidden */
  56163. export var harmonicsFunctions: {
  56164. name: string;
  56165. shader: string;
  56166. };
  56167. }
  56168. declare module BABYLON {
  56169. /** @hidden */
  56170. export var pbrDirectLightingSetupFunctions: {
  56171. name: string;
  56172. shader: string;
  56173. };
  56174. }
  56175. declare module BABYLON {
  56176. /** @hidden */
  56177. export var pbrDirectLightingFalloffFunctions: {
  56178. name: string;
  56179. shader: string;
  56180. };
  56181. }
  56182. declare module BABYLON {
  56183. /** @hidden */
  56184. export var pbrBRDFFunctions: {
  56185. name: string;
  56186. shader: string;
  56187. };
  56188. }
  56189. declare module BABYLON {
  56190. /** @hidden */
  56191. export var hdrFilteringFunctions: {
  56192. name: string;
  56193. shader: string;
  56194. };
  56195. }
  56196. declare module BABYLON {
  56197. /** @hidden */
  56198. export var pbrDirectLightingFunctions: {
  56199. name: string;
  56200. shader: string;
  56201. };
  56202. }
  56203. declare module BABYLON {
  56204. /** @hidden */
  56205. export var pbrIBLFunctions: {
  56206. name: string;
  56207. shader: string;
  56208. };
  56209. }
  56210. declare module BABYLON {
  56211. /** @hidden */
  56212. export var pbrBlockAlbedoOpacity: {
  56213. name: string;
  56214. shader: string;
  56215. };
  56216. }
  56217. declare module BABYLON {
  56218. /** @hidden */
  56219. export var pbrBlockReflectivity: {
  56220. name: string;
  56221. shader: string;
  56222. };
  56223. }
  56224. declare module BABYLON {
  56225. /** @hidden */
  56226. export var pbrBlockAmbientOcclusion: {
  56227. name: string;
  56228. shader: string;
  56229. };
  56230. }
  56231. declare module BABYLON {
  56232. /** @hidden */
  56233. export var pbrBlockAlphaFresnel: {
  56234. name: string;
  56235. shader: string;
  56236. };
  56237. }
  56238. declare module BABYLON {
  56239. /** @hidden */
  56240. export var pbrBlockAnisotropic: {
  56241. name: string;
  56242. shader: string;
  56243. };
  56244. }
  56245. declare module BABYLON {
  56246. /** @hidden */
  56247. export var pbrBlockReflection: {
  56248. name: string;
  56249. shader: string;
  56250. };
  56251. }
  56252. declare module BABYLON {
  56253. /** @hidden */
  56254. export var pbrBlockSheen: {
  56255. name: string;
  56256. shader: string;
  56257. };
  56258. }
  56259. declare module BABYLON {
  56260. /** @hidden */
  56261. export var pbrBlockClearcoat: {
  56262. name: string;
  56263. shader: string;
  56264. };
  56265. }
  56266. declare module BABYLON {
  56267. /** @hidden */
  56268. export var pbrBlockSubSurface: {
  56269. name: string;
  56270. shader: string;
  56271. };
  56272. }
  56273. declare module BABYLON {
  56274. /** @hidden */
  56275. export var pbrBlockNormalGeometric: {
  56276. name: string;
  56277. shader: string;
  56278. };
  56279. }
  56280. declare module BABYLON {
  56281. /** @hidden */
  56282. export var pbrBlockNormalFinal: {
  56283. name: string;
  56284. shader: string;
  56285. };
  56286. }
  56287. declare module BABYLON {
  56288. /** @hidden */
  56289. export var pbrBlockLightmapInit: {
  56290. name: string;
  56291. shader: string;
  56292. };
  56293. }
  56294. declare module BABYLON {
  56295. /** @hidden */
  56296. export var pbrBlockGeometryInfo: {
  56297. name: string;
  56298. shader: string;
  56299. };
  56300. }
  56301. declare module BABYLON {
  56302. /** @hidden */
  56303. export var pbrBlockReflectance0: {
  56304. name: string;
  56305. shader: string;
  56306. };
  56307. }
  56308. declare module BABYLON {
  56309. /** @hidden */
  56310. export var pbrBlockReflectance: {
  56311. name: string;
  56312. shader: string;
  56313. };
  56314. }
  56315. declare module BABYLON {
  56316. /** @hidden */
  56317. export var pbrBlockDirectLighting: {
  56318. name: string;
  56319. shader: string;
  56320. };
  56321. }
  56322. declare module BABYLON {
  56323. /** @hidden */
  56324. export var pbrBlockFinalLitComponents: {
  56325. name: string;
  56326. shader: string;
  56327. };
  56328. }
  56329. declare module BABYLON {
  56330. /** @hidden */
  56331. export var pbrBlockFinalUnlitComponents: {
  56332. name: string;
  56333. shader: string;
  56334. };
  56335. }
  56336. declare module BABYLON {
  56337. /** @hidden */
  56338. export var pbrBlockFinalColorComposition: {
  56339. name: string;
  56340. shader: string;
  56341. };
  56342. }
  56343. declare module BABYLON {
  56344. /** @hidden */
  56345. export var pbrBlockImageProcessing: {
  56346. name: string;
  56347. shader: string;
  56348. };
  56349. }
  56350. declare module BABYLON {
  56351. /** @hidden */
  56352. export var pbrDebug: {
  56353. name: string;
  56354. shader: string;
  56355. };
  56356. }
  56357. declare module BABYLON {
  56358. /** @hidden */
  56359. export var pbrPixelShader: {
  56360. name: string;
  56361. shader: string;
  56362. };
  56363. }
  56364. declare module BABYLON {
  56365. /** @hidden */
  56366. export var pbrVertexDeclaration: {
  56367. name: string;
  56368. shader: string;
  56369. };
  56370. }
  56371. declare module BABYLON {
  56372. /** @hidden */
  56373. export var pbrVertexShader: {
  56374. name: string;
  56375. shader: string;
  56376. };
  56377. }
  56378. declare module BABYLON {
  56379. /**
  56380. * Manages the defines for the PBR Material.
  56381. * @hidden
  56382. */
  56383. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56384. PBR: boolean;
  56385. NUM_SAMPLES: string;
  56386. REALTIME_FILTERING: boolean;
  56387. MAINUV1: boolean;
  56388. MAINUV2: boolean;
  56389. UV1: boolean;
  56390. UV2: boolean;
  56391. ALBEDO: boolean;
  56392. GAMMAALBEDO: boolean;
  56393. ALBEDODIRECTUV: number;
  56394. VERTEXCOLOR: boolean;
  56395. DETAIL: boolean;
  56396. DETAILDIRECTUV: number;
  56397. DETAIL_NORMALBLENDMETHOD: number;
  56398. AMBIENT: boolean;
  56399. AMBIENTDIRECTUV: number;
  56400. AMBIENTINGRAYSCALE: boolean;
  56401. OPACITY: boolean;
  56402. VERTEXALPHA: boolean;
  56403. OPACITYDIRECTUV: number;
  56404. OPACITYRGB: boolean;
  56405. ALPHATEST: boolean;
  56406. DEPTHPREPASS: boolean;
  56407. ALPHABLEND: boolean;
  56408. ALPHAFROMALBEDO: boolean;
  56409. ALPHATESTVALUE: string;
  56410. SPECULAROVERALPHA: boolean;
  56411. RADIANCEOVERALPHA: boolean;
  56412. ALPHAFRESNEL: boolean;
  56413. LINEARALPHAFRESNEL: boolean;
  56414. PREMULTIPLYALPHA: boolean;
  56415. EMISSIVE: boolean;
  56416. EMISSIVEDIRECTUV: number;
  56417. REFLECTIVITY: boolean;
  56418. REFLECTIVITYDIRECTUV: number;
  56419. SPECULARTERM: boolean;
  56420. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56421. MICROSURFACEAUTOMATIC: boolean;
  56422. LODBASEDMICROSFURACE: boolean;
  56423. MICROSURFACEMAP: boolean;
  56424. MICROSURFACEMAPDIRECTUV: number;
  56425. METALLICWORKFLOW: boolean;
  56426. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56427. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56428. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56429. AOSTOREINMETALMAPRED: boolean;
  56430. METALLIC_REFLECTANCE: boolean;
  56431. METALLIC_REFLECTANCEDIRECTUV: number;
  56432. ENVIRONMENTBRDF: boolean;
  56433. ENVIRONMENTBRDF_RGBD: boolean;
  56434. NORMAL: boolean;
  56435. TANGENT: boolean;
  56436. BUMP: boolean;
  56437. BUMPDIRECTUV: number;
  56438. OBJECTSPACE_NORMALMAP: boolean;
  56439. PARALLAX: boolean;
  56440. PARALLAXOCCLUSION: boolean;
  56441. NORMALXYSCALE: boolean;
  56442. LIGHTMAP: boolean;
  56443. LIGHTMAPDIRECTUV: number;
  56444. USELIGHTMAPASSHADOWMAP: boolean;
  56445. GAMMALIGHTMAP: boolean;
  56446. RGBDLIGHTMAP: boolean;
  56447. REFLECTION: boolean;
  56448. REFLECTIONMAP_3D: boolean;
  56449. REFLECTIONMAP_SPHERICAL: boolean;
  56450. REFLECTIONMAP_PLANAR: boolean;
  56451. REFLECTIONMAP_CUBIC: boolean;
  56452. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56453. REFLECTIONMAP_PROJECTION: boolean;
  56454. REFLECTIONMAP_SKYBOX: boolean;
  56455. REFLECTIONMAP_EXPLICIT: boolean;
  56456. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56457. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56458. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56459. INVERTCUBICMAP: boolean;
  56460. USESPHERICALFROMREFLECTIONMAP: boolean;
  56461. USEIRRADIANCEMAP: boolean;
  56462. SPHERICAL_HARMONICS: boolean;
  56463. USESPHERICALINVERTEX: boolean;
  56464. REFLECTIONMAP_OPPOSITEZ: boolean;
  56465. LODINREFLECTIONALPHA: boolean;
  56466. GAMMAREFLECTION: boolean;
  56467. RGBDREFLECTION: boolean;
  56468. LINEARSPECULARREFLECTION: boolean;
  56469. RADIANCEOCCLUSION: boolean;
  56470. HORIZONOCCLUSION: boolean;
  56471. INSTANCES: boolean;
  56472. THIN_INSTANCES: boolean;
  56473. PREPASS: boolean;
  56474. SCENE_MRT_COUNT: number;
  56475. NUM_BONE_INFLUENCERS: number;
  56476. BonesPerMesh: number;
  56477. BONETEXTURE: boolean;
  56478. NONUNIFORMSCALING: boolean;
  56479. MORPHTARGETS: boolean;
  56480. MORPHTARGETS_NORMAL: boolean;
  56481. MORPHTARGETS_TANGENT: boolean;
  56482. MORPHTARGETS_UV: boolean;
  56483. NUM_MORPH_INFLUENCERS: number;
  56484. IMAGEPROCESSING: boolean;
  56485. VIGNETTE: boolean;
  56486. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56487. VIGNETTEBLENDMODEOPAQUE: boolean;
  56488. TONEMAPPING: boolean;
  56489. TONEMAPPING_ACES: boolean;
  56490. CONTRAST: boolean;
  56491. COLORCURVES: boolean;
  56492. COLORGRADING: boolean;
  56493. COLORGRADING3D: boolean;
  56494. SAMPLER3DGREENDEPTH: boolean;
  56495. SAMPLER3DBGRMAP: boolean;
  56496. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56497. EXPOSURE: boolean;
  56498. MULTIVIEW: boolean;
  56499. USEPHYSICALLIGHTFALLOFF: boolean;
  56500. USEGLTFLIGHTFALLOFF: boolean;
  56501. TWOSIDEDLIGHTING: boolean;
  56502. SHADOWFLOAT: boolean;
  56503. CLIPPLANE: boolean;
  56504. CLIPPLANE2: boolean;
  56505. CLIPPLANE3: boolean;
  56506. CLIPPLANE4: boolean;
  56507. CLIPPLANE5: boolean;
  56508. CLIPPLANE6: boolean;
  56509. POINTSIZE: boolean;
  56510. FOG: boolean;
  56511. LOGARITHMICDEPTH: boolean;
  56512. FORCENORMALFORWARD: boolean;
  56513. SPECULARAA: boolean;
  56514. CLEARCOAT: boolean;
  56515. CLEARCOAT_DEFAULTIOR: boolean;
  56516. CLEARCOAT_TEXTURE: boolean;
  56517. CLEARCOAT_TEXTUREDIRECTUV: number;
  56518. CLEARCOAT_BUMP: boolean;
  56519. CLEARCOAT_BUMPDIRECTUV: number;
  56520. CLEARCOAT_TINT: boolean;
  56521. CLEARCOAT_TINT_TEXTURE: boolean;
  56522. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56523. ANISOTROPIC: boolean;
  56524. ANISOTROPIC_TEXTURE: boolean;
  56525. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56526. BRDF_V_HEIGHT_CORRELATED: boolean;
  56527. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56528. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56529. SHEEN: boolean;
  56530. SHEEN_TEXTURE: boolean;
  56531. SHEEN_TEXTUREDIRECTUV: number;
  56532. SHEEN_LINKWITHALBEDO: boolean;
  56533. SHEEN_ROUGHNESS: boolean;
  56534. SHEEN_ALBEDOSCALING: boolean;
  56535. SUBSURFACE: boolean;
  56536. SS_REFRACTION: boolean;
  56537. SS_TRANSLUCENCY: boolean;
  56538. SS_SCATTERING: boolean;
  56539. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56540. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56541. SS_REFRACTIONMAP_3D: boolean;
  56542. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56543. SS_LODINREFRACTIONALPHA: boolean;
  56544. SS_GAMMAREFRACTION: boolean;
  56545. SS_RGBDREFRACTION: boolean;
  56546. SS_LINEARSPECULARREFRACTION: boolean;
  56547. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56548. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56549. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56550. UNLIT: boolean;
  56551. DEBUGMODE: number;
  56552. /**
  56553. * Initializes the PBR Material defines.
  56554. */
  56555. constructor();
  56556. /**
  56557. * Resets the PBR Material defines.
  56558. */
  56559. reset(): void;
  56560. }
  56561. /**
  56562. * The Physically based material base class of BJS.
  56563. *
  56564. * This offers the main features of a standard PBR material.
  56565. * For more information, please refer to the documentation :
  56566. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56567. */
  56568. export abstract class PBRBaseMaterial extends PushMaterial {
  56569. /**
  56570. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56571. */
  56572. static readonly PBRMATERIAL_OPAQUE: number;
  56573. /**
  56574. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56575. */
  56576. static readonly PBRMATERIAL_ALPHATEST: number;
  56577. /**
  56578. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56579. */
  56580. static readonly PBRMATERIAL_ALPHABLEND: number;
  56581. /**
  56582. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56583. * They are also discarded below the alpha cutoff threshold to improve performances.
  56584. */
  56585. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56586. /**
  56587. * Defines the default value of how much AO map is occluding the analytical lights
  56588. * (point spot...).
  56589. */
  56590. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56591. /**
  56592. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56593. */
  56594. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56595. /**
  56596. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56597. * to enhance interoperability with other engines.
  56598. */
  56599. static readonly LIGHTFALLOFF_GLTF: number;
  56600. /**
  56601. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56602. * to enhance interoperability with other materials.
  56603. */
  56604. static readonly LIGHTFALLOFF_STANDARD: number;
  56605. /**
  56606. * Intensity of the direct lights e.g. the four lights available in your scene.
  56607. * This impacts both the direct diffuse and specular highlights.
  56608. */
  56609. protected _directIntensity: number;
  56610. /**
  56611. * Intensity of the emissive part of the material.
  56612. * This helps controlling the emissive effect without modifying the emissive color.
  56613. */
  56614. protected _emissiveIntensity: number;
  56615. /**
  56616. * Intensity of the environment e.g. how much the environment will light the object
  56617. * either through harmonics for rough material or through the refelction for shiny ones.
  56618. */
  56619. protected _environmentIntensity: number;
  56620. /**
  56621. * This is a special control allowing the reduction of the specular highlights coming from the
  56622. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56623. */
  56624. protected _specularIntensity: number;
  56625. /**
  56626. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56627. */
  56628. private _lightingInfos;
  56629. /**
  56630. * Debug Control allowing disabling the bump map on this material.
  56631. */
  56632. protected _disableBumpMap: boolean;
  56633. /**
  56634. * AKA Diffuse Texture in standard nomenclature.
  56635. */
  56636. protected _albedoTexture: Nullable<BaseTexture>;
  56637. /**
  56638. * AKA Occlusion Texture in other nomenclature.
  56639. */
  56640. protected _ambientTexture: Nullable<BaseTexture>;
  56641. /**
  56642. * AKA Occlusion Texture Intensity in other nomenclature.
  56643. */
  56644. protected _ambientTextureStrength: number;
  56645. /**
  56646. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56647. * 1 means it completely occludes it
  56648. * 0 mean it has no impact
  56649. */
  56650. protected _ambientTextureImpactOnAnalyticalLights: number;
  56651. /**
  56652. * Stores the alpha values in a texture.
  56653. */
  56654. protected _opacityTexture: Nullable<BaseTexture>;
  56655. /**
  56656. * Stores the reflection values in a texture.
  56657. */
  56658. protected _reflectionTexture: Nullable<BaseTexture>;
  56659. /**
  56660. * Stores the emissive values in a texture.
  56661. */
  56662. protected _emissiveTexture: Nullable<BaseTexture>;
  56663. /**
  56664. * AKA Specular texture in other nomenclature.
  56665. */
  56666. protected _reflectivityTexture: Nullable<BaseTexture>;
  56667. /**
  56668. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56669. */
  56670. protected _metallicTexture: Nullable<BaseTexture>;
  56671. /**
  56672. * Specifies the metallic scalar of the metallic/roughness workflow.
  56673. * Can also be used to scale the metalness values of the metallic texture.
  56674. */
  56675. protected _metallic: Nullable<number>;
  56676. /**
  56677. * Specifies the roughness scalar of the metallic/roughness workflow.
  56678. * Can also be used to scale the roughness values of the metallic texture.
  56679. */
  56680. protected _roughness: Nullable<number>;
  56681. /**
  56682. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56683. * By default the indexOfrefraction is used to compute F0;
  56684. *
  56685. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56686. *
  56687. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56688. * F90 = metallicReflectanceColor;
  56689. */
  56690. protected _metallicF0Factor: number;
  56691. /**
  56692. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56693. * By default the F90 is always 1;
  56694. *
  56695. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56696. *
  56697. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56698. * F90 = metallicReflectanceColor;
  56699. */
  56700. protected _metallicReflectanceColor: Color3;
  56701. /**
  56702. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56703. * This is multiply against the scalar values defined in the material.
  56704. */
  56705. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56706. /**
  56707. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56708. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56709. */
  56710. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56711. /**
  56712. * Stores surface normal data used to displace a mesh in a texture.
  56713. */
  56714. protected _bumpTexture: Nullable<BaseTexture>;
  56715. /**
  56716. * Stores the pre-calculated light information of a mesh in a texture.
  56717. */
  56718. protected _lightmapTexture: Nullable<BaseTexture>;
  56719. /**
  56720. * The color of a material in ambient lighting.
  56721. */
  56722. protected _ambientColor: Color3;
  56723. /**
  56724. * AKA Diffuse Color in other nomenclature.
  56725. */
  56726. protected _albedoColor: Color3;
  56727. /**
  56728. * AKA Specular Color in other nomenclature.
  56729. */
  56730. protected _reflectivityColor: Color3;
  56731. /**
  56732. * The color applied when light is reflected from a material.
  56733. */
  56734. protected _reflectionColor: Color3;
  56735. /**
  56736. * The color applied when light is emitted from a material.
  56737. */
  56738. protected _emissiveColor: Color3;
  56739. /**
  56740. * AKA Glossiness in other nomenclature.
  56741. */
  56742. protected _microSurface: number;
  56743. /**
  56744. * Specifies that the material will use the light map as a show map.
  56745. */
  56746. protected _useLightmapAsShadowmap: boolean;
  56747. /**
  56748. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56749. * makes the reflect vector face the model (under horizon).
  56750. */
  56751. protected _useHorizonOcclusion: boolean;
  56752. /**
  56753. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56754. * too much the area relying on ambient texture to define their ambient occlusion.
  56755. */
  56756. protected _useRadianceOcclusion: boolean;
  56757. /**
  56758. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56759. */
  56760. protected _useAlphaFromAlbedoTexture: boolean;
  56761. /**
  56762. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56763. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56764. */
  56765. protected _useSpecularOverAlpha: boolean;
  56766. /**
  56767. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56768. */
  56769. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56770. /**
  56771. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56772. */
  56773. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56774. /**
  56775. * Specifies if the metallic texture contains the roughness information in its green channel.
  56776. */
  56777. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56778. /**
  56779. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56780. */
  56781. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56782. /**
  56783. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56784. */
  56785. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56786. /**
  56787. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56788. */
  56789. protected _useAmbientInGrayScale: boolean;
  56790. /**
  56791. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56792. * The material will try to infer what glossiness each pixel should be.
  56793. */
  56794. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56795. /**
  56796. * Defines the falloff type used in this material.
  56797. * It by default is Physical.
  56798. */
  56799. protected _lightFalloff: number;
  56800. /**
  56801. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56802. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56803. */
  56804. protected _useRadianceOverAlpha: boolean;
  56805. /**
  56806. * Allows using an object space normal map (instead of tangent space).
  56807. */
  56808. protected _useObjectSpaceNormalMap: boolean;
  56809. /**
  56810. * Allows using the bump map in parallax mode.
  56811. */
  56812. protected _useParallax: boolean;
  56813. /**
  56814. * Allows using the bump map in parallax occlusion mode.
  56815. */
  56816. protected _useParallaxOcclusion: boolean;
  56817. /**
  56818. * Controls the scale bias of the parallax mode.
  56819. */
  56820. protected _parallaxScaleBias: number;
  56821. /**
  56822. * If sets to true, disables all the lights affecting the material.
  56823. */
  56824. protected _disableLighting: boolean;
  56825. /**
  56826. * Number of Simultaneous lights allowed on the material.
  56827. */
  56828. protected _maxSimultaneousLights: number;
  56829. /**
  56830. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56831. */
  56832. protected _invertNormalMapX: boolean;
  56833. /**
  56834. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56835. */
  56836. protected _invertNormalMapY: boolean;
  56837. /**
  56838. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56839. */
  56840. protected _twoSidedLighting: boolean;
  56841. /**
  56842. * Defines the alpha limits in alpha test mode.
  56843. */
  56844. protected _alphaCutOff: number;
  56845. /**
  56846. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56847. */
  56848. protected _forceAlphaTest: boolean;
  56849. /**
  56850. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56851. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56852. */
  56853. protected _useAlphaFresnel: boolean;
  56854. /**
  56855. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56856. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56857. */
  56858. protected _useLinearAlphaFresnel: boolean;
  56859. /**
  56860. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56861. * from cos thetav and roughness:
  56862. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56863. */
  56864. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56865. /**
  56866. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56867. */
  56868. protected _forceIrradianceInFragment: boolean;
  56869. private _realTimeFiltering;
  56870. /**
  56871. * Enables realtime filtering on the texture.
  56872. */
  56873. get realTimeFiltering(): boolean;
  56874. set realTimeFiltering(b: boolean);
  56875. private _realTimeFilteringQuality;
  56876. /**
  56877. * Quality switch for realtime filtering
  56878. */
  56879. get realTimeFilteringQuality(): number;
  56880. set realTimeFilteringQuality(n: number);
  56881. /**
  56882. * Can this material render to several textures at once
  56883. */
  56884. get canRenderToMRT(): boolean;
  56885. /**
  56886. * Force normal to face away from face.
  56887. */
  56888. protected _forceNormalForward: boolean;
  56889. /**
  56890. * Enables specular anti aliasing in the PBR shader.
  56891. * It will both interacts on the Geometry for analytical and IBL lighting.
  56892. * It also prefilter the roughness map based on the bump values.
  56893. */
  56894. protected _enableSpecularAntiAliasing: boolean;
  56895. /**
  56896. * Default configuration related to image processing available in the PBR Material.
  56897. */
  56898. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56899. /**
  56900. * Keep track of the image processing observer to allow dispose and replace.
  56901. */
  56902. private _imageProcessingObserver;
  56903. /**
  56904. * Attaches a new image processing configuration to the PBR Material.
  56905. * @param configuration
  56906. */
  56907. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56908. /**
  56909. * Stores the available render targets.
  56910. */
  56911. private _renderTargets;
  56912. /**
  56913. * Sets the global ambient color for the material used in lighting calculations.
  56914. */
  56915. private _globalAmbientColor;
  56916. /**
  56917. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56918. */
  56919. private _useLogarithmicDepth;
  56920. /**
  56921. * If set to true, no lighting calculations will be applied.
  56922. */
  56923. private _unlit;
  56924. private _debugMode;
  56925. /**
  56926. * @hidden
  56927. * This is reserved for the inspector.
  56928. * Defines the material debug mode.
  56929. * It helps seeing only some components of the material while troubleshooting.
  56930. */
  56931. debugMode: number;
  56932. /**
  56933. * @hidden
  56934. * This is reserved for the inspector.
  56935. * Specify from where on screen the debug mode should start.
  56936. * The value goes from -1 (full screen) to 1 (not visible)
  56937. * It helps with side by side comparison against the final render
  56938. * This defaults to -1
  56939. */
  56940. private debugLimit;
  56941. /**
  56942. * @hidden
  56943. * This is reserved for the inspector.
  56944. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56945. * You can use the factor to better multiply the final value.
  56946. */
  56947. private debugFactor;
  56948. /**
  56949. * Defines the clear coat layer parameters for the material.
  56950. */
  56951. readonly clearCoat: PBRClearCoatConfiguration;
  56952. /**
  56953. * Defines the anisotropic parameters for the material.
  56954. */
  56955. readonly anisotropy: PBRAnisotropicConfiguration;
  56956. /**
  56957. * Defines the BRDF parameters for the material.
  56958. */
  56959. readonly brdf: PBRBRDFConfiguration;
  56960. /**
  56961. * Defines the Sheen parameters for the material.
  56962. */
  56963. readonly sheen: PBRSheenConfiguration;
  56964. /**
  56965. * Defines the SubSurface parameters for the material.
  56966. */
  56967. readonly subSurface: PBRSubSurfaceConfiguration;
  56968. /**
  56969. * Defines the detail map parameters for the material.
  56970. */
  56971. readonly detailMap: DetailMapConfiguration;
  56972. protected _rebuildInParallel: boolean;
  56973. /**
  56974. * Instantiates a new PBRMaterial instance.
  56975. *
  56976. * @param name The material name
  56977. * @param scene The scene the material will be use in.
  56978. */
  56979. constructor(name: string, scene: Scene);
  56980. /**
  56981. * Gets a boolean indicating that current material needs to register RTT
  56982. */
  56983. get hasRenderTargetTextures(): boolean;
  56984. /**
  56985. * Gets the name of the material class.
  56986. */
  56987. getClassName(): string;
  56988. /**
  56989. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56990. */
  56991. get useLogarithmicDepth(): boolean;
  56992. /**
  56993. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56994. */
  56995. set useLogarithmicDepth(value: boolean);
  56996. /**
  56997. * Returns true if alpha blending should be disabled.
  56998. */
  56999. protected get _disableAlphaBlending(): boolean;
  57000. /**
  57001. * Specifies whether or not this material should be rendered in alpha blend mode.
  57002. */
  57003. needAlphaBlending(): boolean;
  57004. /**
  57005. * Specifies whether or not this material should be rendered in alpha test mode.
  57006. */
  57007. needAlphaTesting(): boolean;
  57008. /**
  57009. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57010. */
  57011. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57012. /**
  57013. * Gets the texture used for the alpha test.
  57014. */
  57015. getAlphaTestTexture(): Nullable<BaseTexture>;
  57016. /**
  57017. * Specifies that the submesh is ready to be used.
  57018. * @param mesh - BJS mesh.
  57019. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57020. * @param useInstances - Specifies that instances should be used.
  57021. * @returns - boolean indicating that the submesh is ready or not.
  57022. */
  57023. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57024. /**
  57025. * Specifies if the material uses metallic roughness workflow.
  57026. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57027. */
  57028. isMetallicWorkflow(): boolean;
  57029. private _prepareEffect;
  57030. private _prepareDefines;
  57031. /**
  57032. * Force shader compilation
  57033. */
  57034. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57035. /**
  57036. * Initializes the uniform buffer layout for the shader.
  57037. */
  57038. buildUniformLayout(): void;
  57039. /**
  57040. * Unbinds the material from the mesh
  57041. */
  57042. unbind(): void;
  57043. /**
  57044. * Binds the submesh data.
  57045. * @param world - The world matrix.
  57046. * @param mesh - The BJS mesh.
  57047. * @param subMesh - A submesh of the BJS mesh.
  57048. */
  57049. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57050. /**
  57051. * Returns the animatable textures.
  57052. * @returns - Array of animatable textures.
  57053. */
  57054. getAnimatables(): IAnimatable[];
  57055. /**
  57056. * Returns the texture used for reflections.
  57057. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57058. */
  57059. private _getReflectionTexture;
  57060. /**
  57061. * Returns an array of the actively used textures.
  57062. * @returns - Array of BaseTextures
  57063. */
  57064. getActiveTextures(): BaseTexture[];
  57065. /**
  57066. * Checks to see if a texture is used in the material.
  57067. * @param texture - Base texture to use.
  57068. * @returns - Boolean specifying if a texture is used in the material.
  57069. */
  57070. hasTexture(texture: BaseTexture): boolean;
  57071. /**
  57072. * Sets the required values to the prepass renderer.
  57073. * @param prePassRenderer defines the prepass renderer to setup
  57074. */
  57075. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57076. /**
  57077. * Disposes the resources of the material.
  57078. * @param forceDisposeEffect - Forces the disposal of effects.
  57079. * @param forceDisposeTextures - Forces the disposal of all textures.
  57080. */
  57081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57082. }
  57083. }
  57084. declare module BABYLON {
  57085. /**
  57086. * The Physically based material of BJS.
  57087. *
  57088. * This offers the main features of a standard PBR material.
  57089. * For more information, please refer to the documentation :
  57090. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57091. */
  57092. export class PBRMaterial extends PBRBaseMaterial {
  57093. /**
  57094. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57095. */
  57096. static readonly PBRMATERIAL_OPAQUE: number;
  57097. /**
  57098. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57099. */
  57100. static readonly PBRMATERIAL_ALPHATEST: number;
  57101. /**
  57102. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57103. */
  57104. static readonly PBRMATERIAL_ALPHABLEND: number;
  57105. /**
  57106. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57107. * They are also discarded below the alpha cutoff threshold to improve performances.
  57108. */
  57109. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57110. /**
  57111. * Defines the default value of how much AO map is occluding the analytical lights
  57112. * (point spot...).
  57113. */
  57114. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57115. /**
  57116. * Intensity of the direct lights e.g. the four lights available in your scene.
  57117. * This impacts both the direct diffuse and specular highlights.
  57118. */
  57119. directIntensity: number;
  57120. /**
  57121. * Intensity of the emissive part of the material.
  57122. * This helps controlling the emissive effect without modifying the emissive color.
  57123. */
  57124. emissiveIntensity: number;
  57125. /**
  57126. * Intensity of the environment e.g. how much the environment will light the object
  57127. * either through harmonics for rough material or through the refelction for shiny ones.
  57128. */
  57129. environmentIntensity: number;
  57130. /**
  57131. * This is a special control allowing the reduction of the specular highlights coming from the
  57132. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57133. */
  57134. specularIntensity: number;
  57135. /**
  57136. * Debug Control allowing disabling the bump map on this material.
  57137. */
  57138. disableBumpMap: boolean;
  57139. /**
  57140. * AKA Diffuse Texture in standard nomenclature.
  57141. */
  57142. albedoTexture: BaseTexture;
  57143. /**
  57144. * AKA Occlusion Texture in other nomenclature.
  57145. */
  57146. ambientTexture: BaseTexture;
  57147. /**
  57148. * AKA Occlusion Texture Intensity in other nomenclature.
  57149. */
  57150. ambientTextureStrength: number;
  57151. /**
  57152. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57153. * 1 means it completely occludes it
  57154. * 0 mean it has no impact
  57155. */
  57156. ambientTextureImpactOnAnalyticalLights: number;
  57157. /**
  57158. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57159. */
  57160. opacityTexture: BaseTexture;
  57161. /**
  57162. * Stores the reflection values in a texture.
  57163. */
  57164. reflectionTexture: Nullable<BaseTexture>;
  57165. /**
  57166. * Stores the emissive values in a texture.
  57167. */
  57168. emissiveTexture: BaseTexture;
  57169. /**
  57170. * AKA Specular texture in other nomenclature.
  57171. */
  57172. reflectivityTexture: BaseTexture;
  57173. /**
  57174. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57175. */
  57176. metallicTexture: BaseTexture;
  57177. /**
  57178. * Specifies the metallic scalar of the metallic/roughness workflow.
  57179. * Can also be used to scale the metalness values of the metallic texture.
  57180. */
  57181. metallic: Nullable<number>;
  57182. /**
  57183. * Specifies the roughness scalar of the metallic/roughness workflow.
  57184. * Can also be used to scale the roughness values of the metallic texture.
  57185. */
  57186. roughness: Nullable<number>;
  57187. /**
  57188. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57189. * By default the indexOfrefraction is used to compute F0;
  57190. *
  57191. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57192. *
  57193. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57194. * F90 = metallicReflectanceColor;
  57195. */
  57196. metallicF0Factor: number;
  57197. /**
  57198. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57199. * By default the F90 is always 1;
  57200. *
  57201. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57202. *
  57203. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57204. * F90 = metallicReflectanceColor;
  57205. */
  57206. metallicReflectanceColor: Color3;
  57207. /**
  57208. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57209. * This is multiply against the scalar values defined in the material.
  57210. */
  57211. metallicReflectanceTexture: Nullable<BaseTexture>;
  57212. /**
  57213. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57214. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57215. */
  57216. microSurfaceTexture: BaseTexture;
  57217. /**
  57218. * Stores surface normal data used to displace a mesh in a texture.
  57219. */
  57220. bumpTexture: BaseTexture;
  57221. /**
  57222. * Stores the pre-calculated light information of a mesh in a texture.
  57223. */
  57224. lightmapTexture: BaseTexture;
  57225. /**
  57226. * Stores the refracted light information in a texture.
  57227. */
  57228. get refractionTexture(): Nullable<BaseTexture>;
  57229. set refractionTexture(value: Nullable<BaseTexture>);
  57230. /**
  57231. * The color of a material in ambient lighting.
  57232. */
  57233. ambientColor: Color3;
  57234. /**
  57235. * AKA Diffuse Color in other nomenclature.
  57236. */
  57237. albedoColor: Color3;
  57238. /**
  57239. * AKA Specular Color in other nomenclature.
  57240. */
  57241. reflectivityColor: Color3;
  57242. /**
  57243. * The color reflected from the material.
  57244. */
  57245. reflectionColor: Color3;
  57246. /**
  57247. * The color emitted from the material.
  57248. */
  57249. emissiveColor: Color3;
  57250. /**
  57251. * AKA Glossiness in other nomenclature.
  57252. */
  57253. microSurface: number;
  57254. /**
  57255. * Index of refraction of the material base layer.
  57256. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57257. *
  57258. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57259. *
  57260. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57261. */
  57262. get indexOfRefraction(): number;
  57263. set indexOfRefraction(value: number);
  57264. /**
  57265. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57266. */
  57267. get invertRefractionY(): boolean;
  57268. set invertRefractionY(value: boolean);
  57269. /**
  57270. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57271. * Materials half opaque for instance using refraction could benefit from this control.
  57272. */
  57273. get linkRefractionWithTransparency(): boolean;
  57274. set linkRefractionWithTransparency(value: boolean);
  57275. /**
  57276. * If true, the light map contains occlusion information instead of lighting info.
  57277. */
  57278. useLightmapAsShadowmap: boolean;
  57279. /**
  57280. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57281. */
  57282. useAlphaFromAlbedoTexture: boolean;
  57283. /**
  57284. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57285. */
  57286. forceAlphaTest: boolean;
  57287. /**
  57288. * Defines the alpha limits in alpha test mode.
  57289. */
  57290. alphaCutOff: number;
  57291. /**
  57292. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57293. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57294. */
  57295. useSpecularOverAlpha: boolean;
  57296. /**
  57297. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57298. */
  57299. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57300. /**
  57301. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57302. */
  57303. useRoughnessFromMetallicTextureAlpha: boolean;
  57304. /**
  57305. * Specifies if the metallic texture contains the roughness information in its green channel.
  57306. */
  57307. useRoughnessFromMetallicTextureGreen: boolean;
  57308. /**
  57309. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57310. */
  57311. useMetallnessFromMetallicTextureBlue: boolean;
  57312. /**
  57313. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57314. */
  57315. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57316. /**
  57317. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57318. */
  57319. useAmbientInGrayScale: boolean;
  57320. /**
  57321. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57322. * The material will try to infer what glossiness each pixel should be.
  57323. */
  57324. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57325. /**
  57326. * BJS is using an harcoded light falloff based on a manually sets up range.
  57327. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57328. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57329. */
  57330. get usePhysicalLightFalloff(): boolean;
  57331. /**
  57332. * BJS is using an harcoded light falloff based on a manually sets up range.
  57333. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57334. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57335. */
  57336. set usePhysicalLightFalloff(value: boolean);
  57337. /**
  57338. * In order to support the falloff compatibility with gltf, a special mode has been added
  57339. * to reproduce the gltf light falloff.
  57340. */
  57341. get useGLTFLightFalloff(): boolean;
  57342. /**
  57343. * In order to support the falloff compatibility with gltf, a special mode has been added
  57344. * to reproduce the gltf light falloff.
  57345. */
  57346. set useGLTFLightFalloff(value: boolean);
  57347. /**
  57348. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57349. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57350. */
  57351. useRadianceOverAlpha: boolean;
  57352. /**
  57353. * Allows using an object space normal map (instead of tangent space).
  57354. */
  57355. useObjectSpaceNormalMap: boolean;
  57356. /**
  57357. * Allows using the bump map in parallax mode.
  57358. */
  57359. useParallax: boolean;
  57360. /**
  57361. * Allows using the bump map in parallax occlusion mode.
  57362. */
  57363. useParallaxOcclusion: boolean;
  57364. /**
  57365. * Controls the scale bias of the parallax mode.
  57366. */
  57367. parallaxScaleBias: number;
  57368. /**
  57369. * If sets to true, disables all the lights affecting the material.
  57370. */
  57371. disableLighting: boolean;
  57372. /**
  57373. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57374. */
  57375. forceIrradianceInFragment: boolean;
  57376. /**
  57377. * Number of Simultaneous lights allowed on the material.
  57378. */
  57379. maxSimultaneousLights: number;
  57380. /**
  57381. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57382. */
  57383. invertNormalMapX: boolean;
  57384. /**
  57385. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57386. */
  57387. invertNormalMapY: boolean;
  57388. /**
  57389. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57390. */
  57391. twoSidedLighting: boolean;
  57392. /**
  57393. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57394. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57395. */
  57396. useAlphaFresnel: boolean;
  57397. /**
  57398. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57399. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57400. */
  57401. useLinearAlphaFresnel: boolean;
  57402. /**
  57403. * Let user defines the brdf lookup texture used for IBL.
  57404. * A default 8bit version is embedded but you could point at :
  57405. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57406. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57407. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57408. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57409. */
  57410. environmentBRDFTexture: Nullable<BaseTexture>;
  57411. /**
  57412. * Force normal to face away from face.
  57413. */
  57414. forceNormalForward: boolean;
  57415. /**
  57416. * Enables specular anti aliasing in the PBR shader.
  57417. * It will both interacts on the Geometry for analytical and IBL lighting.
  57418. * It also prefilter the roughness map based on the bump values.
  57419. */
  57420. enableSpecularAntiAliasing: boolean;
  57421. /**
  57422. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57423. * makes the reflect vector face the model (under horizon).
  57424. */
  57425. useHorizonOcclusion: boolean;
  57426. /**
  57427. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57428. * too much the area relying on ambient texture to define their ambient occlusion.
  57429. */
  57430. useRadianceOcclusion: boolean;
  57431. /**
  57432. * If set to true, no lighting calculations will be applied.
  57433. */
  57434. unlit: boolean;
  57435. /**
  57436. * Gets the image processing configuration used either in this material.
  57437. */
  57438. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57439. /**
  57440. * Sets the Default image processing configuration used either in the this material.
  57441. *
  57442. * If sets to null, the scene one is in use.
  57443. */
  57444. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57445. /**
  57446. * Gets wether the color curves effect is enabled.
  57447. */
  57448. get cameraColorCurvesEnabled(): boolean;
  57449. /**
  57450. * Sets wether the color curves effect is enabled.
  57451. */
  57452. set cameraColorCurvesEnabled(value: boolean);
  57453. /**
  57454. * Gets wether the color grading effect is enabled.
  57455. */
  57456. get cameraColorGradingEnabled(): boolean;
  57457. /**
  57458. * Gets wether the color grading effect is enabled.
  57459. */
  57460. set cameraColorGradingEnabled(value: boolean);
  57461. /**
  57462. * Gets wether tonemapping is enabled or not.
  57463. */
  57464. get cameraToneMappingEnabled(): boolean;
  57465. /**
  57466. * Sets wether tonemapping is enabled or not
  57467. */
  57468. set cameraToneMappingEnabled(value: boolean);
  57469. /**
  57470. * The camera exposure used on this material.
  57471. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57472. * This corresponds to a photographic exposure.
  57473. */
  57474. get cameraExposure(): number;
  57475. /**
  57476. * The camera exposure used on this material.
  57477. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57478. * This corresponds to a photographic exposure.
  57479. */
  57480. set cameraExposure(value: number);
  57481. /**
  57482. * Gets The camera contrast used on this material.
  57483. */
  57484. get cameraContrast(): number;
  57485. /**
  57486. * Sets The camera contrast used on this material.
  57487. */
  57488. set cameraContrast(value: number);
  57489. /**
  57490. * Gets the Color Grading 2D Lookup Texture.
  57491. */
  57492. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57493. /**
  57494. * Sets the Color Grading 2D Lookup Texture.
  57495. */
  57496. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57497. /**
  57498. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57499. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57500. * 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;
  57501. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57502. */
  57503. get cameraColorCurves(): Nullable<ColorCurves>;
  57504. /**
  57505. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57506. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57507. * 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;
  57508. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57509. */
  57510. set cameraColorCurves(value: Nullable<ColorCurves>);
  57511. /**
  57512. * Instantiates a new PBRMaterial instance.
  57513. *
  57514. * @param name The material name
  57515. * @param scene The scene the material will be use in.
  57516. */
  57517. constructor(name: string, scene: Scene);
  57518. /**
  57519. * Returns the name of this material class.
  57520. */
  57521. getClassName(): string;
  57522. /**
  57523. * Makes a duplicate of the current material.
  57524. * @param name - name to use for the new material.
  57525. */
  57526. clone(name: string): PBRMaterial;
  57527. /**
  57528. * Serializes this PBR Material.
  57529. * @returns - An object with the serialized material.
  57530. */
  57531. serialize(): any;
  57532. /**
  57533. * Parses a PBR Material from a serialized object.
  57534. * @param source - Serialized object.
  57535. * @param scene - BJS scene instance.
  57536. * @param rootUrl - url for the scene object
  57537. * @returns - PBRMaterial
  57538. */
  57539. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57540. }
  57541. }
  57542. declare module BABYLON {
  57543. /**
  57544. * Direct draw surface info
  57545. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57546. */
  57547. export interface DDSInfo {
  57548. /**
  57549. * Width of the texture
  57550. */
  57551. width: number;
  57552. /**
  57553. * Width of the texture
  57554. */
  57555. height: number;
  57556. /**
  57557. * Number of Mipmaps for the texture
  57558. * @see https://en.wikipedia.org/wiki/Mipmap
  57559. */
  57560. mipmapCount: number;
  57561. /**
  57562. * If the textures format is a known fourCC format
  57563. * @see https://www.fourcc.org/
  57564. */
  57565. isFourCC: boolean;
  57566. /**
  57567. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57568. */
  57569. isRGB: boolean;
  57570. /**
  57571. * If the texture is a lumincance format
  57572. */
  57573. isLuminance: boolean;
  57574. /**
  57575. * If this is a cube texture
  57576. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57577. */
  57578. isCube: boolean;
  57579. /**
  57580. * If the texture is a compressed format eg. FOURCC_DXT1
  57581. */
  57582. isCompressed: boolean;
  57583. /**
  57584. * The dxgiFormat of the texture
  57585. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57586. */
  57587. dxgiFormat: number;
  57588. /**
  57589. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57590. */
  57591. textureType: number;
  57592. /**
  57593. * Sphericle polynomial created for the dds texture
  57594. */
  57595. sphericalPolynomial?: SphericalPolynomial;
  57596. }
  57597. /**
  57598. * Class used to provide DDS decompression tools
  57599. */
  57600. export class DDSTools {
  57601. /**
  57602. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57603. */
  57604. static StoreLODInAlphaChannel: boolean;
  57605. /**
  57606. * Gets DDS information from an array buffer
  57607. * @param data defines the array buffer view to read data from
  57608. * @returns the DDS information
  57609. */
  57610. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57611. private static _FloatView;
  57612. private static _Int32View;
  57613. private static _ToHalfFloat;
  57614. private static _FromHalfFloat;
  57615. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57616. private static _GetHalfFloatRGBAArrayBuffer;
  57617. private static _GetFloatRGBAArrayBuffer;
  57618. private static _GetFloatAsUIntRGBAArrayBuffer;
  57619. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57620. private static _GetRGBAArrayBuffer;
  57621. private static _ExtractLongWordOrder;
  57622. private static _GetRGBArrayBuffer;
  57623. private static _GetLuminanceArrayBuffer;
  57624. /**
  57625. * Uploads DDS Levels to a Babylon Texture
  57626. * @hidden
  57627. */
  57628. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57629. }
  57630. interface ThinEngine {
  57631. /**
  57632. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57633. * @param rootUrl defines the url where the file to load is located
  57634. * @param scene defines the current scene
  57635. * @param lodScale defines scale to apply to the mip map selection
  57636. * @param lodOffset defines offset to apply to the mip map selection
  57637. * @param onLoad defines an optional callback raised when the texture is loaded
  57638. * @param onError defines an optional callback raised if there is an issue to load the texture
  57639. * @param format defines the format of the data
  57640. * @param forcedExtension defines the extension to use to pick the right loader
  57641. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57642. * @returns the cube texture as an InternalTexture
  57643. */
  57644. 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;
  57645. }
  57646. }
  57647. declare module BABYLON {
  57648. /**
  57649. * Implementation of the DDS Texture Loader.
  57650. * @hidden
  57651. */
  57652. export class _DDSTextureLoader implements IInternalTextureLoader {
  57653. /**
  57654. * Defines wether the loader supports cascade loading the different faces.
  57655. */
  57656. readonly supportCascades: boolean;
  57657. /**
  57658. * This returns if the loader support the current file information.
  57659. * @param extension defines the file extension of the file being loaded
  57660. * @returns true if the loader can load the specified file
  57661. */
  57662. canLoad(extension: string): boolean;
  57663. /**
  57664. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57665. * @param data contains the texture data
  57666. * @param texture defines the BabylonJS internal texture
  57667. * @param createPolynomials will be true if polynomials have been requested
  57668. * @param onLoad defines the callback to trigger once the texture is ready
  57669. * @param onError defines the callback to trigger in case of error
  57670. */
  57671. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57672. /**
  57673. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57674. * @param data contains the texture data
  57675. * @param texture defines the BabylonJS internal texture
  57676. * @param callback defines the method to call once ready to upload
  57677. */
  57678. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57679. }
  57680. }
  57681. declare module BABYLON {
  57682. /**
  57683. * Implementation of the ENV Texture Loader.
  57684. * @hidden
  57685. */
  57686. export class _ENVTextureLoader implements IInternalTextureLoader {
  57687. /**
  57688. * Defines wether the loader supports cascade loading the different faces.
  57689. */
  57690. readonly supportCascades: boolean;
  57691. /**
  57692. * This returns if the loader support the current file information.
  57693. * @param extension defines the file extension of the file being loaded
  57694. * @returns true if the loader can load the specified file
  57695. */
  57696. canLoad(extension: string): boolean;
  57697. /**
  57698. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57699. * @param data contains the texture data
  57700. * @param texture defines the BabylonJS internal texture
  57701. * @param createPolynomials will be true if polynomials have been requested
  57702. * @param onLoad defines the callback to trigger once the texture is ready
  57703. * @param onError defines the callback to trigger in case of error
  57704. */
  57705. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57706. /**
  57707. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57708. * @param data contains the texture data
  57709. * @param texture defines the BabylonJS internal texture
  57710. * @param callback defines the method to call once ready to upload
  57711. */
  57712. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57713. }
  57714. }
  57715. declare module BABYLON {
  57716. /**
  57717. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57718. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57719. */
  57720. export class KhronosTextureContainer {
  57721. /** contents of the KTX container file */
  57722. data: ArrayBufferView;
  57723. private static HEADER_LEN;
  57724. private static COMPRESSED_2D;
  57725. private static COMPRESSED_3D;
  57726. private static TEX_2D;
  57727. private static TEX_3D;
  57728. /**
  57729. * Gets the openGL type
  57730. */
  57731. glType: number;
  57732. /**
  57733. * Gets the openGL type size
  57734. */
  57735. glTypeSize: number;
  57736. /**
  57737. * Gets the openGL format
  57738. */
  57739. glFormat: number;
  57740. /**
  57741. * Gets the openGL internal format
  57742. */
  57743. glInternalFormat: number;
  57744. /**
  57745. * Gets the base internal format
  57746. */
  57747. glBaseInternalFormat: number;
  57748. /**
  57749. * Gets image width in pixel
  57750. */
  57751. pixelWidth: number;
  57752. /**
  57753. * Gets image height in pixel
  57754. */
  57755. pixelHeight: number;
  57756. /**
  57757. * Gets image depth in pixels
  57758. */
  57759. pixelDepth: number;
  57760. /**
  57761. * Gets the number of array elements
  57762. */
  57763. numberOfArrayElements: number;
  57764. /**
  57765. * Gets the number of faces
  57766. */
  57767. numberOfFaces: number;
  57768. /**
  57769. * Gets the number of mipmap levels
  57770. */
  57771. numberOfMipmapLevels: number;
  57772. /**
  57773. * Gets the bytes of key value data
  57774. */
  57775. bytesOfKeyValueData: number;
  57776. /**
  57777. * Gets the load type
  57778. */
  57779. loadType: number;
  57780. /**
  57781. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57782. */
  57783. isInvalid: boolean;
  57784. /**
  57785. * Creates a new KhronosTextureContainer
  57786. * @param data contents of the KTX container file
  57787. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57788. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57789. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57790. */
  57791. constructor(
  57792. /** contents of the KTX container file */
  57793. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57794. /**
  57795. * Uploads KTX content to a Babylon Texture.
  57796. * It is assumed that the texture has already been created & is currently bound
  57797. * @hidden
  57798. */
  57799. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57800. private _upload2DCompressedLevels;
  57801. /**
  57802. * Checks if the given data starts with a KTX file identifier.
  57803. * @param data the data to check
  57804. * @returns true if the data is a KTX file or false otherwise
  57805. */
  57806. static IsValid(data: ArrayBufferView): boolean;
  57807. }
  57808. }
  57809. declare module BABYLON {
  57810. /**
  57811. * Helper class to push actions to a pool of workers.
  57812. */
  57813. export class WorkerPool implements IDisposable {
  57814. private _workerInfos;
  57815. private _pendingActions;
  57816. /**
  57817. * Constructor
  57818. * @param workers Array of workers to use for actions
  57819. */
  57820. constructor(workers: Array<Worker>);
  57821. /**
  57822. * Terminates all workers and clears any pending actions.
  57823. */
  57824. dispose(): void;
  57825. /**
  57826. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57827. * pended until a worker has completed its action.
  57828. * @param action The action to perform. Call onComplete when the action is complete.
  57829. */
  57830. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57831. private _execute;
  57832. }
  57833. }
  57834. declare module BABYLON {
  57835. /**
  57836. * Class for loading KTX2 files
  57837. * @hidden
  57838. */
  57839. export class KhronosTextureContainer2 {
  57840. private static _WorkerPoolPromise?;
  57841. private static _Initialized;
  57842. private static _Ktx2Decoder;
  57843. /**
  57844. * URL to use when loading the KTX2 decoder module
  57845. */
  57846. static JSModuleURL: string;
  57847. /**
  57848. * Default number of workers used to handle data decoding
  57849. */
  57850. static DefaultNumWorkers: number;
  57851. private static GetDefaultNumWorkers;
  57852. private _engine;
  57853. private static _CreateWorkerPool;
  57854. /**
  57855. * Constructor
  57856. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57857. */
  57858. constructor(engine: ThinEngine, numWorkers?: number);
  57859. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57860. /**
  57861. * Stop all async operations and release resources.
  57862. */
  57863. dispose(): void;
  57864. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  57865. /**
  57866. * Checks if the given data starts with a KTX2 file identifier.
  57867. * @param data the data to check
  57868. * @returns true if the data is a KTX2 file or false otherwise
  57869. */
  57870. static IsValid(data: ArrayBufferView): boolean;
  57871. }
  57872. export function workerFunc(): void;
  57873. }
  57874. declare module BABYLON {
  57875. /**
  57876. * Implementation of the KTX Texture Loader.
  57877. * @hidden
  57878. */
  57879. export class _KTXTextureLoader implements IInternalTextureLoader {
  57880. /**
  57881. * Defines wether the loader supports cascade loading the different faces.
  57882. */
  57883. readonly supportCascades: boolean;
  57884. /**
  57885. * This returns if the loader support the current file information.
  57886. * @param extension defines the file extension of the file being loaded
  57887. * @param mimeType defines the optional mime type of the file being loaded
  57888. * @returns true if the loader can load the specified file
  57889. */
  57890. canLoad(extension: string, mimeType?: string): boolean;
  57891. /**
  57892. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57893. * @param data contains the texture data
  57894. * @param texture defines the BabylonJS internal texture
  57895. * @param createPolynomials will be true if polynomials have been requested
  57896. * @param onLoad defines the callback to trigger once the texture is ready
  57897. * @param onError defines the callback to trigger in case of error
  57898. */
  57899. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57900. /**
  57901. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57902. * @param data contains the texture data
  57903. * @param texture defines the BabylonJS internal texture
  57904. * @param callback defines the method to call once ready to upload
  57905. */
  57906. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57907. }
  57908. }
  57909. declare module BABYLON {
  57910. /** @hidden */
  57911. export var _forceSceneHelpersToBundle: boolean;
  57912. interface Scene {
  57913. /**
  57914. * Creates a default light for the scene.
  57915. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57916. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57917. */
  57918. createDefaultLight(replace?: boolean): void;
  57919. /**
  57920. * Creates a default camera for the scene.
  57921. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57922. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57923. * @param replace has default false, when true replaces the active camera in the scene
  57924. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57925. */
  57926. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57927. /**
  57928. * Creates a default camera and a default light.
  57929. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57930. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57931. * @param replace has the default false, when true replaces the active camera/light in the scene
  57932. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57933. */
  57934. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57935. /**
  57936. * Creates a new sky box
  57937. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57938. * @param environmentTexture defines the texture to use as environment texture
  57939. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57940. * @param scale defines the overall scale of the skybox
  57941. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57942. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57943. * @returns a new mesh holding the sky box
  57944. */
  57945. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57946. /**
  57947. * Creates a new environment
  57948. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57949. * @param options defines the options you can use to configure the environment
  57950. * @returns the new EnvironmentHelper
  57951. */
  57952. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57953. /**
  57954. * Creates a new VREXperienceHelper
  57955. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57956. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57957. * @returns a new VREXperienceHelper
  57958. */
  57959. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57960. /**
  57961. * Creates a new WebXRDefaultExperience
  57962. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57963. * @param options experience options
  57964. * @returns a promise for a new WebXRDefaultExperience
  57965. */
  57966. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57967. }
  57968. }
  57969. declare module BABYLON {
  57970. /**
  57971. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57972. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57973. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57974. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57975. */
  57976. export class VideoDome extends TextureDome<VideoTexture> {
  57977. /**
  57978. * Define the video source as a Monoscopic panoramic 360 video.
  57979. */
  57980. static readonly MODE_MONOSCOPIC: number;
  57981. /**
  57982. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57983. */
  57984. static readonly MODE_TOPBOTTOM: number;
  57985. /**
  57986. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57987. */
  57988. static readonly MODE_SIDEBYSIDE: number;
  57989. /**
  57990. * Get the video texture associated with this video dome
  57991. */
  57992. get videoTexture(): VideoTexture;
  57993. /**
  57994. * Get the video mode of this dome
  57995. */
  57996. get videoMode(): number;
  57997. /**
  57998. * Set the video mode of this dome.
  57999. * @see textureMode
  58000. */
  58001. set videoMode(value: number);
  58002. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58003. }
  58004. }
  58005. declare module BABYLON {
  58006. /**
  58007. * This class can be used to get instrumentation data from a Babylon engine
  58008. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58009. */
  58010. export class EngineInstrumentation implements IDisposable {
  58011. /**
  58012. * Define the instrumented engine.
  58013. */
  58014. engine: Engine;
  58015. private _captureGPUFrameTime;
  58016. private _gpuFrameTimeToken;
  58017. private _gpuFrameTime;
  58018. private _captureShaderCompilationTime;
  58019. private _shaderCompilationTime;
  58020. private _onBeginFrameObserver;
  58021. private _onEndFrameObserver;
  58022. private _onBeforeShaderCompilationObserver;
  58023. private _onAfterShaderCompilationObserver;
  58024. /**
  58025. * Gets the perf counter used for GPU frame time
  58026. */
  58027. get gpuFrameTimeCounter(): PerfCounter;
  58028. /**
  58029. * Gets the GPU frame time capture status
  58030. */
  58031. get captureGPUFrameTime(): boolean;
  58032. /**
  58033. * Enable or disable the GPU frame time capture
  58034. */
  58035. set captureGPUFrameTime(value: boolean);
  58036. /**
  58037. * Gets the perf counter used for shader compilation time
  58038. */
  58039. get shaderCompilationTimeCounter(): PerfCounter;
  58040. /**
  58041. * Gets the shader compilation time capture status
  58042. */
  58043. get captureShaderCompilationTime(): boolean;
  58044. /**
  58045. * Enable or disable the shader compilation time capture
  58046. */
  58047. set captureShaderCompilationTime(value: boolean);
  58048. /**
  58049. * Instantiates a new engine instrumentation.
  58050. * This class can be used to get instrumentation data from a Babylon engine
  58051. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58052. * @param engine Defines the engine to instrument
  58053. */
  58054. constructor(
  58055. /**
  58056. * Define the instrumented engine.
  58057. */
  58058. engine: Engine);
  58059. /**
  58060. * Dispose and release associated resources.
  58061. */
  58062. dispose(): void;
  58063. }
  58064. }
  58065. declare module BABYLON {
  58066. /**
  58067. * This class can be used to get instrumentation data from a Babylon engine
  58068. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58069. */
  58070. export class SceneInstrumentation implements IDisposable {
  58071. /**
  58072. * Defines the scene to instrument
  58073. */
  58074. scene: Scene;
  58075. private _captureActiveMeshesEvaluationTime;
  58076. private _activeMeshesEvaluationTime;
  58077. private _captureRenderTargetsRenderTime;
  58078. private _renderTargetsRenderTime;
  58079. private _captureFrameTime;
  58080. private _frameTime;
  58081. private _captureRenderTime;
  58082. private _renderTime;
  58083. private _captureInterFrameTime;
  58084. private _interFrameTime;
  58085. private _captureParticlesRenderTime;
  58086. private _particlesRenderTime;
  58087. private _captureSpritesRenderTime;
  58088. private _spritesRenderTime;
  58089. private _capturePhysicsTime;
  58090. private _physicsTime;
  58091. private _captureAnimationsTime;
  58092. private _animationsTime;
  58093. private _captureCameraRenderTime;
  58094. private _cameraRenderTime;
  58095. private _onBeforeActiveMeshesEvaluationObserver;
  58096. private _onAfterActiveMeshesEvaluationObserver;
  58097. private _onBeforeRenderTargetsRenderObserver;
  58098. private _onAfterRenderTargetsRenderObserver;
  58099. private _onAfterRenderObserver;
  58100. private _onBeforeDrawPhaseObserver;
  58101. private _onAfterDrawPhaseObserver;
  58102. private _onBeforeAnimationsObserver;
  58103. private _onBeforeParticlesRenderingObserver;
  58104. private _onAfterParticlesRenderingObserver;
  58105. private _onBeforeSpritesRenderingObserver;
  58106. private _onAfterSpritesRenderingObserver;
  58107. private _onBeforePhysicsObserver;
  58108. private _onAfterPhysicsObserver;
  58109. private _onAfterAnimationsObserver;
  58110. private _onBeforeCameraRenderObserver;
  58111. private _onAfterCameraRenderObserver;
  58112. /**
  58113. * Gets the perf counter used for active meshes evaluation time
  58114. */
  58115. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58116. /**
  58117. * Gets the active meshes evaluation time capture status
  58118. */
  58119. get captureActiveMeshesEvaluationTime(): boolean;
  58120. /**
  58121. * Enable or disable the active meshes evaluation time capture
  58122. */
  58123. set captureActiveMeshesEvaluationTime(value: boolean);
  58124. /**
  58125. * Gets the perf counter used for render targets render time
  58126. */
  58127. get renderTargetsRenderTimeCounter(): PerfCounter;
  58128. /**
  58129. * Gets the render targets render time capture status
  58130. */
  58131. get captureRenderTargetsRenderTime(): boolean;
  58132. /**
  58133. * Enable or disable the render targets render time capture
  58134. */
  58135. set captureRenderTargetsRenderTime(value: boolean);
  58136. /**
  58137. * Gets the perf counter used for particles render time
  58138. */
  58139. get particlesRenderTimeCounter(): PerfCounter;
  58140. /**
  58141. * Gets the particles render time capture status
  58142. */
  58143. get captureParticlesRenderTime(): boolean;
  58144. /**
  58145. * Enable or disable the particles render time capture
  58146. */
  58147. set captureParticlesRenderTime(value: boolean);
  58148. /**
  58149. * Gets the perf counter used for sprites render time
  58150. */
  58151. get spritesRenderTimeCounter(): PerfCounter;
  58152. /**
  58153. * Gets the sprites render time capture status
  58154. */
  58155. get captureSpritesRenderTime(): boolean;
  58156. /**
  58157. * Enable or disable the sprites render time capture
  58158. */
  58159. set captureSpritesRenderTime(value: boolean);
  58160. /**
  58161. * Gets the perf counter used for physics time
  58162. */
  58163. get physicsTimeCounter(): PerfCounter;
  58164. /**
  58165. * Gets the physics time capture status
  58166. */
  58167. get capturePhysicsTime(): boolean;
  58168. /**
  58169. * Enable or disable the physics time capture
  58170. */
  58171. set capturePhysicsTime(value: boolean);
  58172. /**
  58173. * Gets the perf counter used for animations time
  58174. */
  58175. get animationsTimeCounter(): PerfCounter;
  58176. /**
  58177. * Gets the animations time capture status
  58178. */
  58179. get captureAnimationsTime(): boolean;
  58180. /**
  58181. * Enable or disable the animations time capture
  58182. */
  58183. set captureAnimationsTime(value: boolean);
  58184. /**
  58185. * Gets the perf counter used for frame time capture
  58186. */
  58187. get frameTimeCounter(): PerfCounter;
  58188. /**
  58189. * Gets the frame time capture status
  58190. */
  58191. get captureFrameTime(): boolean;
  58192. /**
  58193. * Enable or disable the frame time capture
  58194. */
  58195. set captureFrameTime(value: boolean);
  58196. /**
  58197. * Gets the perf counter used for inter-frames time capture
  58198. */
  58199. get interFrameTimeCounter(): PerfCounter;
  58200. /**
  58201. * Gets the inter-frames time capture status
  58202. */
  58203. get captureInterFrameTime(): boolean;
  58204. /**
  58205. * Enable or disable the inter-frames time capture
  58206. */
  58207. set captureInterFrameTime(value: boolean);
  58208. /**
  58209. * Gets the perf counter used for render time capture
  58210. */
  58211. get renderTimeCounter(): PerfCounter;
  58212. /**
  58213. * Gets the render time capture status
  58214. */
  58215. get captureRenderTime(): boolean;
  58216. /**
  58217. * Enable or disable the render time capture
  58218. */
  58219. set captureRenderTime(value: boolean);
  58220. /**
  58221. * Gets the perf counter used for camera render time capture
  58222. */
  58223. get cameraRenderTimeCounter(): PerfCounter;
  58224. /**
  58225. * Gets the camera render time capture status
  58226. */
  58227. get captureCameraRenderTime(): boolean;
  58228. /**
  58229. * Enable or disable the camera render time capture
  58230. */
  58231. set captureCameraRenderTime(value: boolean);
  58232. /**
  58233. * Gets the perf counter used for draw calls
  58234. */
  58235. get drawCallsCounter(): PerfCounter;
  58236. /**
  58237. * Instantiates a new scene instrumentation.
  58238. * This class can be used to get instrumentation data from a Babylon engine
  58239. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58240. * @param scene Defines the scene to instrument
  58241. */
  58242. constructor(
  58243. /**
  58244. * Defines the scene to instrument
  58245. */
  58246. scene: Scene);
  58247. /**
  58248. * Dispose and release associated resources.
  58249. */
  58250. dispose(): void;
  58251. }
  58252. }
  58253. declare module BABYLON {
  58254. /** @hidden */
  58255. export var glowMapGenerationPixelShader: {
  58256. name: string;
  58257. shader: string;
  58258. };
  58259. }
  58260. declare module BABYLON {
  58261. /** @hidden */
  58262. export var glowMapGenerationVertexShader: {
  58263. name: string;
  58264. shader: string;
  58265. };
  58266. }
  58267. declare module BABYLON {
  58268. /**
  58269. * Effect layer options. This helps customizing the behaviour
  58270. * of the effect layer.
  58271. */
  58272. export interface IEffectLayerOptions {
  58273. /**
  58274. * Multiplication factor apply to the canvas size to compute the render target size
  58275. * used to generated the objects (the smaller the faster).
  58276. */
  58277. mainTextureRatio: number;
  58278. /**
  58279. * Enforces a fixed size texture to ensure effect stability across devices.
  58280. */
  58281. mainTextureFixedSize?: number;
  58282. /**
  58283. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58284. */
  58285. alphaBlendingMode: number;
  58286. /**
  58287. * The camera attached to the layer.
  58288. */
  58289. camera: Nullable<Camera>;
  58290. /**
  58291. * The rendering group to draw the layer in.
  58292. */
  58293. renderingGroupId: number;
  58294. }
  58295. /**
  58296. * The effect layer Helps adding post process effect blended with the main pass.
  58297. *
  58298. * This can be for instance use to generate glow or higlight effects on the scene.
  58299. *
  58300. * The effect layer class can not be used directly and is intented to inherited from to be
  58301. * customized per effects.
  58302. */
  58303. export abstract class EffectLayer {
  58304. private _vertexBuffers;
  58305. private _indexBuffer;
  58306. private _cachedDefines;
  58307. private _effectLayerMapGenerationEffect;
  58308. private _effectLayerOptions;
  58309. private _mergeEffect;
  58310. protected _scene: Scene;
  58311. protected _engine: Engine;
  58312. protected _maxSize: number;
  58313. protected _mainTextureDesiredSize: ISize;
  58314. protected _mainTexture: RenderTargetTexture;
  58315. protected _shouldRender: boolean;
  58316. protected _postProcesses: PostProcess[];
  58317. protected _textures: BaseTexture[];
  58318. protected _emissiveTextureAndColor: {
  58319. texture: Nullable<BaseTexture>;
  58320. color: Color4;
  58321. };
  58322. /**
  58323. * The name of the layer
  58324. */
  58325. name: string;
  58326. /**
  58327. * The clear color of the texture used to generate the glow map.
  58328. */
  58329. neutralColor: Color4;
  58330. /**
  58331. * Specifies whether the highlight layer is enabled or not.
  58332. */
  58333. isEnabled: boolean;
  58334. /**
  58335. * Gets the camera attached to the layer.
  58336. */
  58337. get camera(): Nullable<Camera>;
  58338. /**
  58339. * Gets the rendering group id the layer should render in.
  58340. */
  58341. get renderingGroupId(): number;
  58342. set renderingGroupId(renderingGroupId: number);
  58343. /**
  58344. * An event triggered when the effect layer has been disposed.
  58345. */
  58346. onDisposeObservable: Observable<EffectLayer>;
  58347. /**
  58348. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58349. */
  58350. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58351. /**
  58352. * An event triggered when the generated texture is being merged in the scene.
  58353. */
  58354. onBeforeComposeObservable: Observable<EffectLayer>;
  58355. /**
  58356. * An event triggered when the mesh is rendered into the effect render target.
  58357. */
  58358. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58359. /**
  58360. * An event triggered after the mesh has been rendered into the effect render target.
  58361. */
  58362. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58363. /**
  58364. * An event triggered when the generated texture has been merged in the scene.
  58365. */
  58366. onAfterComposeObservable: Observable<EffectLayer>;
  58367. /**
  58368. * An event triggered when the efffect layer changes its size.
  58369. */
  58370. onSizeChangedObservable: Observable<EffectLayer>;
  58371. /** @hidden */
  58372. static _SceneComponentInitialization: (scene: Scene) => void;
  58373. /**
  58374. * Instantiates a new effect Layer and references it in the scene.
  58375. * @param name The name of the layer
  58376. * @param scene The scene to use the layer in
  58377. */
  58378. constructor(
  58379. /** The Friendly of the effect in the scene */
  58380. name: string, scene: Scene);
  58381. /**
  58382. * Get the effect name of the layer.
  58383. * @return The effect name
  58384. */
  58385. abstract getEffectName(): string;
  58386. /**
  58387. * Checks for the readiness of the element composing the layer.
  58388. * @param subMesh the mesh to check for
  58389. * @param useInstances specify whether or not to use instances to render the mesh
  58390. * @return true if ready otherwise, false
  58391. */
  58392. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58393. /**
  58394. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58395. * @returns true if the effect requires stencil during the main canvas render pass.
  58396. */
  58397. abstract needStencil(): boolean;
  58398. /**
  58399. * Create the merge effect. This is the shader use to blit the information back
  58400. * to the main canvas at the end of the scene rendering.
  58401. * @returns The effect containing the shader used to merge the effect on the main canvas
  58402. */
  58403. protected abstract _createMergeEffect(): Effect;
  58404. /**
  58405. * Creates the render target textures and post processes used in the effect layer.
  58406. */
  58407. protected abstract _createTextureAndPostProcesses(): void;
  58408. /**
  58409. * Implementation specific of rendering the generating effect on the main canvas.
  58410. * @param effect The effect used to render through
  58411. */
  58412. protected abstract _internalRender(effect: Effect): void;
  58413. /**
  58414. * Sets the required values for both the emissive texture and and the main color.
  58415. */
  58416. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58417. /**
  58418. * Free any resources and references associated to a mesh.
  58419. * Internal use
  58420. * @param mesh The mesh to free.
  58421. */
  58422. abstract _disposeMesh(mesh: Mesh): void;
  58423. /**
  58424. * Serializes this layer (Glow or Highlight for example)
  58425. * @returns a serialized layer object
  58426. */
  58427. abstract serialize?(): any;
  58428. /**
  58429. * Initializes the effect layer with the required options.
  58430. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58431. */
  58432. protected _init(options: Partial<IEffectLayerOptions>): void;
  58433. /**
  58434. * Generates the index buffer of the full screen quad blending to the main canvas.
  58435. */
  58436. private _generateIndexBuffer;
  58437. /**
  58438. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58439. */
  58440. private _generateVertexBuffer;
  58441. /**
  58442. * Sets the main texture desired size which is the closest power of two
  58443. * of the engine canvas size.
  58444. */
  58445. private _setMainTextureSize;
  58446. /**
  58447. * Creates the main texture for the effect layer.
  58448. */
  58449. protected _createMainTexture(): void;
  58450. /**
  58451. * Adds specific effects defines.
  58452. * @param defines The defines to add specifics to.
  58453. */
  58454. protected _addCustomEffectDefines(defines: string[]): void;
  58455. /**
  58456. * Checks for the readiness of the element composing the layer.
  58457. * @param subMesh the mesh to check for
  58458. * @param useInstances specify whether or not to use instances to render the mesh
  58459. * @param emissiveTexture the associated emissive texture used to generate the glow
  58460. * @return true if ready otherwise, false
  58461. */
  58462. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58463. /**
  58464. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58465. */
  58466. render(): void;
  58467. /**
  58468. * Determine if a given mesh will be used in the current effect.
  58469. * @param mesh mesh to test
  58470. * @returns true if the mesh will be used
  58471. */
  58472. hasMesh(mesh: AbstractMesh): boolean;
  58473. /**
  58474. * Returns true if the layer contains information to display, otherwise false.
  58475. * @returns true if the glow layer should be rendered
  58476. */
  58477. shouldRender(): boolean;
  58478. /**
  58479. * Returns true if the mesh should render, otherwise false.
  58480. * @param mesh The mesh to render
  58481. * @returns true if it should render otherwise false
  58482. */
  58483. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58484. /**
  58485. * Returns true if the mesh can be rendered, otherwise false.
  58486. * @param mesh The mesh to render
  58487. * @param material The material used on the mesh
  58488. * @returns true if it can be rendered otherwise false
  58489. */
  58490. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58491. /**
  58492. * Returns true if the mesh should render, otherwise false.
  58493. * @param mesh The mesh to render
  58494. * @returns true if it should render otherwise false
  58495. */
  58496. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58497. /**
  58498. * Renders the submesh passed in parameter to the generation map.
  58499. */
  58500. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58501. /**
  58502. * Defines whether the current material of the mesh should be use to render the effect.
  58503. * @param mesh defines the current mesh to render
  58504. */
  58505. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58506. /**
  58507. * Rebuild the required buffers.
  58508. * @hidden Internal use only.
  58509. */
  58510. _rebuild(): void;
  58511. /**
  58512. * Dispose only the render target textures and post process.
  58513. */
  58514. private _disposeTextureAndPostProcesses;
  58515. /**
  58516. * Dispose the highlight layer and free resources.
  58517. */
  58518. dispose(): void;
  58519. /**
  58520. * Gets the class name of the effect layer
  58521. * @returns the string with the class name of the effect layer
  58522. */
  58523. getClassName(): string;
  58524. /**
  58525. * Creates an effect layer from parsed effect layer data
  58526. * @param parsedEffectLayer defines effect layer data
  58527. * @param scene defines the current scene
  58528. * @param rootUrl defines the root URL containing the effect layer information
  58529. * @returns a parsed effect Layer
  58530. */
  58531. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58532. }
  58533. }
  58534. declare module BABYLON {
  58535. interface AbstractScene {
  58536. /**
  58537. * The list of effect layers (highlights/glow) added to the scene
  58538. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58539. * @see https://doc.babylonjs.com/how_to/glow_layer
  58540. */
  58541. effectLayers: Array<EffectLayer>;
  58542. /**
  58543. * Removes the given effect layer from this scene.
  58544. * @param toRemove defines the effect layer to remove
  58545. * @returns the index of the removed effect layer
  58546. */
  58547. removeEffectLayer(toRemove: EffectLayer): number;
  58548. /**
  58549. * Adds the given effect layer to this scene
  58550. * @param newEffectLayer defines the effect layer to add
  58551. */
  58552. addEffectLayer(newEffectLayer: EffectLayer): void;
  58553. }
  58554. /**
  58555. * Defines the layer scene component responsible to manage any effect layers
  58556. * in a given scene.
  58557. */
  58558. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58559. /**
  58560. * The component name helpfull to identify the component in the list of scene components.
  58561. */
  58562. readonly name: string;
  58563. /**
  58564. * The scene the component belongs to.
  58565. */
  58566. scene: Scene;
  58567. private _engine;
  58568. private _renderEffects;
  58569. private _needStencil;
  58570. private _previousStencilState;
  58571. /**
  58572. * Creates a new instance of the component for the given scene
  58573. * @param scene Defines the scene to register the component in
  58574. */
  58575. constructor(scene: Scene);
  58576. /**
  58577. * Registers the component in a given scene
  58578. */
  58579. register(): void;
  58580. /**
  58581. * Rebuilds the elements related to this component in case of
  58582. * context lost for instance.
  58583. */
  58584. rebuild(): void;
  58585. /**
  58586. * Serializes the component data to the specified json object
  58587. * @param serializationObject The object to serialize to
  58588. */
  58589. serialize(serializationObject: any): void;
  58590. /**
  58591. * Adds all the elements from the container to the scene
  58592. * @param container the container holding the elements
  58593. */
  58594. addFromContainer(container: AbstractScene): void;
  58595. /**
  58596. * Removes all the elements in the container from the scene
  58597. * @param container contains the elements to remove
  58598. * @param dispose if the removed element should be disposed (default: false)
  58599. */
  58600. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58601. /**
  58602. * Disposes the component and the associated ressources.
  58603. */
  58604. dispose(): void;
  58605. private _isReadyForMesh;
  58606. private _renderMainTexture;
  58607. private _setStencil;
  58608. private _setStencilBack;
  58609. private _draw;
  58610. private _drawCamera;
  58611. private _drawRenderingGroup;
  58612. }
  58613. }
  58614. declare module BABYLON {
  58615. /** @hidden */
  58616. export var glowMapMergePixelShader: {
  58617. name: string;
  58618. shader: string;
  58619. };
  58620. }
  58621. declare module BABYLON {
  58622. /** @hidden */
  58623. export var glowMapMergeVertexShader: {
  58624. name: string;
  58625. shader: string;
  58626. };
  58627. }
  58628. declare module BABYLON {
  58629. interface AbstractScene {
  58630. /**
  58631. * Return a the first highlight layer of the scene with a given name.
  58632. * @param name The name of the highlight layer to look for.
  58633. * @return The highlight layer if found otherwise null.
  58634. */
  58635. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58636. }
  58637. /**
  58638. * Glow layer options. This helps customizing the behaviour
  58639. * of the glow layer.
  58640. */
  58641. export interface IGlowLayerOptions {
  58642. /**
  58643. * Multiplication factor apply to the canvas size to compute the render target size
  58644. * used to generated the glowing objects (the smaller the faster).
  58645. */
  58646. mainTextureRatio: number;
  58647. /**
  58648. * Enforces a fixed size texture to ensure resize independant blur.
  58649. */
  58650. mainTextureFixedSize?: number;
  58651. /**
  58652. * How big is the kernel of the blur texture.
  58653. */
  58654. blurKernelSize: number;
  58655. /**
  58656. * The camera attached to the layer.
  58657. */
  58658. camera: Nullable<Camera>;
  58659. /**
  58660. * Enable MSAA by chosing the number of samples.
  58661. */
  58662. mainTextureSamples?: number;
  58663. /**
  58664. * The rendering group to draw the layer in.
  58665. */
  58666. renderingGroupId: number;
  58667. }
  58668. /**
  58669. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58670. *
  58671. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58672. *
  58673. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58674. */
  58675. export class GlowLayer extends EffectLayer {
  58676. /**
  58677. * Effect Name of the layer.
  58678. */
  58679. static readonly EffectName: string;
  58680. /**
  58681. * The default blur kernel size used for the glow.
  58682. */
  58683. static DefaultBlurKernelSize: number;
  58684. /**
  58685. * The default texture size ratio used for the glow.
  58686. */
  58687. static DefaultTextureRatio: number;
  58688. /**
  58689. * Sets the kernel size of the blur.
  58690. */
  58691. set blurKernelSize(value: number);
  58692. /**
  58693. * Gets the kernel size of the blur.
  58694. */
  58695. get blurKernelSize(): number;
  58696. /**
  58697. * Sets the glow intensity.
  58698. */
  58699. set intensity(value: number);
  58700. /**
  58701. * Gets the glow intensity.
  58702. */
  58703. get intensity(): number;
  58704. private _options;
  58705. private _intensity;
  58706. private _horizontalBlurPostprocess1;
  58707. private _verticalBlurPostprocess1;
  58708. private _horizontalBlurPostprocess2;
  58709. private _verticalBlurPostprocess2;
  58710. private _blurTexture1;
  58711. private _blurTexture2;
  58712. private _postProcesses1;
  58713. private _postProcesses2;
  58714. private _includedOnlyMeshes;
  58715. private _excludedMeshes;
  58716. private _meshesUsingTheirOwnMaterials;
  58717. /**
  58718. * Callback used to let the user override the color selection on a per mesh basis
  58719. */
  58720. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58721. /**
  58722. * Callback used to let the user override the texture selection on a per mesh basis
  58723. */
  58724. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58725. /**
  58726. * Instantiates a new glow Layer and references it to the scene.
  58727. * @param name The name of the layer
  58728. * @param scene The scene to use the layer in
  58729. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58730. */
  58731. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58732. /**
  58733. * Get the effect name of the layer.
  58734. * @return The effect name
  58735. */
  58736. getEffectName(): string;
  58737. /**
  58738. * Create the merge effect. This is the shader use to blit the information back
  58739. * to the main canvas at the end of the scene rendering.
  58740. */
  58741. protected _createMergeEffect(): Effect;
  58742. /**
  58743. * Creates the render target textures and post processes used in the glow layer.
  58744. */
  58745. protected _createTextureAndPostProcesses(): void;
  58746. /**
  58747. * Checks for the readiness of the element composing the layer.
  58748. * @param subMesh the mesh to check for
  58749. * @param useInstances specify wether or not to use instances to render the mesh
  58750. * @param emissiveTexture the associated emissive texture used to generate the glow
  58751. * @return true if ready otherwise, false
  58752. */
  58753. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58754. /**
  58755. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58756. */
  58757. needStencil(): boolean;
  58758. /**
  58759. * Returns true if the mesh can be rendered, otherwise false.
  58760. * @param mesh The mesh to render
  58761. * @param material The material used on the mesh
  58762. * @returns true if it can be rendered otherwise false
  58763. */
  58764. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58765. /**
  58766. * Implementation specific of rendering the generating effect on the main canvas.
  58767. * @param effect The effect used to render through
  58768. */
  58769. protected _internalRender(effect: Effect): void;
  58770. /**
  58771. * Sets the required values for both the emissive texture and and the main color.
  58772. */
  58773. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58774. /**
  58775. * Returns true if the mesh should render, otherwise false.
  58776. * @param mesh The mesh to render
  58777. * @returns true if it should render otherwise false
  58778. */
  58779. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58780. /**
  58781. * Adds specific effects defines.
  58782. * @param defines The defines to add specifics to.
  58783. */
  58784. protected _addCustomEffectDefines(defines: string[]): void;
  58785. /**
  58786. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58787. * @param mesh The mesh to exclude from the glow layer
  58788. */
  58789. addExcludedMesh(mesh: Mesh): void;
  58790. /**
  58791. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58792. * @param mesh The mesh to remove
  58793. */
  58794. removeExcludedMesh(mesh: Mesh): void;
  58795. /**
  58796. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58797. * @param mesh The mesh to include in the glow layer
  58798. */
  58799. addIncludedOnlyMesh(mesh: Mesh): void;
  58800. /**
  58801. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58802. * @param mesh The mesh to remove
  58803. */
  58804. removeIncludedOnlyMesh(mesh: Mesh): void;
  58805. /**
  58806. * Determine if a given mesh will be used in the glow layer
  58807. * @param mesh The mesh to test
  58808. * @returns true if the mesh will be highlighted by the current glow layer
  58809. */
  58810. hasMesh(mesh: AbstractMesh): boolean;
  58811. /**
  58812. * Defines whether the current material of the mesh should be use to render the effect.
  58813. * @param mesh defines the current mesh to render
  58814. */
  58815. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58816. /**
  58817. * Add a mesh to be rendered through its own material and not with emissive only.
  58818. * @param mesh The mesh for which we need to use its material
  58819. */
  58820. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58821. /**
  58822. * Remove a mesh from being rendered through its own material and not with emissive only.
  58823. * @param mesh The mesh for which we need to not use its material
  58824. */
  58825. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58826. /**
  58827. * Free any resources and references associated to a mesh.
  58828. * Internal use
  58829. * @param mesh The mesh to free.
  58830. * @hidden
  58831. */
  58832. _disposeMesh(mesh: Mesh): void;
  58833. /**
  58834. * Gets the class name of the effect layer
  58835. * @returns the string with the class name of the effect layer
  58836. */
  58837. getClassName(): string;
  58838. /**
  58839. * Serializes this glow layer
  58840. * @returns a serialized glow layer object
  58841. */
  58842. serialize(): any;
  58843. /**
  58844. * Creates a Glow Layer from parsed glow layer data
  58845. * @param parsedGlowLayer defines glow layer data
  58846. * @param scene defines the current scene
  58847. * @param rootUrl defines the root URL containing the glow layer information
  58848. * @returns a parsed Glow Layer
  58849. */
  58850. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58851. }
  58852. }
  58853. declare module BABYLON {
  58854. /** @hidden */
  58855. export var glowBlurPostProcessPixelShader: {
  58856. name: string;
  58857. shader: string;
  58858. };
  58859. }
  58860. declare module BABYLON {
  58861. interface AbstractScene {
  58862. /**
  58863. * Return a the first highlight layer of the scene with a given name.
  58864. * @param name The name of the highlight layer to look for.
  58865. * @return The highlight layer if found otherwise null.
  58866. */
  58867. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58868. }
  58869. /**
  58870. * Highlight layer options. This helps customizing the behaviour
  58871. * of the highlight layer.
  58872. */
  58873. export interface IHighlightLayerOptions {
  58874. /**
  58875. * Multiplication factor apply to the canvas size to compute the render target size
  58876. * used to generated the glowing objects (the smaller the faster).
  58877. */
  58878. mainTextureRatio: number;
  58879. /**
  58880. * Enforces a fixed size texture to ensure resize independant blur.
  58881. */
  58882. mainTextureFixedSize?: number;
  58883. /**
  58884. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58885. * of the picture to blur (the smaller the faster).
  58886. */
  58887. blurTextureSizeRatio: number;
  58888. /**
  58889. * How big in texel of the blur texture is the vertical blur.
  58890. */
  58891. blurVerticalSize: number;
  58892. /**
  58893. * How big in texel of the blur texture is the horizontal blur.
  58894. */
  58895. blurHorizontalSize: number;
  58896. /**
  58897. * Alpha blending mode used to apply the blur. Default is combine.
  58898. */
  58899. alphaBlendingMode: number;
  58900. /**
  58901. * The camera attached to the layer.
  58902. */
  58903. camera: Nullable<Camera>;
  58904. /**
  58905. * Should we display highlight as a solid stroke?
  58906. */
  58907. isStroke?: boolean;
  58908. /**
  58909. * The rendering group to draw the layer in.
  58910. */
  58911. renderingGroupId: number;
  58912. }
  58913. /**
  58914. * The highlight layer Helps adding a glow effect around a mesh.
  58915. *
  58916. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58917. * glowy meshes to your scene.
  58918. *
  58919. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58920. */
  58921. export class HighlightLayer extends EffectLayer {
  58922. name: string;
  58923. /**
  58924. * Effect Name of the highlight layer.
  58925. */
  58926. static readonly EffectName: string;
  58927. /**
  58928. * The neutral color used during the preparation of the glow effect.
  58929. * This is black by default as the blend operation is a blend operation.
  58930. */
  58931. static NeutralColor: Color4;
  58932. /**
  58933. * Stencil value used for glowing meshes.
  58934. */
  58935. static GlowingMeshStencilReference: number;
  58936. /**
  58937. * Stencil value used for the other meshes in the scene.
  58938. */
  58939. static NormalMeshStencilReference: number;
  58940. /**
  58941. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58942. */
  58943. innerGlow: boolean;
  58944. /**
  58945. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58946. */
  58947. outerGlow: boolean;
  58948. /**
  58949. * Specifies the horizontal size of the blur.
  58950. */
  58951. set blurHorizontalSize(value: number);
  58952. /**
  58953. * Specifies the vertical size of the blur.
  58954. */
  58955. set blurVerticalSize(value: number);
  58956. /**
  58957. * Gets the horizontal size of the blur.
  58958. */
  58959. get blurHorizontalSize(): number;
  58960. /**
  58961. * Gets the vertical size of the blur.
  58962. */
  58963. get blurVerticalSize(): number;
  58964. /**
  58965. * An event triggered when the highlight layer is being blurred.
  58966. */
  58967. onBeforeBlurObservable: Observable<HighlightLayer>;
  58968. /**
  58969. * An event triggered when the highlight layer has been blurred.
  58970. */
  58971. onAfterBlurObservable: Observable<HighlightLayer>;
  58972. private _instanceGlowingMeshStencilReference;
  58973. private _options;
  58974. private _downSamplePostprocess;
  58975. private _horizontalBlurPostprocess;
  58976. private _verticalBlurPostprocess;
  58977. private _blurTexture;
  58978. private _meshes;
  58979. private _excludedMeshes;
  58980. /**
  58981. * Instantiates a new highlight Layer and references it to the scene..
  58982. * @param name The name of the layer
  58983. * @param scene The scene to use the layer in
  58984. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58985. */
  58986. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58987. /**
  58988. * Get the effect name of the layer.
  58989. * @return The effect name
  58990. */
  58991. getEffectName(): string;
  58992. /**
  58993. * Create the merge effect. This is the shader use to blit the information back
  58994. * to the main canvas at the end of the scene rendering.
  58995. */
  58996. protected _createMergeEffect(): Effect;
  58997. /**
  58998. * Creates the render target textures and post processes used in the highlight layer.
  58999. */
  59000. protected _createTextureAndPostProcesses(): void;
  59001. /**
  59002. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59003. */
  59004. needStencil(): boolean;
  59005. /**
  59006. * Checks for the readiness of the element composing the layer.
  59007. * @param subMesh the mesh to check for
  59008. * @param useInstances specify wether or not to use instances to render the mesh
  59009. * @param emissiveTexture the associated emissive texture used to generate the glow
  59010. * @return true if ready otherwise, false
  59011. */
  59012. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59013. /**
  59014. * Implementation specific of rendering the generating effect on the main canvas.
  59015. * @param effect The effect used to render through
  59016. */
  59017. protected _internalRender(effect: Effect): void;
  59018. /**
  59019. * Returns true if the layer contains information to display, otherwise false.
  59020. */
  59021. shouldRender(): boolean;
  59022. /**
  59023. * Returns true if the mesh should render, otherwise false.
  59024. * @param mesh The mesh to render
  59025. * @returns true if it should render otherwise false
  59026. */
  59027. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59028. /**
  59029. * Returns true if the mesh can be rendered, otherwise false.
  59030. * @param mesh The mesh to render
  59031. * @param material The material used on the mesh
  59032. * @returns true if it can be rendered otherwise false
  59033. */
  59034. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59035. /**
  59036. * Adds specific effects defines.
  59037. * @param defines The defines to add specifics to.
  59038. */
  59039. protected _addCustomEffectDefines(defines: string[]): void;
  59040. /**
  59041. * Sets the required values for both the emissive texture and and the main color.
  59042. */
  59043. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59044. /**
  59045. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59046. * @param mesh The mesh to exclude from the highlight layer
  59047. */
  59048. addExcludedMesh(mesh: Mesh): void;
  59049. /**
  59050. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59051. * @param mesh The mesh to highlight
  59052. */
  59053. removeExcludedMesh(mesh: Mesh): void;
  59054. /**
  59055. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59056. * @param mesh mesh to test
  59057. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59058. */
  59059. hasMesh(mesh: AbstractMesh): boolean;
  59060. /**
  59061. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59062. * @param mesh The mesh to highlight
  59063. * @param color The color of the highlight
  59064. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59065. */
  59066. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59067. /**
  59068. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59069. * @param mesh The mesh to highlight
  59070. */
  59071. removeMesh(mesh: Mesh): void;
  59072. /**
  59073. * Remove all the meshes currently referenced in the highlight layer
  59074. */
  59075. removeAllMeshes(): void;
  59076. /**
  59077. * Force the stencil to the normal expected value for none glowing parts
  59078. */
  59079. private _defaultStencilReference;
  59080. /**
  59081. * Free any resources and references associated to a mesh.
  59082. * Internal use
  59083. * @param mesh The mesh to free.
  59084. * @hidden
  59085. */
  59086. _disposeMesh(mesh: Mesh): void;
  59087. /**
  59088. * Dispose the highlight layer and free resources.
  59089. */
  59090. dispose(): void;
  59091. /**
  59092. * Gets the class name of the effect layer
  59093. * @returns the string with the class name of the effect layer
  59094. */
  59095. getClassName(): string;
  59096. /**
  59097. * Serializes this Highlight layer
  59098. * @returns a serialized Highlight layer object
  59099. */
  59100. serialize(): any;
  59101. /**
  59102. * Creates a Highlight layer from parsed Highlight layer data
  59103. * @param parsedHightlightLayer defines the Highlight layer data
  59104. * @param scene defines the current scene
  59105. * @param rootUrl defines the root URL containing the Highlight layer information
  59106. * @returns a parsed Highlight layer
  59107. */
  59108. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59109. }
  59110. }
  59111. declare module BABYLON {
  59112. interface AbstractScene {
  59113. /**
  59114. * The list of layers (background and foreground) of the scene
  59115. */
  59116. layers: Array<Layer>;
  59117. }
  59118. /**
  59119. * Defines the layer scene component responsible to manage any layers
  59120. * in a given scene.
  59121. */
  59122. export class LayerSceneComponent implements ISceneComponent {
  59123. /**
  59124. * The component name helpfull to identify the component in the list of scene components.
  59125. */
  59126. readonly name: string;
  59127. /**
  59128. * The scene the component belongs to.
  59129. */
  59130. scene: Scene;
  59131. private _engine;
  59132. /**
  59133. * Creates a new instance of the component for the given scene
  59134. * @param scene Defines the scene to register the component in
  59135. */
  59136. constructor(scene: Scene);
  59137. /**
  59138. * Registers the component in a given scene
  59139. */
  59140. register(): void;
  59141. /**
  59142. * Rebuilds the elements related to this component in case of
  59143. * context lost for instance.
  59144. */
  59145. rebuild(): void;
  59146. /**
  59147. * Disposes the component and the associated ressources.
  59148. */
  59149. dispose(): void;
  59150. private _draw;
  59151. private _drawCameraPredicate;
  59152. private _drawCameraBackground;
  59153. private _drawCameraForeground;
  59154. private _drawRenderTargetPredicate;
  59155. private _drawRenderTargetBackground;
  59156. private _drawRenderTargetForeground;
  59157. /**
  59158. * Adds all the elements from the container to the scene
  59159. * @param container the container holding the elements
  59160. */
  59161. addFromContainer(container: AbstractScene): void;
  59162. /**
  59163. * Removes all the elements in the container from the scene
  59164. * @param container contains the elements to remove
  59165. * @param dispose if the removed element should be disposed (default: false)
  59166. */
  59167. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59168. }
  59169. }
  59170. declare module BABYLON {
  59171. /** @hidden */
  59172. export var layerPixelShader: {
  59173. name: string;
  59174. shader: string;
  59175. };
  59176. }
  59177. declare module BABYLON {
  59178. /** @hidden */
  59179. export var layerVertexShader: {
  59180. name: string;
  59181. shader: string;
  59182. };
  59183. }
  59184. declare module BABYLON {
  59185. /**
  59186. * This represents a full screen 2d layer.
  59187. * This can be useful to display a picture in the background of your scene for instance.
  59188. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59189. */
  59190. export class Layer {
  59191. /**
  59192. * Define the name of the layer.
  59193. */
  59194. name: string;
  59195. /**
  59196. * Define the texture the layer should display.
  59197. */
  59198. texture: Nullable<Texture>;
  59199. /**
  59200. * Is the layer in background or foreground.
  59201. */
  59202. isBackground: boolean;
  59203. /**
  59204. * Define the color of the layer (instead of texture).
  59205. */
  59206. color: Color4;
  59207. /**
  59208. * Define the scale of the layer in order to zoom in out of the texture.
  59209. */
  59210. scale: Vector2;
  59211. /**
  59212. * Define an offset for the layer in order to shift the texture.
  59213. */
  59214. offset: Vector2;
  59215. /**
  59216. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59217. */
  59218. alphaBlendingMode: number;
  59219. /**
  59220. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59221. * Alpha test will not mix with the background color in case of transparency.
  59222. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59223. */
  59224. alphaTest: boolean;
  59225. /**
  59226. * Define a mask to restrict the layer to only some of the scene cameras.
  59227. */
  59228. layerMask: number;
  59229. /**
  59230. * Define the list of render target the layer is visible into.
  59231. */
  59232. renderTargetTextures: RenderTargetTexture[];
  59233. /**
  59234. * Define if the layer is only used in renderTarget or if it also
  59235. * renders in the main frame buffer of the canvas.
  59236. */
  59237. renderOnlyInRenderTargetTextures: boolean;
  59238. private _scene;
  59239. private _vertexBuffers;
  59240. private _indexBuffer;
  59241. private _effect;
  59242. private _previousDefines;
  59243. /**
  59244. * An event triggered when the layer is disposed.
  59245. */
  59246. onDisposeObservable: Observable<Layer>;
  59247. private _onDisposeObserver;
  59248. /**
  59249. * Back compatibility with callback before the onDisposeObservable existed.
  59250. * The set callback will be triggered when the layer has been disposed.
  59251. */
  59252. set onDispose(callback: () => void);
  59253. /**
  59254. * An event triggered before rendering the scene
  59255. */
  59256. onBeforeRenderObservable: Observable<Layer>;
  59257. private _onBeforeRenderObserver;
  59258. /**
  59259. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59260. * The set callback will be triggered just before rendering the layer.
  59261. */
  59262. set onBeforeRender(callback: () => void);
  59263. /**
  59264. * An event triggered after rendering the scene
  59265. */
  59266. onAfterRenderObservable: Observable<Layer>;
  59267. private _onAfterRenderObserver;
  59268. /**
  59269. * Back compatibility with callback before the onAfterRenderObservable existed.
  59270. * The set callback will be triggered just after rendering the layer.
  59271. */
  59272. set onAfterRender(callback: () => void);
  59273. /**
  59274. * Instantiates a new layer.
  59275. * This represents a full screen 2d layer.
  59276. * This can be useful to display a picture in the background of your scene for instance.
  59277. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59278. * @param name Define the name of the layer in the scene
  59279. * @param imgUrl Define the url of the texture to display in the layer
  59280. * @param scene Define the scene the layer belongs to
  59281. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59282. * @param color Defines a color for the layer
  59283. */
  59284. constructor(
  59285. /**
  59286. * Define the name of the layer.
  59287. */
  59288. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59289. private _createIndexBuffer;
  59290. /** @hidden */
  59291. _rebuild(): void;
  59292. /**
  59293. * Renders the layer in the scene.
  59294. */
  59295. render(): void;
  59296. /**
  59297. * Disposes and releases the associated ressources.
  59298. */
  59299. dispose(): void;
  59300. }
  59301. }
  59302. declare module BABYLON {
  59303. /** @hidden */
  59304. export var lensFlarePixelShader: {
  59305. name: string;
  59306. shader: string;
  59307. };
  59308. }
  59309. declare module BABYLON {
  59310. /** @hidden */
  59311. export var lensFlareVertexShader: {
  59312. name: string;
  59313. shader: string;
  59314. };
  59315. }
  59316. declare module BABYLON {
  59317. /**
  59318. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59319. * It is usually composed of several `lensFlare`.
  59320. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59321. */
  59322. export class LensFlareSystem {
  59323. /**
  59324. * Define the name of the lens flare system
  59325. */
  59326. name: string;
  59327. /**
  59328. * List of lens flares used in this system.
  59329. */
  59330. lensFlares: LensFlare[];
  59331. /**
  59332. * Define a limit from the border the lens flare can be visible.
  59333. */
  59334. borderLimit: number;
  59335. /**
  59336. * Define a viewport border we do not want to see the lens flare in.
  59337. */
  59338. viewportBorder: number;
  59339. /**
  59340. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59341. */
  59342. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59343. /**
  59344. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59345. */
  59346. layerMask: number;
  59347. /**
  59348. * Define the id of the lens flare system in the scene.
  59349. * (equal to name by default)
  59350. */
  59351. id: string;
  59352. private _scene;
  59353. private _emitter;
  59354. private _vertexBuffers;
  59355. private _indexBuffer;
  59356. private _effect;
  59357. private _positionX;
  59358. private _positionY;
  59359. private _isEnabled;
  59360. /** @hidden */
  59361. static _SceneComponentInitialization: (scene: Scene) => void;
  59362. /**
  59363. * Instantiates a lens flare system.
  59364. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59365. * It is usually composed of several `lensFlare`.
  59366. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59367. * @param name Define the name of the lens flare system in the scene
  59368. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59369. * @param scene Define the scene the lens flare system belongs to
  59370. */
  59371. constructor(
  59372. /**
  59373. * Define the name of the lens flare system
  59374. */
  59375. name: string, emitter: any, scene: Scene);
  59376. /**
  59377. * Define if the lens flare system is enabled.
  59378. */
  59379. get isEnabled(): boolean;
  59380. set isEnabled(value: boolean);
  59381. /**
  59382. * Get the scene the effects belongs to.
  59383. * @returns the scene holding the lens flare system
  59384. */
  59385. getScene(): Scene;
  59386. /**
  59387. * Get the emitter of the lens flare system.
  59388. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59389. * @returns the emitter of the lens flare system
  59390. */
  59391. getEmitter(): any;
  59392. /**
  59393. * Set the emitter of the lens flare system.
  59394. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59395. * @param newEmitter Define the new emitter of the system
  59396. */
  59397. setEmitter(newEmitter: any): void;
  59398. /**
  59399. * Get the lens flare system emitter position.
  59400. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59401. * @returns the position
  59402. */
  59403. getEmitterPosition(): Vector3;
  59404. /**
  59405. * @hidden
  59406. */
  59407. computeEffectivePosition(globalViewport: Viewport): boolean;
  59408. /** @hidden */
  59409. _isVisible(): boolean;
  59410. /**
  59411. * @hidden
  59412. */
  59413. render(): boolean;
  59414. /**
  59415. * Dispose and release the lens flare with its associated resources.
  59416. */
  59417. dispose(): void;
  59418. /**
  59419. * Parse a lens flare system from a JSON repressentation
  59420. * @param parsedLensFlareSystem Define the JSON to parse
  59421. * @param scene Define the scene the parsed system should be instantiated in
  59422. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59423. * @returns the parsed system
  59424. */
  59425. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59426. /**
  59427. * Serialize the current Lens Flare System into a JSON representation.
  59428. * @returns the serialized JSON
  59429. */
  59430. serialize(): any;
  59431. }
  59432. }
  59433. declare module BABYLON {
  59434. /**
  59435. * This represents one of the lens effect in a `lensFlareSystem`.
  59436. * It controls one of the indiviual texture used in the effect.
  59437. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59438. */
  59439. export class LensFlare {
  59440. /**
  59441. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59442. */
  59443. size: number;
  59444. /**
  59445. * 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.
  59446. */
  59447. position: number;
  59448. /**
  59449. * Define the lens color.
  59450. */
  59451. color: Color3;
  59452. /**
  59453. * Define the lens texture.
  59454. */
  59455. texture: Nullable<Texture>;
  59456. /**
  59457. * Define the alpha mode to render this particular lens.
  59458. */
  59459. alphaMode: number;
  59460. private _system;
  59461. /**
  59462. * Creates a new Lens Flare.
  59463. * This represents one of the lens effect in a `lensFlareSystem`.
  59464. * It controls one of the indiviual texture used in the effect.
  59465. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59466. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59467. * @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.
  59468. * @param color Define the lens color
  59469. * @param imgUrl Define the lens texture url
  59470. * @param system Define the `lensFlareSystem` this flare is part of
  59471. * @returns The newly created Lens Flare
  59472. */
  59473. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59474. /**
  59475. * Instantiates a new Lens Flare.
  59476. * This represents one of the lens effect in a `lensFlareSystem`.
  59477. * It controls one of the indiviual texture used in the effect.
  59478. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59479. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59480. * @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.
  59481. * @param color Define the lens color
  59482. * @param imgUrl Define the lens texture url
  59483. * @param system Define the `lensFlareSystem` this flare is part of
  59484. */
  59485. constructor(
  59486. /**
  59487. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59488. */
  59489. size: number,
  59490. /**
  59491. * 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.
  59492. */
  59493. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59494. /**
  59495. * Dispose and release the lens flare with its associated resources.
  59496. */
  59497. dispose(): void;
  59498. }
  59499. }
  59500. declare module BABYLON {
  59501. interface AbstractScene {
  59502. /**
  59503. * The list of lens flare system added to the scene
  59504. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59505. */
  59506. lensFlareSystems: Array<LensFlareSystem>;
  59507. /**
  59508. * Removes the given lens flare system from this scene.
  59509. * @param toRemove The lens flare system to remove
  59510. * @returns The index of the removed lens flare system
  59511. */
  59512. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59513. /**
  59514. * Adds the given lens flare system to this scene
  59515. * @param newLensFlareSystem The lens flare system to add
  59516. */
  59517. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59518. /**
  59519. * Gets a lens flare system using its name
  59520. * @param name defines the name to look for
  59521. * @returns the lens flare system or null if not found
  59522. */
  59523. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59524. /**
  59525. * Gets a lens flare system using its id
  59526. * @param id defines the id to look for
  59527. * @returns the lens flare system or null if not found
  59528. */
  59529. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59530. }
  59531. /**
  59532. * Defines the lens flare scene component responsible to manage any lens flares
  59533. * in a given scene.
  59534. */
  59535. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59536. /**
  59537. * The component name helpfull to identify the component in the list of scene components.
  59538. */
  59539. readonly name: string;
  59540. /**
  59541. * The scene the component belongs to.
  59542. */
  59543. scene: Scene;
  59544. /**
  59545. * Creates a new instance of the component for the given scene
  59546. * @param scene Defines the scene to register the component in
  59547. */
  59548. constructor(scene: Scene);
  59549. /**
  59550. * Registers the component in a given scene
  59551. */
  59552. register(): void;
  59553. /**
  59554. * Rebuilds the elements related to this component in case of
  59555. * context lost for instance.
  59556. */
  59557. rebuild(): 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. * Serializes the component data to the specified json object
  59571. * @param serializationObject The object to serialize to
  59572. */
  59573. serialize(serializationObject: any): void;
  59574. /**
  59575. * Disposes the component and the associated ressources.
  59576. */
  59577. dispose(): void;
  59578. private _draw;
  59579. }
  59580. }
  59581. declare module BABYLON {
  59582. /** @hidden */
  59583. export var depthPixelShader: {
  59584. name: string;
  59585. shader: string;
  59586. };
  59587. }
  59588. declare module BABYLON {
  59589. /** @hidden */
  59590. export var depthVertexShader: {
  59591. name: string;
  59592. shader: string;
  59593. };
  59594. }
  59595. declare module BABYLON {
  59596. /**
  59597. * This represents a depth renderer in Babylon.
  59598. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59599. */
  59600. export class DepthRenderer {
  59601. private _scene;
  59602. private _depthMap;
  59603. private _effect;
  59604. private readonly _storeNonLinearDepth;
  59605. private readonly _clearColor;
  59606. /** Get if the depth renderer is using packed depth or not */
  59607. readonly isPacked: boolean;
  59608. private _cachedDefines;
  59609. private _camera;
  59610. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59611. enabled: boolean;
  59612. /**
  59613. * Specifiess that the depth renderer will only be used within
  59614. * the camera it is created for.
  59615. * This can help forcing its rendering during the camera processing.
  59616. */
  59617. useOnlyInActiveCamera: boolean;
  59618. /** @hidden */
  59619. static _SceneComponentInitialization: (scene: Scene) => void;
  59620. /**
  59621. * Instantiates a depth renderer
  59622. * @param scene The scene the renderer belongs to
  59623. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59624. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59625. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59626. */
  59627. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59628. /**
  59629. * Creates the depth rendering effect and checks if the effect is ready.
  59630. * @param subMesh The submesh to be used to render the depth map of
  59631. * @param useInstances If multiple world instances should be used
  59632. * @returns if the depth renderer is ready to render the depth map
  59633. */
  59634. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59635. /**
  59636. * Gets the texture which the depth map will be written to.
  59637. * @returns The depth map texture
  59638. */
  59639. getDepthMap(): RenderTargetTexture;
  59640. /**
  59641. * Disposes of the depth renderer.
  59642. */
  59643. dispose(): void;
  59644. }
  59645. }
  59646. declare module BABYLON {
  59647. /** @hidden */
  59648. export var minmaxReduxPixelShader: {
  59649. name: string;
  59650. shader: string;
  59651. };
  59652. }
  59653. declare module BABYLON {
  59654. /**
  59655. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59656. * and maximum values from all values of the texture.
  59657. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59658. * The source values are read from the red channel of the texture.
  59659. */
  59660. export class MinMaxReducer {
  59661. /**
  59662. * Observable triggered when the computation has been performed
  59663. */
  59664. onAfterReductionPerformed: Observable<{
  59665. min: number;
  59666. max: number;
  59667. }>;
  59668. protected _camera: Camera;
  59669. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59670. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59671. protected _postProcessManager: PostProcessManager;
  59672. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59673. protected _forceFullscreenViewport: boolean;
  59674. /**
  59675. * Creates a min/max reducer
  59676. * @param camera The camera to use for the post processes
  59677. */
  59678. constructor(camera: Camera);
  59679. /**
  59680. * Gets the texture used to read the values from.
  59681. */
  59682. get sourceTexture(): Nullable<RenderTargetTexture>;
  59683. /**
  59684. * Sets the source texture to read the values from.
  59685. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59686. * because in such textures '1' value must not be taken into account to compute the maximum
  59687. * as this value is used to clear the texture.
  59688. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59689. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59690. * @param depthRedux Indicates if the texture is a depth texture or not
  59691. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59692. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59693. */
  59694. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59695. /**
  59696. * Defines the refresh rate of the computation.
  59697. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59698. */
  59699. get refreshRate(): number;
  59700. set refreshRate(value: number);
  59701. protected _activated: boolean;
  59702. /**
  59703. * Gets the activation status of the reducer
  59704. */
  59705. get activated(): boolean;
  59706. /**
  59707. * Activates the reduction computation.
  59708. * When activated, the observers registered in onAfterReductionPerformed are
  59709. * called after the compuation is performed
  59710. */
  59711. activate(): void;
  59712. /**
  59713. * Deactivates the reduction computation.
  59714. */
  59715. deactivate(): void;
  59716. /**
  59717. * Disposes the min/max reducer
  59718. * @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.
  59719. */
  59720. dispose(disposeAll?: boolean): void;
  59721. }
  59722. }
  59723. declare module BABYLON {
  59724. /**
  59725. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59726. */
  59727. export class DepthReducer extends MinMaxReducer {
  59728. private _depthRenderer;
  59729. private _depthRendererId;
  59730. /**
  59731. * Gets the depth renderer used for the computation.
  59732. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59733. */
  59734. get depthRenderer(): Nullable<DepthRenderer>;
  59735. /**
  59736. * Creates a depth reducer
  59737. * @param camera The camera used to render the depth texture
  59738. */
  59739. constructor(camera: Camera);
  59740. /**
  59741. * Sets the depth renderer to use to generate the depth map
  59742. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59743. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59744. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59745. */
  59746. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59747. /** @hidden */
  59748. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59749. /**
  59750. * Activates the reduction computation.
  59751. * When activated, the observers registered in onAfterReductionPerformed are
  59752. * called after the compuation is performed
  59753. */
  59754. activate(): void;
  59755. /**
  59756. * Deactivates the reduction computation.
  59757. */
  59758. deactivate(): void;
  59759. /**
  59760. * Disposes the depth reducer
  59761. * @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.
  59762. */
  59763. dispose(disposeAll?: boolean): void;
  59764. }
  59765. }
  59766. declare module BABYLON {
  59767. /**
  59768. * A CSM implementation allowing casting shadows on large scenes.
  59769. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59770. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59771. */
  59772. export class CascadedShadowGenerator extends ShadowGenerator {
  59773. private static readonly frustumCornersNDCSpace;
  59774. /**
  59775. * Name of the CSM class
  59776. */
  59777. static CLASSNAME: string;
  59778. /**
  59779. * Defines the default number of cascades used by the CSM.
  59780. */
  59781. static readonly DEFAULT_CASCADES_COUNT: number;
  59782. /**
  59783. * Defines the minimum number of cascades used by the CSM.
  59784. */
  59785. static readonly MIN_CASCADES_COUNT: number;
  59786. /**
  59787. * Defines the maximum number of cascades used by the CSM.
  59788. */
  59789. static readonly MAX_CASCADES_COUNT: number;
  59790. protected _validateFilter(filter: number): number;
  59791. /**
  59792. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59793. */
  59794. penumbraDarkness: number;
  59795. private _numCascades;
  59796. /**
  59797. * Gets or set the number of cascades used by the CSM.
  59798. */
  59799. get numCascades(): number;
  59800. set numCascades(value: number);
  59801. /**
  59802. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59803. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59804. */
  59805. stabilizeCascades: boolean;
  59806. private _freezeShadowCastersBoundingInfo;
  59807. private _freezeShadowCastersBoundingInfoObservable;
  59808. /**
  59809. * Enables or disables the shadow casters bounding info computation.
  59810. * If your shadow casters don't move, you can disable this feature.
  59811. * If it is enabled, the bounding box computation is done every frame.
  59812. */
  59813. get freezeShadowCastersBoundingInfo(): boolean;
  59814. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59815. private _scbiMin;
  59816. private _scbiMax;
  59817. protected _computeShadowCastersBoundingInfo(): void;
  59818. protected _shadowCastersBoundingInfo: BoundingInfo;
  59819. /**
  59820. * Gets or sets the shadow casters bounding info.
  59821. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59822. * so that the system won't overwrite the bounds you provide
  59823. */
  59824. get shadowCastersBoundingInfo(): BoundingInfo;
  59825. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59826. protected _breaksAreDirty: boolean;
  59827. protected _minDistance: number;
  59828. protected _maxDistance: number;
  59829. /**
  59830. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59831. *
  59832. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59833. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59834. * @param min minimal distance for the breaks (default to 0.)
  59835. * @param max maximal distance for the breaks (default to 1.)
  59836. */
  59837. setMinMaxDistance(min: number, max: number): void;
  59838. /** Gets the minimal distance used in the cascade break computation */
  59839. get minDistance(): number;
  59840. /** Gets the maximal distance used in the cascade break computation */
  59841. get maxDistance(): number;
  59842. /**
  59843. * Gets the class name of that object
  59844. * @returns "CascadedShadowGenerator"
  59845. */
  59846. getClassName(): string;
  59847. private _cascadeMinExtents;
  59848. private _cascadeMaxExtents;
  59849. /**
  59850. * Gets a cascade minimum extents
  59851. * @param cascadeIndex index of the cascade
  59852. * @returns the minimum cascade extents
  59853. */
  59854. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59855. /**
  59856. * Gets a cascade maximum extents
  59857. * @param cascadeIndex index of the cascade
  59858. * @returns the maximum cascade extents
  59859. */
  59860. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59861. private _cascades;
  59862. private _currentLayer;
  59863. private _viewSpaceFrustumsZ;
  59864. private _viewMatrices;
  59865. private _projectionMatrices;
  59866. private _transformMatrices;
  59867. private _transformMatricesAsArray;
  59868. private _frustumLengths;
  59869. private _lightSizeUVCorrection;
  59870. private _depthCorrection;
  59871. private _frustumCornersWorldSpace;
  59872. private _frustumCenter;
  59873. private _shadowCameraPos;
  59874. private _shadowMaxZ;
  59875. /**
  59876. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59877. * It defaults to camera.maxZ
  59878. */
  59879. get shadowMaxZ(): number;
  59880. /**
  59881. * Sets the shadow max z distance.
  59882. */
  59883. set shadowMaxZ(value: number);
  59884. protected _debug: boolean;
  59885. /**
  59886. * Gets or sets the debug flag.
  59887. * When enabled, the cascades are materialized by different colors on the screen.
  59888. */
  59889. get debug(): boolean;
  59890. set debug(dbg: boolean);
  59891. private _depthClamp;
  59892. /**
  59893. * Gets or sets the depth clamping value.
  59894. *
  59895. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59896. * to account for the shadow casters far away.
  59897. *
  59898. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59899. */
  59900. get depthClamp(): boolean;
  59901. set depthClamp(value: boolean);
  59902. private _cascadeBlendPercentage;
  59903. /**
  59904. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59905. * It defaults to 0.1 (10% blending).
  59906. */
  59907. get cascadeBlendPercentage(): number;
  59908. set cascadeBlendPercentage(value: number);
  59909. private _lambda;
  59910. /**
  59911. * Gets or set the lambda parameter.
  59912. * This parameter is used to split the camera frustum and create the cascades.
  59913. * 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.
  59914. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59915. */
  59916. get lambda(): number;
  59917. set lambda(value: number);
  59918. /**
  59919. * Gets the view matrix corresponding to a given cascade
  59920. * @param cascadeNum cascade to retrieve the view matrix from
  59921. * @returns the cascade view matrix
  59922. */
  59923. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59924. /**
  59925. * Gets the projection matrix corresponding to a given cascade
  59926. * @param cascadeNum cascade to retrieve the projection matrix from
  59927. * @returns the cascade projection matrix
  59928. */
  59929. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59930. /**
  59931. * Gets the transformation matrix corresponding to a given cascade
  59932. * @param cascadeNum cascade to retrieve the transformation matrix from
  59933. * @returns the cascade transformation matrix
  59934. */
  59935. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59936. private _depthRenderer;
  59937. /**
  59938. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59939. *
  59940. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59941. *
  59942. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59943. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59944. * @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
  59945. */
  59946. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59947. private _depthReducer;
  59948. private _autoCalcDepthBounds;
  59949. /**
  59950. * Gets or sets the autoCalcDepthBounds property.
  59951. *
  59952. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59953. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59954. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59955. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59956. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59957. */
  59958. get autoCalcDepthBounds(): boolean;
  59959. set autoCalcDepthBounds(value: boolean);
  59960. /**
  59961. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59962. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59963. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59964. * for setting the refresh rate on the renderer yourself!
  59965. */
  59966. get autoCalcDepthBoundsRefreshRate(): number;
  59967. set autoCalcDepthBoundsRefreshRate(value: number);
  59968. /**
  59969. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59970. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59971. * you change the camera near/far planes!
  59972. */
  59973. splitFrustum(): void;
  59974. private _splitFrustum;
  59975. private _computeMatrices;
  59976. private _computeFrustumInWorldSpace;
  59977. private _computeCascadeFrustum;
  59978. /**
  59979. * Support test.
  59980. */
  59981. static get IsSupported(): boolean;
  59982. /** @hidden */
  59983. static _SceneComponentInitialization: (scene: Scene) => void;
  59984. /**
  59985. * Creates a Cascaded Shadow Generator object.
  59986. * A ShadowGenerator is the required tool to use the shadows.
  59987. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59988. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59989. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59990. * @param light The directional light object generating the shadows.
  59991. * @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.
  59992. */
  59993. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59994. protected _initializeGenerator(): void;
  59995. protected _createTargetRenderTexture(): void;
  59996. protected _initializeShadowMap(): void;
  59997. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59998. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59999. /**
  60000. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60001. * @param defines Defines of the material we want to update
  60002. * @param lightIndex Index of the light in the enabled light list of the material
  60003. */
  60004. prepareDefines(defines: any, lightIndex: number): void;
  60005. /**
  60006. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60007. * defined in the generator but impacting the effect).
  60008. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60009. * @param effect The effect we are binfing the information for
  60010. */
  60011. bindShadowLight(lightIndex: string, effect: Effect): void;
  60012. /**
  60013. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60014. * (eq to view projection * shadow projection matrices)
  60015. * @returns The transform matrix used to create the shadow map
  60016. */
  60017. getTransformMatrix(): Matrix;
  60018. /**
  60019. * Disposes the ShadowGenerator.
  60020. * Returns nothing.
  60021. */
  60022. dispose(): void;
  60023. /**
  60024. * Serializes the shadow generator setup to a json object.
  60025. * @returns The serialized JSON object
  60026. */
  60027. serialize(): any;
  60028. /**
  60029. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60030. * @param parsedShadowGenerator The JSON object to parse
  60031. * @param scene The scene to create the shadow map for
  60032. * @returns The parsed shadow generator
  60033. */
  60034. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60035. }
  60036. }
  60037. declare module BABYLON {
  60038. /**
  60039. * Defines the shadow generator component responsible to manage any shadow generators
  60040. * in a given scene.
  60041. */
  60042. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60043. /**
  60044. * The component name helpfull to identify the component in the list of scene components.
  60045. */
  60046. readonly name: string;
  60047. /**
  60048. * The scene the component belongs to.
  60049. */
  60050. scene: Scene;
  60051. /**
  60052. * Creates a new instance of the component for the given scene
  60053. * @param scene Defines the scene to register the component in
  60054. */
  60055. constructor(scene: Scene);
  60056. /**
  60057. * Registers the component in a given scene
  60058. */
  60059. register(): void;
  60060. /**
  60061. * Rebuilds the elements related to this component in case of
  60062. * context lost for instance.
  60063. */
  60064. rebuild(): void;
  60065. /**
  60066. * Serializes the component data to the specified json object
  60067. * @param serializationObject The object to serialize to
  60068. */
  60069. serialize(serializationObject: any): void;
  60070. /**
  60071. * Adds all the elements from the container to the scene
  60072. * @param container the container holding the elements
  60073. */
  60074. addFromContainer(container: AbstractScene): void;
  60075. /**
  60076. * Removes all the elements in the container from the scene
  60077. * @param container contains the elements to remove
  60078. * @param dispose if the removed element should be disposed (default: false)
  60079. */
  60080. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60081. /**
  60082. * Rebuilds the elements related to this component in case of
  60083. * context lost for instance.
  60084. */
  60085. dispose(): void;
  60086. private _gatherRenderTargets;
  60087. }
  60088. }
  60089. declare module BABYLON {
  60090. /**
  60091. * A point light is a light defined by an unique point in world space.
  60092. * The light is emitted in every direction from this point.
  60093. * A good example of a point light is a standard light bulb.
  60094. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60095. */
  60096. export class PointLight extends ShadowLight {
  60097. private _shadowAngle;
  60098. /**
  60099. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60100. * This specifies what angle the shadow will use to be created.
  60101. *
  60102. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60103. */
  60104. get shadowAngle(): number;
  60105. /**
  60106. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60107. * This specifies what angle the shadow will use to be created.
  60108. *
  60109. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60110. */
  60111. set shadowAngle(value: number);
  60112. /**
  60113. * Gets the direction if it has been set.
  60114. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60115. */
  60116. get direction(): Vector3;
  60117. /**
  60118. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60119. */
  60120. set direction(value: Vector3);
  60121. /**
  60122. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60123. * A PointLight emits the light in every direction.
  60124. * It can cast shadows.
  60125. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60126. * ```javascript
  60127. * var pointLight = new PointLight("pl", camera.position, scene);
  60128. * ```
  60129. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60130. * @param name The light friendly name
  60131. * @param position The position of the point light in the scene
  60132. * @param scene The scene the lights belongs to
  60133. */
  60134. constructor(name: string, position: Vector3, scene: Scene);
  60135. /**
  60136. * Returns the string "PointLight"
  60137. * @returns the class name
  60138. */
  60139. getClassName(): string;
  60140. /**
  60141. * Returns the integer 0.
  60142. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60143. */
  60144. getTypeID(): number;
  60145. /**
  60146. * Specifies wether or not the shadowmap should be a cube texture.
  60147. * @returns true if the shadowmap needs to be a cube texture.
  60148. */
  60149. needCube(): boolean;
  60150. /**
  60151. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60152. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60153. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60154. */
  60155. getShadowDirection(faceIndex?: number): Vector3;
  60156. /**
  60157. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60158. * - fov = PI / 2
  60159. * - aspect ratio : 1.0
  60160. * - z-near and far equal to the active camera minZ and maxZ.
  60161. * Returns the PointLight.
  60162. */
  60163. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60164. protected _buildUniformLayout(): void;
  60165. /**
  60166. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60167. * @param effect The effect to update
  60168. * @param lightIndex The index of the light in the effect to update
  60169. * @returns The point light
  60170. */
  60171. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60172. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60173. /**
  60174. * Prepares the list of defines specific to the light type.
  60175. * @param defines the list of defines
  60176. * @param lightIndex defines the index of the light for the effect
  60177. */
  60178. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60179. }
  60180. }
  60181. declare module BABYLON {
  60182. /**
  60183. * Header information of HDR texture files.
  60184. */
  60185. export interface HDRInfo {
  60186. /**
  60187. * The height of the texture in pixels.
  60188. */
  60189. height: number;
  60190. /**
  60191. * The width of the texture in pixels.
  60192. */
  60193. width: number;
  60194. /**
  60195. * The index of the beginning of the data in the binary file.
  60196. */
  60197. dataPosition: number;
  60198. }
  60199. /**
  60200. * This groups tools to convert HDR texture to native colors array.
  60201. */
  60202. export class HDRTools {
  60203. private static Ldexp;
  60204. private static Rgbe2float;
  60205. private static readStringLine;
  60206. /**
  60207. * Reads header information from an RGBE texture stored in a native array.
  60208. * More information on this format are available here:
  60209. * https://en.wikipedia.org/wiki/RGBE_image_format
  60210. *
  60211. * @param uint8array The binary file stored in native array.
  60212. * @return The header information.
  60213. */
  60214. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60215. /**
  60216. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60217. * This RGBE texture needs to store the information as a panorama.
  60218. *
  60219. * More information on this format are available here:
  60220. * https://en.wikipedia.org/wiki/RGBE_image_format
  60221. *
  60222. * @param buffer The binary file stored in an array buffer.
  60223. * @param size The expected size of the extracted cubemap.
  60224. * @return The Cube Map information.
  60225. */
  60226. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60227. /**
  60228. * Returns the pixels data extracted from an RGBE texture.
  60229. * This pixels will be stored left to right up to down in the R G B order in one array.
  60230. *
  60231. * More information on this format are available here:
  60232. * https://en.wikipedia.org/wiki/RGBE_image_format
  60233. *
  60234. * @param uint8array The binary file stored in an array buffer.
  60235. * @param hdrInfo The header information of the file.
  60236. * @return The pixels data in RGB right to left up to down order.
  60237. */
  60238. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60239. private static RGBE_ReadPixels_RLE;
  60240. private static RGBE_ReadPixels_NOT_RLE;
  60241. }
  60242. }
  60243. declare module BABYLON {
  60244. /**
  60245. * Effect Render Options
  60246. */
  60247. export interface IEffectRendererOptions {
  60248. /**
  60249. * Defines the vertices positions.
  60250. */
  60251. positions?: number[];
  60252. /**
  60253. * Defines the indices.
  60254. */
  60255. indices?: number[];
  60256. }
  60257. /**
  60258. * Helper class to render one or more effects.
  60259. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60260. */
  60261. export class EffectRenderer {
  60262. private engine;
  60263. private static _DefaultOptions;
  60264. private _vertexBuffers;
  60265. private _indexBuffer;
  60266. private _fullscreenViewport;
  60267. /**
  60268. * Creates an effect renderer
  60269. * @param engine the engine to use for rendering
  60270. * @param options defines the options of the effect renderer
  60271. */
  60272. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60273. /**
  60274. * Sets the current viewport in normalized coordinates 0-1
  60275. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60276. */
  60277. setViewport(viewport?: Viewport): void;
  60278. /**
  60279. * Binds the embedded attributes buffer to the effect.
  60280. * @param effect Defines the effect to bind the attributes for
  60281. */
  60282. bindBuffers(effect: Effect): void;
  60283. /**
  60284. * Sets the current effect wrapper to use during draw.
  60285. * The effect needs to be ready before calling this api.
  60286. * This also sets the default full screen position attribute.
  60287. * @param effectWrapper Defines the effect to draw with
  60288. */
  60289. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60290. /**
  60291. * Restores engine states
  60292. */
  60293. restoreStates(): void;
  60294. /**
  60295. * Draws a full screen quad.
  60296. */
  60297. draw(): void;
  60298. private isRenderTargetTexture;
  60299. /**
  60300. * renders one or more effects to a specified texture
  60301. * @param effectWrapper the effect to renderer
  60302. * @param outputTexture texture to draw to, if null it will render to the screen.
  60303. */
  60304. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60305. /**
  60306. * Disposes of the effect renderer
  60307. */
  60308. dispose(): void;
  60309. }
  60310. /**
  60311. * Options to create an EffectWrapper
  60312. */
  60313. interface EffectWrapperCreationOptions {
  60314. /**
  60315. * Engine to use to create the effect
  60316. */
  60317. engine: ThinEngine;
  60318. /**
  60319. * Fragment shader for the effect
  60320. */
  60321. fragmentShader: string;
  60322. /**
  60323. * Use the shader store instead of direct source code
  60324. */
  60325. useShaderStore?: boolean;
  60326. /**
  60327. * Vertex shader for the effect
  60328. */
  60329. vertexShader?: string;
  60330. /**
  60331. * Attributes to use in the shader
  60332. */
  60333. attributeNames?: Array<string>;
  60334. /**
  60335. * Uniforms to use in the shader
  60336. */
  60337. uniformNames?: Array<string>;
  60338. /**
  60339. * Texture sampler names to use in the shader
  60340. */
  60341. samplerNames?: Array<string>;
  60342. /**
  60343. * Defines to use in the shader
  60344. */
  60345. defines?: Array<string>;
  60346. /**
  60347. * Callback when effect is compiled
  60348. */
  60349. onCompiled?: Nullable<(effect: Effect) => void>;
  60350. /**
  60351. * The friendly name of the effect displayed in Spector.
  60352. */
  60353. name?: string;
  60354. }
  60355. /**
  60356. * Wraps an effect to be used for rendering
  60357. */
  60358. export class EffectWrapper {
  60359. /**
  60360. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60361. */
  60362. onApplyObservable: Observable<{}>;
  60363. /**
  60364. * The underlying effect
  60365. */
  60366. effect: Effect;
  60367. /**
  60368. * Creates an effect to be renderer
  60369. * @param creationOptions options to create the effect
  60370. */
  60371. constructor(creationOptions: EffectWrapperCreationOptions);
  60372. /**
  60373. * Disposes of the effect wrapper
  60374. */
  60375. dispose(): void;
  60376. }
  60377. }
  60378. declare module BABYLON {
  60379. /** @hidden */
  60380. export var hdrFilteringVertexShader: {
  60381. name: string;
  60382. shader: string;
  60383. };
  60384. }
  60385. declare module BABYLON {
  60386. /** @hidden */
  60387. export var hdrFilteringPixelShader: {
  60388. name: string;
  60389. shader: string;
  60390. };
  60391. }
  60392. declare module BABYLON {
  60393. /**
  60394. * Options for texture filtering
  60395. */
  60396. interface IHDRFilteringOptions {
  60397. /**
  60398. * Scales pixel intensity for the input HDR map.
  60399. */
  60400. hdrScale?: number;
  60401. /**
  60402. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60403. */
  60404. quality?: number;
  60405. }
  60406. /**
  60407. * Filters HDR maps to get correct renderings of PBR reflections
  60408. */
  60409. export class HDRFiltering {
  60410. private _engine;
  60411. private _effectRenderer;
  60412. private _effectWrapper;
  60413. private _lodGenerationOffset;
  60414. private _lodGenerationScale;
  60415. /**
  60416. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60417. * you care about baking speed.
  60418. */
  60419. quality: number;
  60420. /**
  60421. * Scales pixel intensity for the input HDR map.
  60422. */
  60423. hdrScale: number;
  60424. /**
  60425. * Instantiates HDR filter for reflection maps
  60426. *
  60427. * @param engine Thin engine
  60428. * @param options Options
  60429. */
  60430. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60431. private _createRenderTarget;
  60432. private _prefilterInternal;
  60433. private _createEffect;
  60434. /**
  60435. * Get a value indicating if the filter is ready to be used
  60436. * @param texture Texture to filter
  60437. * @returns true if the filter is ready
  60438. */
  60439. isReady(texture: BaseTexture): boolean;
  60440. /**
  60441. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60442. * Prefiltering will be invoked at the end of next rendering pass.
  60443. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60444. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60445. * @param texture Texture to filter
  60446. * @param onFinished Callback when filtering is done
  60447. * @return Promise called when prefiltering is done
  60448. */
  60449. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60450. }
  60451. }
  60452. declare module BABYLON {
  60453. /**
  60454. * This represents a texture coming from an HDR input.
  60455. *
  60456. * The only supported format is currently panorama picture stored in RGBE format.
  60457. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60458. */
  60459. export class HDRCubeTexture extends BaseTexture {
  60460. private static _facesMapping;
  60461. private _generateHarmonics;
  60462. private _noMipmap;
  60463. private _prefilterOnLoad;
  60464. private _textureMatrix;
  60465. private _size;
  60466. private _onLoad;
  60467. private _onError;
  60468. /**
  60469. * The texture URL.
  60470. */
  60471. url: string;
  60472. protected _isBlocking: boolean;
  60473. /**
  60474. * Sets wether or not the texture is blocking during loading.
  60475. */
  60476. set isBlocking(value: boolean);
  60477. /**
  60478. * Gets wether or not the texture is blocking during loading.
  60479. */
  60480. get isBlocking(): boolean;
  60481. protected _rotationY: number;
  60482. /**
  60483. * Sets texture matrix rotation angle around Y axis in radians.
  60484. */
  60485. set rotationY(value: number);
  60486. /**
  60487. * Gets texture matrix rotation angle around Y axis radians.
  60488. */
  60489. get rotationY(): number;
  60490. /**
  60491. * Gets or sets the center of the bounding box associated with the cube texture
  60492. * It must define where the camera used to render the texture was set
  60493. */
  60494. boundingBoxPosition: Vector3;
  60495. private _boundingBoxSize;
  60496. /**
  60497. * Gets or sets the size of the bounding box associated with the cube texture
  60498. * When defined, the cubemap will switch to local mode
  60499. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60500. * @example https://www.babylonjs-playground.com/#RNASML
  60501. */
  60502. set boundingBoxSize(value: Vector3);
  60503. get boundingBoxSize(): Vector3;
  60504. /**
  60505. * Instantiates an HDRTexture from the following parameters.
  60506. *
  60507. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60508. * @param sceneOrEngine The scene or engine the texture will be used in
  60509. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60510. * @param noMipmap Forces to not generate the mipmap if true
  60511. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60512. * @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)
  60513. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60514. */
  60515. 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>);
  60516. /**
  60517. * Get the current class name of the texture useful for serialization or dynamic coding.
  60518. * @returns "HDRCubeTexture"
  60519. */
  60520. getClassName(): string;
  60521. /**
  60522. * Occurs when the file is raw .hdr file.
  60523. */
  60524. private loadTexture;
  60525. clone(): HDRCubeTexture;
  60526. delayLoad(): void;
  60527. /**
  60528. * Get the texture reflection matrix used to rotate/transform the reflection.
  60529. * @returns the reflection matrix
  60530. */
  60531. getReflectionTextureMatrix(): Matrix;
  60532. /**
  60533. * Set the texture reflection matrix used to rotate/transform the reflection.
  60534. * @param value Define the reflection matrix to set
  60535. */
  60536. setReflectionTextureMatrix(value: Matrix): void;
  60537. /**
  60538. * Parses a JSON representation of an HDR Texture in order to create the texture
  60539. * @param parsedTexture Define the JSON representation
  60540. * @param scene Define the scene the texture should be created in
  60541. * @param rootUrl Define the root url in case we need to load relative dependencies
  60542. * @returns the newly created texture after parsing
  60543. */
  60544. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60545. serialize(): any;
  60546. }
  60547. }
  60548. declare module BABYLON {
  60549. /**
  60550. * Class used to control physics engine
  60551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60552. */
  60553. export class PhysicsEngine implements IPhysicsEngine {
  60554. private _physicsPlugin;
  60555. /**
  60556. * Global value used to control the smallest number supported by the simulation
  60557. */
  60558. static Epsilon: number;
  60559. private _impostors;
  60560. private _joints;
  60561. private _subTimeStep;
  60562. /**
  60563. * Gets the gravity vector used by the simulation
  60564. */
  60565. gravity: Vector3;
  60566. /**
  60567. * Factory used to create the default physics plugin.
  60568. * @returns The default physics plugin
  60569. */
  60570. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60571. /**
  60572. * Creates a new Physics Engine
  60573. * @param gravity defines the gravity vector used by the simulation
  60574. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60575. */
  60576. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60577. /**
  60578. * Sets the gravity vector used by the simulation
  60579. * @param gravity defines the gravity vector to use
  60580. */
  60581. setGravity(gravity: Vector3): void;
  60582. /**
  60583. * Set the time step of the physics engine.
  60584. * Default is 1/60.
  60585. * To slow it down, enter 1/600 for example.
  60586. * To speed it up, 1/30
  60587. * @param newTimeStep defines the new timestep to apply to this world.
  60588. */
  60589. setTimeStep(newTimeStep?: number): void;
  60590. /**
  60591. * Get the time step of the physics engine.
  60592. * @returns the current time step
  60593. */
  60594. getTimeStep(): number;
  60595. /**
  60596. * Set the sub time step of the physics engine.
  60597. * Default is 0 meaning there is no sub steps
  60598. * To increase physics resolution precision, set a small value (like 1 ms)
  60599. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60600. */
  60601. setSubTimeStep(subTimeStep?: number): void;
  60602. /**
  60603. * Get the sub time step of the physics engine.
  60604. * @returns the current sub time step
  60605. */
  60606. getSubTimeStep(): number;
  60607. /**
  60608. * Release all resources
  60609. */
  60610. dispose(): void;
  60611. /**
  60612. * Gets the name of the current physics plugin
  60613. * @returns the name of the plugin
  60614. */
  60615. getPhysicsPluginName(): string;
  60616. /**
  60617. * Adding a new impostor for the impostor tracking.
  60618. * This will be done by the impostor itself.
  60619. * @param impostor the impostor to add
  60620. */
  60621. addImpostor(impostor: PhysicsImpostor): void;
  60622. /**
  60623. * Remove an impostor from the engine.
  60624. * This impostor and its mesh will not longer be updated by the physics engine.
  60625. * @param impostor the impostor to remove
  60626. */
  60627. removeImpostor(impostor: PhysicsImpostor): void;
  60628. /**
  60629. * Add a joint to the physics engine
  60630. * @param mainImpostor defines the main impostor to which the joint is added.
  60631. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60632. * @param joint defines the joint that will connect both impostors.
  60633. */
  60634. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60635. /**
  60636. * Removes a joint from the simulation
  60637. * @param mainImpostor defines the impostor used with the joint
  60638. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60639. * @param joint defines the joint to remove
  60640. */
  60641. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60642. /**
  60643. * Called by the scene. No need to call it.
  60644. * @param delta defines the timespam between frames
  60645. */
  60646. _step(delta: number): void;
  60647. /**
  60648. * Gets the current plugin used to run the simulation
  60649. * @returns current plugin
  60650. */
  60651. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60652. /**
  60653. * Gets the list of physic impostors
  60654. * @returns an array of PhysicsImpostor
  60655. */
  60656. getImpostors(): Array<PhysicsImpostor>;
  60657. /**
  60658. * Gets the impostor for a physics enabled object
  60659. * @param object defines the object impersonated by the impostor
  60660. * @returns the PhysicsImpostor or null if not found
  60661. */
  60662. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60663. /**
  60664. * Gets the impostor for a physics body object
  60665. * @param body defines physics body used by the impostor
  60666. * @returns the PhysicsImpostor or null if not found
  60667. */
  60668. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60669. /**
  60670. * Does a raycast in the physics world
  60671. * @param from when should the ray start?
  60672. * @param to when should the ray end?
  60673. * @returns PhysicsRaycastResult
  60674. */
  60675. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60676. }
  60677. }
  60678. declare module BABYLON {
  60679. /** @hidden */
  60680. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60681. private _useDeltaForWorldStep;
  60682. world: any;
  60683. name: string;
  60684. private _physicsMaterials;
  60685. private _fixedTimeStep;
  60686. private _cannonRaycastResult;
  60687. private _raycastResult;
  60688. private _physicsBodysToRemoveAfterStep;
  60689. private _firstFrame;
  60690. BJSCANNON: any;
  60691. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60692. setGravity(gravity: Vector3): void;
  60693. setTimeStep(timeStep: number): void;
  60694. getTimeStep(): number;
  60695. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60696. private _removeMarkedPhysicsBodiesFromWorld;
  60697. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60698. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60699. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60700. private _processChildMeshes;
  60701. removePhysicsBody(impostor: PhysicsImpostor): void;
  60702. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60703. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60704. private _addMaterial;
  60705. private _checkWithEpsilon;
  60706. private _createShape;
  60707. private _createHeightmap;
  60708. private _minus90X;
  60709. private _plus90X;
  60710. private _tmpPosition;
  60711. private _tmpDeltaPosition;
  60712. private _tmpUnityRotation;
  60713. private _updatePhysicsBodyTransformation;
  60714. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60715. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60716. isSupported(): boolean;
  60717. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60718. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60719. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60720. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60721. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60722. getBodyMass(impostor: PhysicsImpostor): number;
  60723. getBodyFriction(impostor: PhysicsImpostor): number;
  60724. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60725. getBodyRestitution(impostor: PhysicsImpostor): number;
  60726. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60727. sleepBody(impostor: PhysicsImpostor): void;
  60728. wakeUpBody(impostor: PhysicsImpostor): void;
  60729. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60730. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60731. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60732. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60733. getRadius(impostor: PhysicsImpostor): number;
  60734. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60735. dispose(): void;
  60736. private _extendNamespace;
  60737. /**
  60738. * Does a raycast in the physics world
  60739. * @param from when should the ray start?
  60740. * @param to when should the ray end?
  60741. * @returns PhysicsRaycastResult
  60742. */
  60743. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60744. }
  60745. }
  60746. declare module BABYLON {
  60747. /** @hidden */
  60748. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60749. private _useDeltaForWorldStep;
  60750. world: any;
  60751. name: string;
  60752. BJSOIMO: any;
  60753. private _raycastResult;
  60754. private _fixedTimeStep;
  60755. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60756. setGravity(gravity: Vector3): void;
  60757. setTimeStep(timeStep: number): void;
  60758. getTimeStep(): number;
  60759. private _tmpImpostorsArray;
  60760. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60761. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60762. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60763. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60764. private _tmpPositionVector;
  60765. removePhysicsBody(impostor: PhysicsImpostor): void;
  60766. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60767. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60768. isSupported(): boolean;
  60769. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60770. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60771. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60772. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60773. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60774. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60775. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60776. getBodyMass(impostor: PhysicsImpostor): number;
  60777. getBodyFriction(impostor: PhysicsImpostor): number;
  60778. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60779. getBodyRestitution(impostor: PhysicsImpostor): number;
  60780. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60781. sleepBody(impostor: PhysicsImpostor): void;
  60782. wakeUpBody(impostor: PhysicsImpostor): void;
  60783. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60784. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60785. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60786. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60787. getRadius(impostor: PhysicsImpostor): number;
  60788. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60789. dispose(): void;
  60790. /**
  60791. * Does a raycast in the physics world
  60792. * @param from when should the ray start?
  60793. * @param to when should the ray end?
  60794. * @returns PhysicsRaycastResult
  60795. */
  60796. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60797. }
  60798. }
  60799. declare module BABYLON {
  60800. /**
  60801. * AmmoJS Physics plugin
  60802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60803. * @see https://github.com/kripken/ammo.js/
  60804. */
  60805. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60806. private _useDeltaForWorldStep;
  60807. /**
  60808. * Reference to the Ammo library
  60809. */
  60810. bjsAMMO: any;
  60811. /**
  60812. * Created ammoJS world which physics bodies are added to
  60813. */
  60814. world: any;
  60815. /**
  60816. * Name of the plugin
  60817. */
  60818. name: string;
  60819. private _timeStep;
  60820. private _fixedTimeStep;
  60821. private _maxSteps;
  60822. private _tmpQuaternion;
  60823. private _tmpAmmoTransform;
  60824. private _tmpAmmoQuaternion;
  60825. private _tmpAmmoConcreteContactResultCallback;
  60826. private _collisionConfiguration;
  60827. private _dispatcher;
  60828. private _overlappingPairCache;
  60829. private _solver;
  60830. private _softBodySolver;
  60831. private _tmpAmmoVectorA;
  60832. private _tmpAmmoVectorB;
  60833. private _tmpAmmoVectorC;
  60834. private _tmpAmmoVectorD;
  60835. private _tmpContactCallbackResult;
  60836. private _tmpAmmoVectorRCA;
  60837. private _tmpAmmoVectorRCB;
  60838. private _raycastResult;
  60839. private static readonly DISABLE_COLLISION_FLAG;
  60840. private static readonly KINEMATIC_FLAG;
  60841. private static readonly DISABLE_DEACTIVATION_FLAG;
  60842. /**
  60843. * Initializes the ammoJS plugin
  60844. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60845. * @param ammoInjection can be used to inject your own ammo reference
  60846. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60847. */
  60848. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60849. /**
  60850. * Sets the gravity of the physics world (m/(s^2))
  60851. * @param gravity Gravity to set
  60852. */
  60853. setGravity(gravity: Vector3): void;
  60854. /**
  60855. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60856. * @param timeStep timestep to use in seconds
  60857. */
  60858. setTimeStep(timeStep: number): void;
  60859. /**
  60860. * 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)
  60861. * @param fixedTimeStep fixedTimeStep to use in seconds
  60862. */
  60863. setFixedTimeStep(fixedTimeStep: number): void;
  60864. /**
  60865. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60866. * @param maxSteps the maximum number of steps by the physics engine per frame
  60867. */
  60868. setMaxSteps(maxSteps: number): void;
  60869. /**
  60870. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60871. * @returns the current timestep in seconds
  60872. */
  60873. getTimeStep(): number;
  60874. /**
  60875. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60876. */
  60877. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60878. private _isImpostorInContact;
  60879. private _isImpostorPairInContact;
  60880. private _stepSimulation;
  60881. /**
  60882. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60883. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60884. * After the step the babylon meshes are set to the position of the physics imposters
  60885. * @param delta amount of time to step forward
  60886. * @param impostors array of imposters to update before/after the step
  60887. */
  60888. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60889. /**
  60890. * Update babylon mesh to match physics world object
  60891. * @param impostor imposter to match
  60892. */
  60893. private _afterSoftStep;
  60894. /**
  60895. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60896. * @param impostor imposter to match
  60897. */
  60898. private _ropeStep;
  60899. /**
  60900. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60901. * @param impostor imposter to match
  60902. */
  60903. private _softbodyOrClothStep;
  60904. private _tmpMatrix;
  60905. /**
  60906. * Applies an impulse on the imposter
  60907. * @param impostor imposter to apply impulse to
  60908. * @param force amount of force to be applied to the imposter
  60909. * @param contactPoint the location to apply the impulse on the imposter
  60910. */
  60911. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60912. /**
  60913. * Applies a force on the imposter
  60914. * @param impostor imposter to apply force
  60915. * @param force amount of force to be applied to the imposter
  60916. * @param contactPoint the location to apply the force on the imposter
  60917. */
  60918. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60919. /**
  60920. * Creates a physics body using the plugin
  60921. * @param impostor the imposter to create the physics body on
  60922. */
  60923. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60924. /**
  60925. * Removes the physics body from the imposter and disposes of the body's memory
  60926. * @param impostor imposter to remove the physics body from
  60927. */
  60928. removePhysicsBody(impostor: PhysicsImpostor): void;
  60929. /**
  60930. * Generates a joint
  60931. * @param impostorJoint the imposter joint to create the joint with
  60932. */
  60933. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60934. /**
  60935. * Removes a joint
  60936. * @param impostorJoint the imposter joint to remove the joint from
  60937. */
  60938. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60939. private _addMeshVerts;
  60940. /**
  60941. * Initialise the soft body vertices to match its object's (mesh) vertices
  60942. * Softbody vertices (nodes) are in world space and to match this
  60943. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60944. * @param impostor to create the softbody for
  60945. */
  60946. private _softVertexData;
  60947. /**
  60948. * Create an impostor's soft body
  60949. * @param impostor to create the softbody for
  60950. */
  60951. private _createSoftbody;
  60952. /**
  60953. * Create cloth for an impostor
  60954. * @param impostor to create the softbody for
  60955. */
  60956. private _createCloth;
  60957. /**
  60958. * Create rope for an impostor
  60959. * @param impostor to create the softbody for
  60960. */
  60961. private _createRope;
  60962. /**
  60963. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60964. * @param impostor to create the custom physics shape for
  60965. */
  60966. private _createCustom;
  60967. private _addHullVerts;
  60968. private _createShape;
  60969. /**
  60970. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60971. * @param impostor imposter containing the physics body and babylon object
  60972. */
  60973. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60974. /**
  60975. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60976. * @param impostor imposter containing the physics body and babylon object
  60977. * @param newPosition new position
  60978. * @param newRotation new rotation
  60979. */
  60980. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60981. /**
  60982. * If this plugin is supported
  60983. * @returns true if its supported
  60984. */
  60985. isSupported(): boolean;
  60986. /**
  60987. * Sets the linear velocity of the physics body
  60988. * @param impostor imposter to set the velocity on
  60989. * @param velocity velocity to set
  60990. */
  60991. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60992. /**
  60993. * Sets the angular velocity of the physics body
  60994. * @param impostor imposter to set the velocity on
  60995. * @param velocity velocity to set
  60996. */
  60997. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60998. /**
  60999. * gets the linear velocity
  61000. * @param impostor imposter to get linear velocity from
  61001. * @returns linear velocity
  61002. */
  61003. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61004. /**
  61005. * gets the angular velocity
  61006. * @param impostor imposter to get angular velocity from
  61007. * @returns angular velocity
  61008. */
  61009. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61010. /**
  61011. * Sets the mass of physics body
  61012. * @param impostor imposter to set the mass on
  61013. * @param mass mass to set
  61014. */
  61015. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61016. /**
  61017. * Gets the mass of the physics body
  61018. * @param impostor imposter to get the mass from
  61019. * @returns mass
  61020. */
  61021. getBodyMass(impostor: PhysicsImpostor): number;
  61022. /**
  61023. * Gets friction of the impostor
  61024. * @param impostor impostor to get friction from
  61025. * @returns friction value
  61026. */
  61027. getBodyFriction(impostor: PhysicsImpostor): number;
  61028. /**
  61029. * Sets friction of the impostor
  61030. * @param impostor impostor to set friction on
  61031. * @param friction friction value
  61032. */
  61033. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61034. /**
  61035. * Gets restitution of the impostor
  61036. * @param impostor impostor to get restitution from
  61037. * @returns restitution value
  61038. */
  61039. getBodyRestitution(impostor: PhysicsImpostor): number;
  61040. /**
  61041. * Sets resitution of the impostor
  61042. * @param impostor impostor to set resitution on
  61043. * @param restitution resitution value
  61044. */
  61045. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61046. /**
  61047. * Gets pressure inside the impostor
  61048. * @param impostor impostor to get pressure from
  61049. * @returns pressure value
  61050. */
  61051. getBodyPressure(impostor: PhysicsImpostor): number;
  61052. /**
  61053. * Sets pressure inside a soft body impostor
  61054. * Cloth and rope must remain 0 pressure
  61055. * @param impostor impostor to set pressure on
  61056. * @param pressure pressure value
  61057. */
  61058. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61059. /**
  61060. * Gets stiffness of the impostor
  61061. * @param impostor impostor to get stiffness from
  61062. * @returns pressure value
  61063. */
  61064. getBodyStiffness(impostor: PhysicsImpostor): number;
  61065. /**
  61066. * Sets stiffness of the impostor
  61067. * @param impostor impostor to set stiffness on
  61068. * @param stiffness stiffness value from 0 to 1
  61069. */
  61070. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61071. /**
  61072. * Gets velocityIterations of the impostor
  61073. * @param impostor impostor to get velocity iterations from
  61074. * @returns velocityIterations value
  61075. */
  61076. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61077. /**
  61078. * Sets velocityIterations of the impostor
  61079. * @param impostor impostor to set velocity iterations on
  61080. * @param velocityIterations velocityIterations value
  61081. */
  61082. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61083. /**
  61084. * Gets positionIterations of the impostor
  61085. * @param impostor impostor to get position iterations from
  61086. * @returns positionIterations value
  61087. */
  61088. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61089. /**
  61090. * Sets positionIterations of the impostor
  61091. * @param impostor impostor to set position on
  61092. * @param positionIterations positionIterations value
  61093. */
  61094. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61095. /**
  61096. * Append an anchor to a cloth object
  61097. * @param impostor is the cloth impostor to add anchor to
  61098. * @param otherImpostor is the rigid impostor to anchor to
  61099. * @param width ratio across width from 0 to 1
  61100. * @param height ratio up height from 0 to 1
  61101. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61102. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61103. */
  61104. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61105. /**
  61106. * Append an hook to a rope object
  61107. * @param impostor is the rope impostor to add hook to
  61108. * @param otherImpostor is the rigid impostor to hook to
  61109. * @param length ratio along the rope from 0 to 1
  61110. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61111. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61112. */
  61113. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61114. /**
  61115. * Sleeps the physics body and stops it from being active
  61116. * @param impostor impostor to sleep
  61117. */
  61118. sleepBody(impostor: PhysicsImpostor): void;
  61119. /**
  61120. * Activates the physics body
  61121. * @param impostor impostor to activate
  61122. */
  61123. wakeUpBody(impostor: PhysicsImpostor): void;
  61124. /**
  61125. * Updates the distance parameters of the joint
  61126. * @param joint joint to update
  61127. * @param maxDistance maximum distance of the joint
  61128. * @param minDistance minimum distance of the joint
  61129. */
  61130. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61131. /**
  61132. * Sets a motor on the joint
  61133. * @param joint joint to set motor on
  61134. * @param speed speed of the motor
  61135. * @param maxForce maximum force of the motor
  61136. * @param motorIndex index of the motor
  61137. */
  61138. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61139. /**
  61140. * Sets the motors limit
  61141. * @param joint joint to set limit on
  61142. * @param upperLimit upper limit
  61143. * @param lowerLimit lower limit
  61144. */
  61145. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61146. /**
  61147. * Syncs the position and rotation of a mesh with the impostor
  61148. * @param mesh mesh to sync
  61149. * @param impostor impostor to update the mesh with
  61150. */
  61151. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61152. /**
  61153. * Gets the radius of the impostor
  61154. * @param impostor impostor to get radius from
  61155. * @returns the radius
  61156. */
  61157. getRadius(impostor: PhysicsImpostor): number;
  61158. /**
  61159. * Gets the box size of the impostor
  61160. * @param impostor impostor to get box size from
  61161. * @param result the resulting box size
  61162. */
  61163. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61164. /**
  61165. * Disposes of the impostor
  61166. */
  61167. dispose(): void;
  61168. /**
  61169. * Does a raycast in the physics world
  61170. * @param from when should the ray start?
  61171. * @param to when should the ray end?
  61172. * @returns PhysicsRaycastResult
  61173. */
  61174. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61175. }
  61176. }
  61177. declare module BABYLON {
  61178. interface AbstractScene {
  61179. /**
  61180. * The list of reflection probes added to the scene
  61181. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61182. */
  61183. reflectionProbes: Array<ReflectionProbe>;
  61184. /**
  61185. * Removes the given reflection probe from this scene.
  61186. * @param toRemove The reflection probe to remove
  61187. * @returns The index of the removed reflection probe
  61188. */
  61189. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61190. /**
  61191. * Adds the given reflection probe to this scene.
  61192. * @param newReflectionProbe The reflection probe to add
  61193. */
  61194. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61195. }
  61196. /**
  61197. * Class used to generate realtime reflection / refraction cube textures
  61198. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61199. */
  61200. export class ReflectionProbe {
  61201. /** defines the name of the probe */
  61202. name: string;
  61203. private _scene;
  61204. private _renderTargetTexture;
  61205. private _projectionMatrix;
  61206. private _viewMatrix;
  61207. private _target;
  61208. private _add;
  61209. private _attachedMesh;
  61210. private _invertYAxis;
  61211. /** Gets or sets probe position (center of the cube map) */
  61212. position: Vector3;
  61213. /**
  61214. * Creates a new reflection probe
  61215. * @param name defines the name of the probe
  61216. * @param size defines the texture resolution (for each face)
  61217. * @param scene defines the hosting scene
  61218. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61219. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61220. */
  61221. constructor(
  61222. /** defines the name of the probe */
  61223. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61224. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61225. get samples(): number;
  61226. set samples(value: number);
  61227. /** Gets or sets the refresh rate to use (on every frame by default) */
  61228. get refreshRate(): number;
  61229. set refreshRate(value: number);
  61230. /**
  61231. * Gets the hosting scene
  61232. * @returns a Scene
  61233. */
  61234. getScene(): Scene;
  61235. /** Gets the internal CubeTexture used to render to */
  61236. get cubeTexture(): RenderTargetTexture;
  61237. /** Gets the list of meshes to render */
  61238. get renderList(): Nullable<AbstractMesh[]>;
  61239. /**
  61240. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61241. * @param mesh defines the mesh to attach to
  61242. */
  61243. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61244. /**
  61245. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61246. * @param renderingGroupId The rendering group id corresponding to its index
  61247. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61248. */
  61249. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61250. /**
  61251. * Clean all associated resources
  61252. */
  61253. dispose(): void;
  61254. /**
  61255. * Converts the reflection probe information to a readable string for debug purpose.
  61256. * @param fullDetails Supports for multiple levels of logging within scene loading
  61257. * @returns the human readable reflection probe info
  61258. */
  61259. toString(fullDetails?: boolean): string;
  61260. /**
  61261. * Get the class name of the relfection probe.
  61262. * @returns "ReflectionProbe"
  61263. */
  61264. getClassName(): string;
  61265. /**
  61266. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61267. * @returns The JSON representation of the texture
  61268. */
  61269. serialize(): any;
  61270. /**
  61271. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61272. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61273. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61274. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61275. * @returns The parsed reflection probe if successful
  61276. */
  61277. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61278. }
  61279. }
  61280. declare module BABYLON {
  61281. /** @hidden */
  61282. export var _BabylonLoaderRegistered: boolean;
  61283. /**
  61284. * Helps setting up some configuration for the babylon file loader.
  61285. */
  61286. export class BabylonFileLoaderConfiguration {
  61287. /**
  61288. * The loader does not allow injecting custom physix engine into the plugins.
  61289. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61290. * So you could set this variable to your engine import to make it work.
  61291. */
  61292. static LoaderInjectedPhysicsEngine: any;
  61293. }
  61294. }
  61295. declare module BABYLON {
  61296. /**
  61297. * The Physically based simple base material of BJS.
  61298. *
  61299. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61300. * It is used as the base class for both the specGloss and metalRough conventions.
  61301. */
  61302. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61303. /**
  61304. * Number of Simultaneous lights allowed on the material.
  61305. */
  61306. maxSimultaneousLights: number;
  61307. /**
  61308. * If sets to true, disables all the lights affecting the material.
  61309. */
  61310. disableLighting: boolean;
  61311. /**
  61312. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61313. */
  61314. environmentTexture: BaseTexture;
  61315. /**
  61316. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61317. */
  61318. invertNormalMapX: boolean;
  61319. /**
  61320. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61321. */
  61322. invertNormalMapY: boolean;
  61323. /**
  61324. * Normal map used in the model.
  61325. */
  61326. normalTexture: BaseTexture;
  61327. /**
  61328. * Emissivie color used to self-illuminate the model.
  61329. */
  61330. emissiveColor: Color3;
  61331. /**
  61332. * Emissivie texture used to self-illuminate the model.
  61333. */
  61334. emissiveTexture: BaseTexture;
  61335. /**
  61336. * Occlusion Channel Strenght.
  61337. */
  61338. occlusionStrength: number;
  61339. /**
  61340. * Occlusion Texture of the material (adding extra occlusion effects).
  61341. */
  61342. occlusionTexture: BaseTexture;
  61343. /**
  61344. * Defines the alpha limits in alpha test mode.
  61345. */
  61346. alphaCutOff: number;
  61347. /**
  61348. * Gets the current double sided mode.
  61349. */
  61350. get doubleSided(): boolean;
  61351. /**
  61352. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61353. */
  61354. set doubleSided(value: boolean);
  61355. /**
  61356. * Stores the pre-calculated light information of a mesh in a texture.
  61357. */
  61358. lightmapTexture: BaseTexture;
  61359. /**
  61360. * If true, the light map contains occlusion information instead of lighting info.
  61361. */
  61362. useLightmapAsShadowmap: boolean;
  61363. /**
  61364. * Instantiates a new PBRMaterial instance.
  61365. *
  61366. * @param name The material name
  61367. * @param scene The scene the material will be use in.
  61368. */
  61369. constructor(name: string, scene: Scene);
  61370. getClassName(): string;
  61371. }
  61372. }
  61373. declare module BABYLON {
  61374. /**
  61375. * The PBR material of BJS following the metal roughness convention.
  61376. *
  61377. * This fits to the PBR convention in the GLTF definition:
  61378. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61379. */
  61380. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61381. /**
  61382. * The base color has two different interpretations depending on the value of metalness.
  61383. * When the material is a metal, the base color is the specific measured reflectance value
  61384. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61385. * of the material.
  61386. */
  61387. baseColor: Color3;
  61388. /**
  61389. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61390. * well as opacity information in the alpha channel.
  61391. */
  61392. baseTexture: BaseTexture;
  61393. /**
  61394. * Specifies the metallic scalar value of the material.
  61395. * Can also be used to scale the metalness values of the metallic texture.
  61396. */
  61397. metallic: number;
  61398. /**
  61399. * Specifies the roughness scalar value of the material.
  61400. * Can also be used to scale the roughness values of the metallic texture.
  61401. */
  61402. roughness: number;
  61403. /**
  61404. * Texture containing both the metallic value in the B channel and the
  61405. * roughness value in the G channel to keep better precision.
  61406. */
  61407. metallicRoughnessTexture: BaseTexture;
  61408. /**
  61409. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61410. *
  61411. * @param name The material name
  61412. * @param scene The scene the material will be use in.
  61413. */
  61414. constructor(name: string, scene: Scene);
  61415. /**
  61416. * Return the currrent class name of the material.
  61417. */
  61418. getClassName(): string;
  61419. /**
  61420. * Makes a duplicate of the current material.
  61421. * @param name - name to use for the new material.
  61422. */
  61423. clone(name: string): PBRMetallicRoughnessMaterial;
  61424. /**
  61425. * Serialize the material to a parsable JSON object.
  61426. */
  61427. serialize(): any;
  61428. /**
  61429. * Parses a JSON object correponding to the serialize function.
  61430. */
  61431. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61432. }
  61433. }
  61434. declare module BABYLON {
  61435. /**
  61436. * The PBR material of BJS following the specular glossiness convention.
  61437. *
  61438. * This fits to the PBR convention in the GLTF definition:
  61439. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61440. */
  61441. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61442. /**
  61443. * Specifies the diffuse color of the material.
  61444. */
  61445. diffuseColor: Color3;
  61446. /**
  61447. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61448. * channel.
  61449. */
  61450. diffuseTexture: BaseTexture;
  61451. /**
  61452. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61453. */
  61454. specularColor: Color3;
  61455. /**
  61456. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61457. */
  61458. glossiness: number;
  61459. /**
  61460. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61461. */
  61462. specularGlossinessTexture: BaseTexture;
  61463. /**
  61464. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61465. *
  61466. * @param name The material name
  61467. * @param scene The scene the material will be use in.
  61468. */
  61469. constructor(name: string, scene: Scene);
  61470. /**
  61471. * Return the currrent class name of the material.
  61472. */
  61473. getClassName(): string;
  61474. /**
  61475. * Makes a duplicate of the current material.
  61476. * @param name - name to use for the new material.
  61477. */
  61478. clone(name: string): PBRSpecularGlossinessMaterial;
  61479. /**
  61480. * Serialize the material to a parsable JSON object.
  61481. */
  61482. serialize(): any;
  61483. /**
  61484. * Parses a JSON object correponding to the serialize function.
  61485. */
  61486. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61487. }
  61488. }
  61489. declare module BABYLON {
  61490. /**
  61491. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61492. * It can help converting any input color in a desired output one. This can then be used to create effects
  61493. * from sepia, black and white to sixties or futuristic rendering...
  61494. *
  61495. * The only supported format is currently 3dl.
  61496. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61497. */
  61498. export class ColorGradingTexture extends BaseTexture {
  61499. /**
  61500. * The texture URL.
  61501. */
  61502. url: string;
  61503. /**
  61504. * Empty line regex stored for GC.
  61505. */
  61506. private static _noneEmptyLineRegex;
  61507. private _textureMatrix;
  61508. private _onLoad;
  61509. /**
  61510. * Instantiates a ColorGradingTexture from the following parameters.
  61511. *
  61512. * @param url The location of the color gradind data (currently only supporting 3dl)
  61513. * @param sceneOrEngine The scene or engine the texture will be used in
  61514. * @param onLoad defines a callback triggered when the texture has been loaded
  61515. */
  61516. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61517. /**
  61518. * Fires the onload event from the constructor if requested.
  61519. */
  61520. private _triggerOnLoad;
  61521. /**
  61522. * Returns the texture matrix used in most of the material.
  61523. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61524. */
  61525. getTextureMatrix(): Matrix;
  61526. /**
  61527. * Occurs when the file being loaded is a .3dl LUT file.
  61528. */
  61529. private load3dlTexture;
  61530. /**
  61531. * Starts the loading process of the texture.
  61532. */
  61533. private loadTexture;
  61534. /**
  61535. * Clones the color gradind texture.
  61536. */
  61537. clone(): ColorGradingTexture;
  61538. /**
  61539. * Called during delayed load for textures.
  61540. */
  61541. delayLoad(): void;
  61542. /**
  61543. * Parses a color grading texture serialized by Babylon.
  61544. * @param parsedTexture The texture information being parsedTexture
  61545. * @param scene The scene to load the texture in
  61546. * @param rootUrl The root url of the data assets to load
  61547. * @return A color gradind texture
  61548. */
  61549. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61550. /**
  61551. * Serializes the LUT texture to json format.
  61552. */
  61553. serialize(): any;
  61554. }
  61555. }
  61556. declare module BABYLON {
  61557. /**
  61558. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61559. */
  61560. export class EquiRectangularCubeTexture extends BaseTexture {
  61561. /** The six faces of the cube. */
  61562. private static _FacesMapping;
  61563. private _noMipmap;
  61564. private _onLoad;
  61565. private _onError;
  61566. /** The size of the cubemap. */
  61567. private _size;
  61568. /** The buffer of the image. */
  61569. private _buffer;
  61570. /** The width of the input image. */
  61571. private _width;
  61572. /** The height of the input image. */
  61573. private _height;
  61574. /** The URL to the image. */
  61575. url: string;
  61576. /**
  61577. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61578. * @param url The location of the image
  61579. * @param scene The scene the texture will be used in
  61580. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61581. * @param noMipmap Forces to not generate the mipmap if true
  61582. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61583. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61584. * @param onLoad — defines a callback called when texture is loaded
  61585. * @param onError — defines a callback called if there is an error
  61586. */
  61587. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61588. /**
  61589. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61590. */
  61591. private loadImage;
  61592. /**
  61593. * Convert the image buffer into a cubemap and create a CubeTexture.
  61594. */
  61595. private loadTexture;
  61596. /**
  61597. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61598. * @param buffer The ArrayBuffer that should be converted.
  61599. * @returns The buffer as Float32Array.
  61600. */
  61601. private getFloat32ArrayFromArrayBuffer;
  61602. /**
  61603. * Get the current class name of the texture useful for serialization or dynamic coding.
  61604. * @returns "EquiRectangularCubeTexture"
  61605. */
  61606. getClassName(): string;
  61607. /**
  61608. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61609. * @returns A clone of the current EquiRectangularCubeTexture.
  61610. */
  61611. clone(): EquiRectangularCubeTexture;
  61612. }
  61613. }
  61614. declare module BABYLON {
  61615. /**
  61616. * Defines the options related to the creation of an HtmlElementTexture
  61617. */
  61618. export interface IHtmlElementTextureOptions {
  61619. /**
  61620. * Defines wether mip maps should be created or not.
  61621. */
  61622. generateMipMaps?: boolean;
  61623. /**
  61624. * Defines the sampling mode of the texture.
  61625. */
  61626. samplingMode?: number;
  61627. /**
  61628. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61629. */
  61630. engine: Nullable<ThinEngine>;
  61631. /**
  61632. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61633. */
  61634. scene: Nullable<Scene>;
  61635. }
  61636. /**
  61637. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61638. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61639. * is automatically managed.
  61640. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61641. * in your application.
  61642. *
  61643. * As the update is not automatic, you need to call them manually.
  61644. */
  61645. export class HtmlElementTexture extends BaseTexture {
  61646. /**
  61647. * The texture URL.
  61648. */
  61649. element: HTMLVideoElement | HTMLCanvasElement;
  61650. private static readonly DefaultOptions;
  61651. private _textureMatrix;
  61652. private _isVideo;
  61653. private _generateMipMaps;
  61654. private _samplingMode;
  61655. /**
  61656. * Instantiates a HtmlElementTexture from the following parameters.
  61657. *
  61658. * @param name Defines the name of the texture
  61659. * @param element Defines the video or canvas the texture is filled with
  61660. * @param options Defines the other none mandatory texture creation options
  61661. */
  61662. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61663. private _createInternalTexture;
  61664. /**
  61665. * Returns the texture matrix used in most of the material.
  61666. */
  61667. getTextureMatrix(): Matrix;
  61668. /**
  61669. * Updates the content of the texture.
  61670. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61671. */
  61672. update(invertY?: Nullable<boolean>): void;
  61673. }
  61674. }
  61675. declare module BABYLON {
  61676. /**
  61677. * Based on jsTGALoader - Javascript loader for TGA file
  61678. * By Vincent Thibault
  61679. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61680. */
  61681. export class TGATools {
  61682. private static _TYPE_INDEXED;
  61683. private static _TYPE_RGB;
  61684. private static _TYPE_GREY;
  61685. private static _TYPE_RLE_INDEXED;
  61686. private static _TYPE_RLE_RGB;
  61687. private static _TYPE_RLE_GREY;
  61688. private static _ORIGIN_MASK;
  61689. private static _ORIGIN_SHIFT;
  61690. private static _ORIGIN_BL;
  61691. private static _ORIGIN_BR;
  61692. private static _ORIGIN_UL;
  61693. private static _ORIGIN_UR;
  61694. /**
  61695. * Gets the header of a TGA file
  61696. * @param data defines the TGA data
  61697. * @returns the header
  61698. */
  61699. static GetTGAHeader(data: Uint8Array): any;
  61700. /**
  61701. * Uploads TGA content to a Babylon Texture
  61702. * @hidden
  61703. */
  61704. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61705. /** @hidden */
  61706. 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;
  61707. /** @hidden */
  61708. 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;
  61709. /** @hidden */
  61710. 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;
  61711. /** @hidden */
  61712. 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;
  61713. /** @hidden */
  61714. 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;
  61715. /** @hidden */
  61716. 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;
  61717. }
  61718. }
  61719. declare module BABYLON {
  61720. /**
  61721. * Implementation of the TGA Texture Loader.
  61722. * @hidden
  61723. */
  61724. export class _TGATextureLoader implements IInternalTextureLoader {
  61725. /**
  61726. * Defines wether the loader supports cascade loading the different faces.
  61727. */
  61728. readonly supportCascades: boolean;
  61729. /**
  61730. * This returns if the loader support the current file information.
  61731. * @param extension defines the file extension of the file being loaded
  61732. * @returns true if the loader can load the specified file
  61733. */
  61734. canLoad(extension: string): boolean;
  61735. /**
  61736. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61737. * @param data contains the texture data
  61738. * @param texture defines the BabylonJS internal texture
  61739. * @param createPolynomials will be true if polynomials have been requested
  61740. * @param onLoad defines the callback to trigger once the texture is ready
  61741. * @param onError defines the callback to trigger in case of error
  61742. */
  61743. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61744. /**
  61745. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61746. * @param data contains the texture data
  61747. * @param texture defines the BabylonJS internal texture
  61748. * @param callback defines the method to call once ready to upload
  61749. */
  61750. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61751. }
  61752. }
  61753. declare module BABYLON {
  61754. /**
  61755. * Info about the .basis files
  61756. */
  61757. class BasisFileInfo {
  61758. /**
  61759. * If the file has alpha
  61760. */
  61761. hasAlpha: boolean;
  61762. /**
  61763. * Info about each image of the basis file
  61764. */
  61765. images: Array<{
  61766. levels: Array<{
  61767. width: number;
  61768. height: number;
  61769. transcodedPixels: ArrayBufferView;
  61770. }>;
  61771. }>;
  61772. }
  61773. /**
  61774. * Result of transcoding a basis file
  61775. */
  61776. class TranscodeResult {
  61777. /**
  61778. * Info about the .basis file
  61779. */
  61780. fileInfo: BasisFileInfo;
  61781. /**
  61782. * Format to use when loading the file
  61783. */
  61784. format: number;
  61785. }
  61786. /**
  61787. * Configuration options for the Basis transcoder
  61788. */
  61789. export class BasisTranscodeConfiguration {
  61790. /**
  61791. * Supported compression formats used to determine the supported output format of the transcoder
  61792. */
  61793. supportedCompressionFormats?: {
  61794. /**
  61795. * etc1 compression format
  61796. */
  61797. etc1?: boolean;
  61798. /**
  61799. * s3tc compression format
  61800. */
  61801. s3tc?: boolean;
  61802. /**
  61803. * pvrtc compression format
  61804. */
  61805. pvrtc?: boolean;
  61806. /**
  61807. * etc2 compression format
  61808. */
  61809. etc2?: boolean;
  61810. };
  61811. /**
  61812. * If mipmap levels should be loaded for transcoded images (Default: true)
  61813. */
  61814. loadMipmapLevels?: boolean;
  61815. /**
  61816. * Index of a single image to load (Default: all images)
  61817. */
  61818. loadSingleImage?: number;
  61819. }
  61820. /**
  61821. * Used to load .Basis files
  61822. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61823. */
  61824. export class BasisTools {
  61825. private static _IgnoreSupportedFormats;
  61826. /**
  61827. * URL to use when loading the basis transcoder
  61828. */
  61829. static JSModuleURL: string;
  61830. /**
  61831. * URL to use when loading the wasm module for the transcoder
  61832. */
  61833. static WasmModuleURL: string;
  61834. /**
  61835. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61836. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61837. * @returns internal format corresponding to the Basis format
  61838. */
  61839. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61840. private static _WorkerPromise;
  61841. private static _Worker;
  61842. private static _actionId;
  61843. private static _CreateWorkerAsync;
  61844. /**
  61845. * Transcodes a loaded image file to compressed pixel data
  61846. * @param data image data to transcode
  61847. * @param config configuration options for the transcoding
  61848. * @returns a promise resulting in the transcoded image
  61849. */
  61850. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61851. /**
  61852. * Loads a texture from the transcode result
  61853. * @param texture texture load to
  61854. * @param transcodeResult the result of transcoding the basis file to load from
  61855. */
  61856. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61857. }
  61858. }
  61859. declare module BABYLON {
  61860. /**
  61861. * Loader for .basis file format
  61862. */
  61863. export class _BasisTextureLoader implements IInternalTextureLoader {
  61864. /**
  61865. * Defines whether the loader supports cascade loading the different faces.
  61866. */
  61867. readonly supportCascades: boolean;
  61868. /**
  61869. * This returns if the loader support the current file information.
  61870. * @param extension defines the file extension of the file being loaded
  61871. * @returns true if the loader can load the specified file
  61872. */
  61873. canLoad(extension: string): boolean;
  61874. /**
  61875. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61876. * @param data contains the texture data
  61877. * @param texture defines the BabylonJS internal texture
  61878. * @param createPolynomials will be true if polynomials have been requested
  61879. * @param onLoad defines the callback to trigger once the texture is ready
  61880. * @param onError defines the callback to trigger in case of error
  61881. */
  61882. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61883. /**
  61884. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61885. * @param data contains the texture data
  61886. * @param texture defines the BabylonJS internal texture
  61887. * @param callback defines the method to call once ready to upload
  61888. */
  61889. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61890. }
  61891. }
  61892. declare module BABYLON {
  61893. /**
  61894. * Defines the basic options interface of a TexturePacker Frame
  61895. */
  61896. export interface ITexturePackerFrame {
  61897. /**
  61898. * The frame ID
  61899. */
  61900. id: number;
  61901. /**
  61902. * The frames Scale
  61903. */
  61904. scale: Vector2;
  61905. /**
  61906. * The Frames offset
  61907. */
  61908. offset: Vector2;
  61909. }
  61910. /**
  61911. * This is a support class for frame Data on texture packer sets.
  61912. */
  61913. export class TexturePackerFrame implements ITexturePackerFrame {
  61914. /**
  61915. * The frame ID
  61916. */
  61917. id: number;
  61918. /**
  61919. * The frames Scale
  61920. */
  61921. scale: Vector2;
  61922. /**
  61923. * The Frames offset
  61924. */
  61925. offset: Vector2;
  61926. /**
  61927. * Initializes a texture package frame.
  61928. * @param id The numerical frame identifier
  61929. * @param scale Scalar Vector2 for UV frame
  61930. * @param offset Vector2 for the frame position in UV units.
  61931. * @returns TexturePackerFrame
  61932. */
  61933. constructor(id: number, scale: Vector2, offset: Vector2);
  61934. }
  61935. }
  61936. declare module BABYLON {
  61937. /**
  61938. * Defines the basic options interface of a TexturePacker
  61939. */
  61940. export interface ITexturePackerOptions {
  61941. /**
  61942. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61943. */
  61944. map?: string[];
  61945. /**
  61946. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61947. */
  61948. uvsIn?: string;
  61949. /**
  61950. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61951. */
  61952. uvsOut?: string;
  61953. /**
  61954. * number representing the layout style. Defaults to LAYOUT_STRIP
  61955. */
  61956. layout?: number;
  61957. /**
  61958. * number of columns if using custom column count layout(2). This defaults to 4.
  61959. */
  61960. colnum?: number;
  61961. /**
  61962. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61963. */
  61964. updateInputMeshes?: boolean;
  61965. /**
  61966. * boolean flag to dispose all the source textures. Defaults to true.
  61967. */
  61968. disposeSources?: boolean;
  61969. /**
  61970. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61971. */
  61972. fillBlanks?: boolean;
  61973. /**
  61974. * string value representing the context fill style color. Defaults to 'black'.
  61975. */
  61976. customFillColor?: string;
  61977. /**
  61978. * Width and Height Value of each Frame in the TexturePacker Sets
  61979. */
  61980. frameSize?: number;
  61981. /**
  61982. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61983. */
  61984. paddingRatio?: number;
  61985. /**
  61986. * Number that declares the fill method for the padding gutter.
  61987. */
  61988. paddingMode?: number;
  61989. /**
  61990. * If in SUBUV_COLOR padding mode what color to use.
  61991. */
  61992. paddingColor?: Color3 | Color4;
  61993. }
  61994. /**
  61995. * Defines the basic interface of a TexturePacker JSON File
  61996. */
  61997. export interface ITexturePackerJSON {
  61998. /**
  61999. * The frame ID
  62000. */
  62001. name: string;
  62002. /**
  62003. * The base64 channel data
  62004. */
  62005. sets: any;
  62006. /**
  62007. * The options of the Packer
  62008. */
  62009. options: ITexturePackerOptions;
  62010. /**
  62011. * The frame data of the Packer
  62012. */
  62013. frames: Array<number>;
  62014. }
  62015. /**
  62016. * This is a support class that generates a series of packed texture sets.
  62017. * @see https://doc.babylonjs.com/babylon101/materials
  62018. */
  62019. export class TexturePacker {
  62020. /** Packer Layout Constant 0 */
  62021. static readonly LAYOUT_STRIP: number;
  62022. /** Packer Layout Constant 1 */
  62023. static readonly LAYOUT_POWER2: number;
  62024. /** Packer Layout Constant 2 */
  62025. static readonly LAYOUT_COLNUM: number;
  62026. /** Packer Layout Constant 0 */
  62027. static readonly SUBUV_WRAP: number;
  62028. /** Packer Layout Constant 1 */
  62029. static readonly SUBUV_EXTEND: number;
  62030. /** Packer Layout Constant 2 */
  62031. static readonly SUBUV_COLOR: number;
  62032. /** The Name of the Texture Package */
  62033. name: string;
  62034. /** The scene scope of the TexturePacker */
  62035. scene: Scene;
  62036. /** The Meshes to target */
  62037. meshes: AbstractMesh[];
  62038. /** Arguments passed with the Constructor */
  62039. options: ITexturePackerOptions;
  62040. /** The promise that is started upon initialization */
  62041. promise: Nullable<Promise<TexturePacker | string>>;
  62042. /** The Container object for the channel sets that are generated */
  62043. sets: object;
  62044. /** The Container array for the frames that are generated */
  62045. frames: TexturePackerFrame[];
  62046. /** The expected number of textures the system is parsing. */
  62047. private _expecting;
  62048. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62049. private _paddingValue;
  62050. /**
  62051. * Initializes a texture package series from an array of meshes or a single mesh.
  62052. * @param name The name of the package
  62053. * @param meshes The target meshes to compose the package from
  62054. * @param options The arguments that texture packer should follow while building.
  62055. * @param scene The scene which the textures are scoped to.
  62056. * @returns TexturePacker
  62057. */
  62058. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62059. /**
  62060. * Starts the package process
  62061. * @param resolve The promises resolution function
  62062. * @returns TexturePacker
  62063. */
  62064. private _createFrames;
  62065. /**
  62066. * Calculates the Size of the Channel Sets
  62067. * @returns Vector2
  62068. */
  62069. private _calculateSize;
  62070. /**
  62071. * Calculates the UV data for the frames.
  62072. * @param baseSize the base frameSize
  62073. * @param padding the base frame padding
  62074. * @param dtSize size of the Dynamic Texture for that channel
  62075. * @param dtUnits is 1/dtSize
  62076. * @param update flag to update the input meshes
  62077. */
  62078. private _calculateMeshUVFrames;
  62079. /**
  62080. * Calculates the frames Offset.
  62081. * @param index of the frame
  62082. * @returns Vector2
  62083. */
  62084. private _getFrameOffset;
  62085. /**
  62086. * Updates a Mesh to the frame data
  62087. * @param mesh that is the target
  62088. * @param frameID or the frame index
  62089. */
  62090. private _updateMeshUV;
  62091. /**
  62092. * Updates a Meshes materials to use the texture packer channels
  62093. * @param m is the mesh to target
  62094. * @param force all channels on the packer to be set.
  62095. */
  62096. private _updateTextureReferences;
  62097. /**
  62098. * Public method to set a Mesh to a frame
  62099. * @param m that is the target
  62100. * @param frameID or the frame index
  62101. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62102. */
  62103. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62104. /**
  62105. * Starts the async promise to compile the texture packer.
  62106. * @returns Promise<void>
  62107. */
  62108. processAsync(): Promise<void>;
  62109. /**
  62110. * Disposes all textures associated with this packer
  62111. */
  62112. dispose(): void;
  62113. /**
  62114. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62115. * @param imageType is the image type to use.
  62116. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62117. */
  62118. download(imageType?: string, quality?: number): void;
  62119. /**
  62120. * Public method to load a texturePacker JSON file.
  62121. * @param data of the JSON file in string format.
  62122. */
  62123. updateFromJSON(data: string): void;
  62124. }
  62125. }
  62126. declare module BABYLON {
  62127. /**
  62128. * 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.
  62129. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62130. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62131. */
  62132. export class CustomProceduralTexture extends ProceduralTexture {
  62133. private _animate;
  62134. private _time;
  62135. private _config;
  62136. private _texturePath;
  62137. /**
  62138. * Instantiates a new Custom Procedural Texture.
  62139. * 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.
  62140. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62141. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62142. * @param name Define the name of the texture
  62143. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62144. * @param size Define the size of the texture to create
  62145. * @param scene Define the scene the texture belongs to
  62146. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62147. * @param generateMipMaps Define if the texture should creates mip maps or not
  62148. */
  62149. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62150. private _loadJson;
  62151. /**
  62152. * Is the texture ready to be used ? (rendered at least once)
  62153. * @returns true if ready, otherwise, false.
  62154. */
  62155. isReady(): boolean;
  62156. /**
  62157. * Render the texture to its associated render target.
  62158. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62159. */
  62160. render(useCameraPostProcess?: boolean): void;
  62161. /**
  62162. * Update the list of dependant textures samplers in the shader.
  62163. */
  62164. updateTextures(): void;
  62165. /**
  62166. * Update the uniform values of the procedural texture in the shader.
  62167. */
  62168. updateShaderUniforms(): void;
  62169. /**
  62170. * Define if the texture animates or not.
  62171. */
  62172. get animate(): boolean;
  62173. set animate(value: boolean);
  62174. }
  62175. }
  62176. declare module BABYLON {
  62177. /** @hidden */
  62178. export var noisePixelShader: {
  62179. name: string;
  62180. shader: string;
  62181. };
  62182. }
  62183. declare module BABYLON {
  62184. /**
  62185. * Class used to generate noise procedural textures
  62186. */
  62187. export class NoiseProceduralTexture extends ProceduralTexture {
  62188. /** Gets or sets the start time (default is 0) */
  62189. time: number;
  62190. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62191. brightness: number;
  62192. /** Defines the number of octaves to process */
  62193. octaves: number;
  62194. /** Defines the level of persistence (0.8 by default) */
  62195. persistence: number;
  62196. /** Gets or sets animation speed factor (default is 1) */
  62197. animationSpeedFactor: number;
  62198. /**
  62199. * Creates a new NoiseProceduralTexture
  62200. * @param name defines the name fo the texture
  62201. * @param size defines the size of the texture (default is 256)
  62202. * @param scene defines the hosting scene
  62203. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62204. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62205. */
  62206. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62207. private _updateShaderUniforms;
  62208. protected _getDefines(): string;
  62209. /** Generate the current state of the procedural texture */
  62210. render(useCameraPostProcess?: boolean): void;
  62211. /**
  62212. * Serializes this noise procedural texture
  62213. * @returns a serialized noise procedural texture object
  62214. */
  62215. serialize(): any;
  62216. /**
  62217. * Clone the texture.
  62218. * @returns the cloned texture
  62219. */
  62220. clone(): NoiseProceduralTexture;
  62221. /**
  62222. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62223. * @param parsedTexture defines parsed texture data
  62224. * @param scene defines the current scene
  62225. * @param rootUrl defines the root URL containing noise procedural texture information
  62226. * @returns a parsed NoiseProceduralTexture
  62227. */
  62228. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62229. }
  62230. }
  62231. declare module BABYLON {
  62232. /**
  62233. * Raw cube texture where the raw buffers are passed in
  62234. */
  62235. export class RawCubeTexture extends CubeTexture {
  62236. /**
  62237. * Creates a cube texture where the raw buffers are passed in.
  62238. * @param scene defines the scene the texture is attached to
  62239. * @param data defines the array of data to use to create each face
  62240. * @param size defines the size of the textures
  62241. * @param format defines the format of the data
  62242. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62243. * @param generateMipMaps defines if the engine should generate the mip levels
  62244. * @param invertY defines if data must be stored with Y axis inverted
  62245. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62246. * @param compression defines the compression used (null by default)
  62247. */
  62248. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62249. /**
  62250. * Updates the raw cube texture.
  62251. * @param data defines the data to store
  62252. * @param format defines the data format
  62253. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62254. * @param invertY defines if data must be stored with Y axis inverted
  62255. * @param compression defines the compression used (null by default)
  62256. * @param level defines which level of the texture to update
  62257. */
  62258. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62259. /**
  62260. * Updates a raw cube texture with RGBD encoded data.
  62261. * @param data defines the array of data [mipmap][face] to use to create each face
  62262. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62263. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62264. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62265. * @returns a promsie that resolves when the operation is complete
  62266. */
  62267. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62268. /**
  62269. * Clones the raw cube texture.
  62270. * @return a new cube texture
  62271. */
  62272. clone(): CubeTexture;
  62273. /** @hidden */
  62274. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62275. }
  62276. }
  62277. declare module BABYLON {
  62278. /**
  62279. * Class used to store 2D array textures containing user data
  62280. */
  62281. export class RawTexture2DArray extends Texture {
  62282. /** Gets or sets the texture format to use */
  62283. format: number;
  62284. /**
  62285. * Create a new RawTexture2DArray
  62286. * @param data defines the data of the texture
  62287. * @param width defines the width of the texture
  62288. * @param height defines the height of the texture
  62289. * @param depth defines the number of layers of the texture
  62290. * @param format defines the texture format to use
  62291. * @param scene defines the hosting scene
  62292. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62293. * @param invertY defines if texture must be stored with Y axis inverted
  62294. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62295. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62296. */
  62297. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62298. /** Gets or sets the texture format to use */
  62299. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62300. /**
  62301. * Update the texture with new data
  62302. * @param data defines the data to store in the texture
  62303. */
  62304. update(data: ArrayBufferView): void;
  62305. }
  62306. }
  62307. declare module BABYLON {
  62308. /**
  62309. * Class used to store 3D textures containing user data
  62310. */
  62311. export class RawTexture3D extends Texture {
  62312. /** Gets or sets the texture format to use */
  62313. format: number;
  62314. /**
  62315. * Create a new RawTexture3D
  62316. * @param data defines the data of the texture
  62317. * @param width defines the width of the texture
  62318. * @param height defines the height of the texture
  62319. * @param depth defines the depth of the texture
  62320. * @param format defines the texture format to use
  62321. * @param scene defines the hosting scene
  62322. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62323. * @param invertY defines if texture must be stored with Y axis inverted
  62324. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62325. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62326. */
  62327. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62328. /** Gets or sets the texture format to use */
  62329. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62330. /**
  62331. * Update the texture with new data
  62332. * @param data defines the data to store in the texture
  62333. */
  62334. update(data: ArrayBufferView): void;
  62335. }
  62336. }
  62337. declare module BABYLON {
  62338. /**
  62339. * Creates a refraction texture used by refraction channel of the standard material.
  62340. * It is like a mirror but to see through a material.
  62341. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62342. */
  62343. export class RefractionTexture extends RenderTargetTexture {
  62344. /**
  62345. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62346. * 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.
  62347. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62348. */
  62349. refractionPlane: Plane;
  62350. /**
  62351. * Define how deep under the surface we should see.
  62352. */
  62353. depth: number;
  62354. /**
  62355. * Creates a refraction texture used by refraction channel of the standard material.
  62356. * It is like a mirror but to see through a material.
  62357. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62358. * @param name Define the texture name
  62359. * @param size Define the size of the underlying texture
  62360. * @param scene Define the scene the refraction belongs to
  62361. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62362. */
  62363. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62364. /**
  62365. * Clone the refraction texture.
  62366. * @returns the cloned texture
  62367. */
  62368. clone(): RefractionTexture;
  62369. /**
  62370. * Serialize the texture to a JSON representation you could use in Parse later on
  62371. * @returns the serialized JSON representation
  62372. */
  62373. serialize(): any;
  62374. }
  62375. }
  62376. declare module BABYLON {
  62377. /**
  62378. * Block used to add support for vertex skinning (bones)
  62379. */
  62380. export class BonesBlock extends NodeMaterialBlock {
  62381. /**
  62382. * Creates a new BonesBlock
  62383. * @param name defines the block name
  62384. */
  62385. constructor(name: string);
  62386. /**
  62387. * Initialize the block and prepare the context for build
  62388. * @param state defines the state that will be used for the build
  62389. */
  62390. initialize(state: NodeMaterialBuildState): void;
  62391. /**
  62392. * Gets the current class name
  62393. * @returns the class name
  62394. */
  62395. getClassName(): string;
  62396. /**
  62397. * Gets the matrix indices input component
  62398. */
  62399. get matricesIndices(): NodeMaterialConnectionPoint;
  62400. /**
  62401. * Gets the matrix weights input component
  62402. */
  62403. get matricesWeights(): NodeMaterialConnectionPoint;
  62404. /**
  62405. * Gets the extra matrix indices input component
  62406. */
  62407. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62408. /**
  62409. * Gets the extra matrix weights input component
  62410. */
  62411. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62412. /**
  62413. * Gets the world input component
  62414. */
  62415. get world(): NodeMaterialConnectionPoint;
  62416. /**
  62417. * Gets the output component
  62418. */
  62419. get output(): NodeMaterialConnectionPoint;
  62420. autoConfigure(material: NodeMaterial): void;
  62421. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62422. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62424. protected _buildBlock(state: NodeMaterialBuildState): this;
  62425. }
  62426. }
  62427. declare module BABYLON {
  62428. /**
  62429. * Block used to add support for instances
  62430. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62431. */
  62432. export class InstancesBlock extends NodeMaterialBlock {
  62433. /**
  62434. * Creates a new InstancesBlock
  62435. * @param name defines the block name
  62436. */
  62437. constructor(name: string);
  62438. /**
  62439. * Gets the current class name
  62440. * @returns the class name
  62441. */
  62442. getClassName(): string;
  62443. /**
  62444. * Gets the first world row input component
  62445. */
  62446. get world0(): NodeMaterialConnectionPoint;
  62447. /**
  62448. * Gets the second world row input component
  62449. */
  62450. get world1(): NodeMaterialConnectionPoint;
  62451. /**
  62452. * Gets the third world row input component
  62453. */
  62454. get world2(): NodeMaterialConnectionPoint;
  62455. /**
  62456. * Gets the forth world row input component
  62457. */
  62458. get world3(): NodeMaterialConnectionPoint;
  62459. /**
  62460. * Gets the world input component
  62461. */
  62462. get world(): NodeMaterialConnectionPoint;
  62463. /**
  62464. * Gets the output component
  62465. */
  62466. get output(): NodeMaterialConnectionPoint;
  62467. /**
  62468. * Gets the isntanceID component
  62469. */
  62470. get instanceID(): NodeMaterialConnectionPoint;
  62471. autoConfigure(material: NodeMaterial): void;
  62472. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62473. protected _buildBlock(state: NodeMaterialBuildState): this;
  62474. }
  62475. }
  62476. declare module BABYLON {
  62477. /**
  62478. * Block used to add morph targets support to vertex shader
  62479. */
  62480. export class MorphTargetsBlock extends NodeMaterialBlock {
  62481. private _repeatableContentAnchor;
  62482. /**
  62483. * Create a new MorphTargetsBlock
  62484. * @param name defines the block name
  62485. */
  62486. constructor(name: string);
  62487. /**
  62488. * Gets the current class name
  62489. * @returns the class name
  62490. */
  62491. getClassName(): string;
  62492. /**
  62493. * Gets the position input component
  62494. */
  62495. get position(): NodeMaterialConnectionPoint;
  62496. /**
  62497. * Gets the normal input component
  62498. */
  62499. get normal(): NodeMaterialConnectionPoint;
  62500. /**
  62501. * Gets the tangent input component
  62502. */
  62503. get tangent(): NodeMaterialConnectionPoint;
  62504. /**
  62505. * Gets the tangent input component
  62506. */
  62507. get uv(): NodeMaterialConnectionPoint;
  62508. /**
  62509. * Gets the position output component
  62510. */
  62511. get positionOutput(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the normal output component
  62514. */
  62515. get normalOutput(): NodeMaterialConnectionPoint;
  62516. /**
  62517. * Gets the tangent output component
  62518. */
  62519. get tangentOutput(): NodeMaterialConnectionPoint;
  62520. /**
  62521. * Gets the tangent output component
  62522. */
  62523. get uvOutput(): NodeMaterialConnectionPoint;
  62524. initialize(state: NodeMaterialBuildState): void;
  62525. autoConfigure(material: NodeMaterial): void;
  62526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62527. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62528. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62529. protected _buildBlock(state: NodeMaterialBuildState): this;
  62530. }
  62531. }
  62532. declare module BABYLON {
  62533. /**
  62534. * Block used to get data information from a light
  62535. */
  62536. export class LightInformationBlock extends NodeMaterialBlock {
  62537. private _lightDataUniformName;
  62538. private _lightColorUniformName;
  62539. private _lightTypeDefineName;
  62540. /**
  62541. * Gets or sets the light associated with this block
  62542. */
  62543. light: Nullable<Light>;
  62544. /**
  62545. * Creates a new LightInformationBlock
  62546. * @param name defines the block name
  62547. */
  62548. constructor(name: string);
  62549. /**
  62550. * Gets the current class name
  62551. * @returns the class name
  62552. */
  62553. getClassName(): string;
  62554. /**
  62555. * Gets the world position input component
  62556. */
  62557. get worldPosition(): NodeMaterialConnectionPoint;
  62558. /**
  62559. * Gets the direction output component
  62560. */
  62561. get direction(): NodeMaterialConnectionPoint;
  62562. /**
  62563. * Gets the direction output component
  62564. */
  62565. get color(): NodeMaterialConnectionPoint;
  62566. /**
  62567. * Gets the direction output component
  62568. */
  62569. get intensity(): NodeMaterialConnectionPoint;
  62570. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62572. protected _buildBlock(state: NodeMaterialBuildState): this;
  62573. serialize(): any;
  62574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62575. }
  62576. }
  62577. declare module BABYLON {
  62578. /**
  62579. * Block used to add image processing support to fragment shader
  62580. */
  62581. export class ImageProcessingBlock extends NodeMaterialBlock {
  62582. /**
  62583. * Create a new ImageProcessingBlock
  62584. * @param name defines the block name
  62585. */
  62586. constructor(name: string);
  62587. /**
  62588. * Gets the current class name
  62589. * @returns the class name
  62590. */
  62591. getClassName(): string;
  62592. /**
  62593. * Gets the color input component
  62594. */
  62595. get color(): NodeMaterialConnectionPoint;
  62596. /**
  62597. * Gets the output component
  62598. */
  62599. get output(): NodeMaterialConnectionPoint;
  62600. /**
  62601. * Initialize the block and prepare the context for build
  62602. * @param state defines the state that will be used for the build
  62603. */
  62604. initialize(state: NodeMaterialBuildState): void;
  62605. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62606. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62607. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62608. protected _buildBlock(state: NodeMaterialBuildState): this;
  62609. }
  62610. }
  62611. declare module BABYLON {
  62612. /**
  62613. * Block used to pertub normals based on a normal map
  62614. */
  62615. export class PerturbNormalBlock extends NodeMaterialBlock {
  62616. private _tangentSpaceParameterName;
  62617. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62618. invertX: boolean;
  62619. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62620. invertY: boolean;
  62621. /**
  62622. * Create a new PerturbNormalBlock
  62623. * @param name defines the block name
  62624. */
  62625. constructor(name: string);
  62626. /**
  62627. * Gets the current class name
  62628. * @returns the class name
  62629. */
  62630. getClassName(): string;
  62631. /**
  62632. * Gets the world position input component
  62633. */
  62634. get worldPosition(): NodeMaterialConnectionPoint;
  62635. /**
  62636. * Gets the world normal input component
  62637. */
  62638. get worldNormal(): NodeMaterialConnectionPoint;
  62639. /**
  62640. * Gets the world tangent input component
  62641. */
  62642. get worldTangent(): NodeMaterialConnectionPoint;
  62643. /**
  62644. * Gets the uv input component
  62645. */
  62646. get uv(): NodeMaterialConnectionPoint;
  62647. /**
  62648. * Gets the normal map color input component
  62649. */
  62650. get normalMapColor(): NodeMaterialConnectionPoint;
  62651. /**
  62652. * Gets the strength input component
  62653. */
  62654. get strength(): NodeMaterialConnectionPoint;
  62655. /**
  62656. * Gets the output component
  62657. */
  62658. get output(): NodeMaterialConnectionPoint;
  62659. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62660. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62661. autoConfigure(material: NodeMaterial): void;
  62662. protected _buildBlock(state: NodeMaterialBuildState): this;
  62663. protected _dumpPropertiesCode(): string;
  62664. serialize(): any;
  62665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62666. }
  62667. }
  62668. declare module BABYLON {
  62669. /**
  62670. * Block used to discard a pixel if a value is smaller than a cutoff
  62671. */
  62672. export class DiscardBlock extends NodeMaterialBlock {
  62673. /**
  62674. * Create a new DiscardBlock
  62675. * @param name defines the block name
  62676. */
  62677. constructor(name: string);
  62678. /**
  62679. * Gets the current class name
  62680. * @returns the class name
  62681. */
  62682. getClassName(): string;
  62683. /**
  62684. * Gets the color input component
  62685. */
  62686. get value(): NodeMaterialConnectionPoint;
  62687. /**
  62688. * Gets the cutoff input component
  62689. */
  62690. get cutoff(): NodeMaterialConnectionPoint;
  62691. protected _buildBlock(state: NodeMaterialBuildState): this;
  62692. }
  62693. }
  62694. declare module BABYLON {
  62695. /**
  62696. * Block used to test if the fragment shader is front facing
  62697. */
  62698. export class FrontFacingBlock extends NodeMaterialBlock {
  62699. /**
  62700. * Creates a new FrontFacingBlock
  62701. * @param name defines the block name
  62702. */
  62703. constructor(name: string);
  62704. /**
  62705. * Gets the current class name
  62706. * @returns the class name
  62707. */
  62708. getClassName(): string;
  62709. /**
  62710. * Gets the output component
  62711. */
  62712. get output(): NodeMaterialConnectionPoint;
  62713. protected _buildBlock(state: NodeMaterialBuildState): this;
  62714. }
  62715. }
  62716. declare module BABYLON {
  62717. /**
  62718. * Block used to get the derivative value on x and y of a given input
  62719. */
  62720. export class DerivativeBlock extends NodeMaterialBlock {
  62721. /**
  62722. * Create a new DerivativeBlock
  62723. * @param name defines the block name
  62724. */
  62725. constructor(name: string);
  62726. /**
  62727. * Gets the current class name
  62728. * @returns the class name
  62729. */
  62730. getClassName(): string;
  62731. /**
  62732. * Gets the input component
  62733. */
  62734. get input(): NodeMaterialConnectionPoint;
  62735. /**
  62736. * Gets the derivative output on x
  62737. */
  62738. get dx(): NodeMaterialConnectionPoint;
  62739. /**
  62740. * Gets the derivative output on y
  62741. */
  62742. get dy(): NodeMaterialConnectionPoint;
  62743. protected _buildBlock(state: NodeMaterialBuildState): this;
  62744. }
  62745. }
  62746. declare module BABYLON {
  62747. /**
  62748. * Block used to make gl_FragCoord available
  62749. */
  62750. export class FragCoordBlock extends NodeMaterialBlock {
  62751. /**
  62752. * Creates a new FragCoordBlock
  62753. * @param name defines the block name
  62754. */
  62755. constructor(name: string);
  62756. /**
  62757. * Gets the current class name
  62758. * @returns the class name
  62759. */
  62760. getClassName(): string;
  62761. /**
  62762. * Gets the xy component
  62763. */
  62764. get xy(): NodeMaterialConnectionPoint;
  62765. /**
  62766. * Gets the xyz component
  62767. */
  62768. get xyz(): NodeMaterialConnectionPoint;
  62769. /**
  62770. * Gets the xyzw component
  62771. */
  62772. get xyzw(): NodeMaterialConnectionPoint;
  62773. /**
  62774. * Gets the x component
  62775. */
  62776. get x(): NodeMaterialConnectionPoint;
  62777. /**
  62778. * Gets the y component
  62779. */
  62780. get y(): NodeMaterialConnectionPoint;
  62781. /**
  62782. * Gets the z component
  62783. */
  62784. get z(): NodeMaterialConnectionPoint;
  62785. /**
  62786. * Gets the w component
  62787. */
  62788. get output(): NodeMaterialConnectionPoint;
  62789. protected writeOutputs(state: NodeMaterialBuildState): string;
  62790. protected _buildBlock(state: NodeMaterialBuildState): this;
  62791. }
  62792. }
  62793. declare module BABYLON {
  62794. /**
  62795. * Block used to get the screen sizes
  62796. */
  62797. export class ScreenSizeBlock extends NodeMaterialBlock {
  62798. private _varName;
  62799. private _scene;
  62800. /**
  62801. * Creates a new ScreenSizeBlock
  62802. * @param name defines the block name
  62803. */
  62804. constructor(name: string);
  62805. /**
  62806. * Gets the current class name
  62807. * @returns the class name
  62808. */
  62809. getClassName(): string;
  62810. /**
  62811. * Gets the xy component
  62812. */
  62813. get xy(): NodeMaterialConnectionPoint;
  62814. /**
  62815. * Gets the x component
  62816. */
  62817. get x(): NodeMaterialConnectionPoint;
  62818. /**
  62819. * Gets the y component
  62820. */
  62821. get y(): NodeMaterialConnectionPoint;
  62822. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62823. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62824. protected _buildBlock(state: NodeMaterialBuildState): this;
  62825. }
  62826. }
  62827. declare module BABYLON {
  62828. /**
  62829. * Block used to add support for scene fog
  62830. */
  62831. export class FogBlock extends NodeMaterialBlock {
  62832. private _fogDistanceName;
  62833. private _fogParameters;
  62834. /**
  62835. * Create a new FogBlock
  62836. * @param name defines the block name
  62837. */
  62838. constructor(name: string);
  62839. /**
  62840. * Gets the current class name
  62841. * @returns the class name
  62842. */
  62843. getClassName(): string;
  62844. /**
  62845. * Gets the world position input component
  62846. */
  62847. get worldPosition(): NodeMaterialConnectionPoint;
  62848. /**
  62849. * Gets the view input component
  62850. */
  62851. get view(): NodeMaterialConnectionPoint;
  62852. /**
  62853. * Gets the color input component
  62854. */
  62855. get input(): NodeMaterialConnectionPoint;
  62856. /**
  62857. * Gets the fog color input component
  62858. */
  62859. get fogColor(): NodeMaterialConnectionPoint;
  62860. /**
  62861. * Gets the output component
  62862. */
  62863. get output(): NodeMaterialConnectionPoint;
  62864. autoConfigure(material: NodeMaterial): void;
  62865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62866. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62867. protected _buildBlock(state: NodeMaterialBuildState): this;
  62868. }
  62869. }
  62870. declare module BABYLON {
  62871. /**
  62872. * Block used to add light in the fragment shader
  62873. */
  62874. export class LightBlock extends NodeMaterialBlock {
  62875. private _lightId;
  62876. /**
  62877. * Gets or sets the light associated with this block
  62878. */
  62879. light: Nullable<Light>;
  62880. /**
  62881. * Create a new LightBlock
  62882. * @param name defines the block name
  62883. */
  62884. constructor(name: string);
  62885. /**
  62886. * Gets the current class name
  62887. * @returns the class name
  62888. */
  62889. getClassName(): string;
  62890. /**
  62891. * Gets the world position input component
  62892. */
  62893. get worldPosition(): NodeMaterialConnectionPoint;
  62894. /**
  62895. * Gets the world normal input component
  62896. */
  62897. get worldNormal(): NodeMaterialConnectionPoint;
  62898. /**
  62899. * Gets the camera (or eye) position component
  62900. */
  62901. get cameraPosition(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the glossiness component
  62904. */
  62905. get glossiness(): NodeMaterialConnectionPoint;
  62906. /**
  62907. * Gets the glossinness power component
  62908. */
  62909. get glossPower(): NodeMaterialConnectionPoint;
  62910. /**
  62911. * Gets the diffuse color component
  62912. */
  62913. get diffuseColor(): NodeMaterialConnectionPoint;
  62914. /**
  62915. * Gets the specular color component
  62916. */
  62917. get specularColor(): NodeMaterialConnectionPoint;
  62918. /**
  62919. * Gets the diffuse output component
  62920. */
  62921. get diffuseOutput(): NodeMaterialConnectionPoint;
  62922. /**
  62923. * Gets the specular output component
  62924. */
  62925. get specularOutput(): NodeMaterialConnectionPoint;
  62926. /**
  62927. * Gets the shadow output component
  62928. */
  62929. get shadow(): NodeMaterialConnectionPoint;
  62930. autoConfigure(material: NodeMaterial): void;
  62931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62932. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62933. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62934. private _injectVertexCode;
  62935. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62936. serialize(): any;
  62937. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62938. }
  62939. }
  62940. declare module BABYLON {
  62941. /**
  62942. * Block used to read a reflection texture from a sampler
  62943. */
  62944. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62945. /**
  62946. * Create a new ReflectionTextureBlock
  62947. * @param name defines the block name
  62948. */
  62949. constructor(name: string);
  62950. /**
  62951. * Gets the current class name
  62952. * @returns the class name
  62953. */
  62954. getClassName(): string;
  62955. /**
  62956. * Gets the world position input component
  62957. */
  62958. get position(): NodeMaterialConnectionPoint;
  62959. /**
  62960. * Gets the world position input component
  62961. */
  62962. get worldPosition(): NodeMaterialConnectionPoint;
  62963. /**
  62964. * Gets the world normal input component
  62965. */
  62966. get worldNormal(): NodeMaterialConnectionPoint;
  62967. /**
  62968. * Gets the world input component
  62969. */
  62970. get world(): NodeMaterialConnectionPoint;
  62971. /**
  62972. * Gets the camera (or eye) position component
  62973. */
  62974. get cameraPosition(): NodeMaterialConnectionPoint;
  62975. /**
  62976. * Gets the view input component
  62977. */
  62978. get view(): NodeMaterialConnectionPoint;
  62979. /**
  62980. * Gets the rgb output component
  62981. */
  62982. get rgb(): NodeMaterialConnectionPoint;
  62983. /**
  62984. * Gets the rgba output component
  62985. */
  62986. get rgba(): NodeMaterialConnectionPoint;
  62987. /**
  62988. * Gets the r output component
  62989. */
  62990. get r(): NodeMaterialConnectionPoint;
  62991. /**
  62992. * Gets the g output component
  62993. */
  62994. get g(): NodeMaterialConnectionPoint;
  62995. /**
  62996. * Gets the b output component
  62997. */
  62998. get b(): NodeMaterialConnectionPoint;
  62999. /**
  63000. * Gets the a output component
  63001. */
  63002. get a(): NodeMaterialConnectionPoint;
  63003. autoConfigure(material: NodeMaterial): void;
  63004. protected _buildBlock(state: NodeMaterialBuildState): this;
  63005. }
  63006. }
  63007. declare module BABYLON {
  63008. /**
  63009. * Block used to add 2 vectors
  63010. */
  63011. export class AddBlock extends NodeMaterialBlock {
  63012. /**
  63013. * Creates a new AddBlock
  63014. * @param name defines the block name
  63015. */
  63016. constructor(name: string);
  63017. /**
  63018. * Gets the current class name
  63019. * @returns the class name
  63020. */
  63021. getClassName(): string;
  63022. /**
  63023. * Gets the left operand input component
  63024. */
  63025. get left(): NodeMaterialConnectionPoint;
  63026. /**
  63027. * Gets the right operand input component
  63028. */
  63029. get right(): NodeMaterialConnectionPoint;
  63030. /**
  63031. * Gets the output component
  63032. */
  63033. get output(): NodeMaterialConnectionPoint;
  63034. protected _buildBlock(state: NodeMaterialBuildState): this;
  63035. }
  63036. }
  63037. declare module BABYLON {
  63038. /**
  63039. * Block used to scale a vector by a float
  63040. */
  63041. export class ScaleBlock extends NodeMaterialBlock {
  63042. /**
  63043. * Creates a new ScaleBlock
  63044. * @param name defines the block name
  63045. */
  63046. constructor(name: string);
  63047. /**
  63048. * Gets the current class name
  63049. * @returns the class name
  63050. */
  63051. getClassName(): string;
  63052. /**
  63053. * Gets the input component
  63054. */
  63055. get input(): NodeMaterialConnectionPoint;
  63056. /**
  63057. * Gets the factor input component
  63058. */
  63059. get factor(): NodeMaterialConnectionPoint;
  63060. /**
  63061. * Gets the output component
  63062. */
  63063. get output(): NodeMaterialConnectionPoint;
  63064. protected _buildBlock(state: NodeMaterialBuildState): this;
  63065. }
  63066. }
  63067. declare module BABYLON {
  63068. /**
  63069. * Block used to clamp a float
  63070. */
  63071. export class ClampBlock extends NodeMaterialBlock {
  63072. /** Gets or sets the minimum range */
  63073. minimum: number;
  63074. /** Gets or sets the maximum range */
  63075. maximum: number;
  63076. /**
  63077. * Creates a new ClampBlock
  63078. * @param name defines the block name
  63079. */
  63080. constructor(name: string);
  63081. /**
  63082. * Gets the current class name
  63083. * @returns the class name
  63084. */
  63085. getClassName(): string;
  63086. /**
  63087. * Gets the value input component
  63088. */
  63089. get value(): NodeMaterialConnectionPoint;
  63090. /**
  63091. * Gets the output component
  63092. */
  63093. get output(): NodeMaterialConnectionPoint;
  63094. protected _buildBlock(state: NodeMaterialBuildState): this;
  63095. protected _dumpPropertiesCode(): string;
  63096. serialize(): any;
  63097. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63098. }
  63099. }
  63100. declare module BABYLON {
  63101. /**
  63102. * Block used to apply a cross product between 2 vectors
  63103. */
  63104. export class CrossBlock extends NodeMaterialBlock {
  63105. /**
  63106. * Creates a new CrossBlock
  63107. * @param name defines the block name
  63108. */
  63109. constructor(name: string);
  63110. /**
  63111. * Gets the current class name
  63112. * @returns the class name
  63113. */
  63114. getClassName(): string;
  63115. /**
  63116. * Gets the left operand input component
  63117. */
  63118. get left(): NodeMaterialConnectionPoint;
  63119. /**
  63120. * Gets the right operand input component
  63121. */
  63122. get right(): NodeMaterialConnectionPoint;
  63123. /**
  63124. * Gets the output component
  63125. */
  63126. get output(): NodeMaterialConnectionPoint;
  63127. protected _buildBlock(state: NodeMaterialBuildState): this;
  63128. }
  63129. }
  63130. declare module BABYLON {
  63131. /**
  63132. * Block used to apply a dot product between 2 vectors
  63133. */
  63134. export class DotBlock extends NodeMaterialBlock {
  63135. /**
  63136. * Creates a new DotBlock
  63137. * @param name defines the block name
  63138. */
  63139. constructor(name: string);
  63140. /**
  63141. * Gets the current class name
  63142. * @returns the class name
  63143. */
  63144. getClassName(): string;
  63145. /**
  63146. * Gets the left operand input component
  63147. */
  63148. get left(): NodeMaterialConnectionPoint;
  63149. /**
  63150. * Gets the right operand input component
  63151. */
  63152. get right(): NodeMaterialConnectionPoint;
  63153. /**
  63154. * Gets the output component
  63155. */
  63156. get output(): NodeMaterialConnectionPoint;
  63157. protected _buildBlock(state: NodeMaterialBuildState): this;
  63158. }
  63159. }
  63160. declare module BABYLON {
  63161. /**
  63162. * Block used to normalize a vector
  63163. */
  63164. export class NormalizeBlock extends NodeMaterialBlock {
  63165. /**
  63166. * Creates a new NormalizeBlock
  63167. * @param name defines the block name
  63168. */
  63169. constructor(name: string);
  63170. /**
  63171. * Gets the current class name
  63172. * @returns the class name
  63173. */
  63174. getClassName(): string;
  63175. /**
  63176. * Gets the input component
  63177. */
  63178. get input(): NodeMaterialConnectionPoint;
  63179. /**
  63180. * Gets the output component
  63181. */
  63182. get output(): NodeMaterialConnectionPoint;
  63183. protected _buildBlock(state: NodeMaterialBuildState): this;
  63184. }
  63185. }
  63186. declare module BABYLON {
  63187. /**
  63188. * Operations supported by the Trigonometry block
  63189. */
  63190. export enum TrigonometryBlockOperations {
  63191. /** Cos */
  63192. Cos = 0,
  63193. /** Sin */
  63194. Sin = 1,
  63195. /** Abs */
  63196. Abs = 2,
  63197. /** Exp */
  63198. Exp = 3,
  63199. /** Exp2 */
  63200. Exp2 = 4,
  63201. /** Round */
  63202. Round = 5,
  63203. /** Floor */
  63204. Floor = 6,
  63205. /** Ceiling */
  63206. Ceiling = 7,
  63207. /** Square root */
  63208. Sqrt = 8,
  63209. /** Log */
  63210. Log = 9,
  63211. /** Tangent */
  63212. Tan = 10,
  63213. /** Arc tangent */
  63214. ArcTan = 11,
  63215. /** Arc cosinus */
  63216. ArcCos = 12,
  63217. /** Arc sinus */
  63218. ArcSin = 13,
  63219. /** Fraction */
  63220. Fract = 14,
  63221. /** Sign */
  63222. Sign = 15,
  63223. /** To radians (from degrees) */
  63224. Radians = 16,
  63225. /** To degrees (from radians) */
  63226. Degrees = 17
  63227. }
  63228. /**
  63229. * Block used to apply trigonometry operation to floats
  63230. */
  63231. export class TrigonometryBlock extends NodeMaterialBlock {
  63232. /**
  63233. * Gets or sets the operation applied by the block
  63234. */
  63235. operation: TrigonometryBlockOperations;
  63236. /**
  63237. * Creates a new TrigonometryBlock
  63238. * @param name defines the block name
  63239. */
  63240. constructor(name: string);
  63241. /**
  63242. * Gets the current class name
  63243. * @returns the class name
  63244. */
  63245. getClassName(): string;
  63246. /**
  63247. * Gets the input component
  63248. */
  63249. get input(): NodeMaterialConnectionPoint;
  63250. /**
  63251. * Gets the output component
  63252. */
  63253. get output(): NodeMaterialConnectionPoint;
  63254. protected _buildBlock(state: NodeMaterialBuildState): this;
  63255. serialize(): any;
  63256. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63257. protected _dumpPropertiesCode(): string;
  63258. }
  63259. }
  63260. declare module BABYLON {
  63261. /**
  63262. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63263. */
  63264. export class ColorMergerBlock extends NodeMaterialBlock {
  63265. /**
  63266. * Create a new ColorMergerBlock
  63267. * @param name defines the block name
  63268. */
  63269. constructor(name: string);
  63270. /**
  63271. * Gets the current class name
  63272. * @returns the class name
  63273. */
  63274. getClassName(): string;
  63275. /**
  63276. * Gets the rgb component (input)
  63277. */
  63278. get rgbIn(): NodeMaterialConnectionPoint;
  63279. /**
  63280. * Gets the r component (input)
  63281. */
  63282. get r(): NodeMaterialConnectionPoint;
  63283. /**
  63284. * Gets the g component (input)
  63285. */
  63286. get g(): NodeMaterialConnectionPoint;
  63287. /**
  63288. * Gets the b component (input)
  63289. */
  63290. get b(): NodeMaterialConnectionPoint;
  63291. /**
  63292. * Gets the a component (input)
  63293. */
  63294. get a(): NodeMaterialConnectionPoint;
  63295. /**
  63296. * Gets the rgba component (output)
  63297. */
  63298. get rgba(): NodeMaterialConnectionPoint;
  63299. /**
  63300. * Gets the rgb component (output)
  63301. */
  63302. get rgbOut(): NodeMaterialConnectionPoint;
  63303. /**
  63304. * Gets the rgb component (output)
  63305. * @deprecated Please use rgbOut instead.
  63306. */
  63307. get rgb(): NodeMaterialConnectionPoint;
  63308. protected _buildBlock(state: NodeMaterialBuildState): this;
  63309. }
  63310. }
  63311. declare module BABYLON {
  63312. /**
  63313. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63314. */
  63315. export class VectorSplitterBlock extends NodeMaterialBlock {
  63316. /**
  63317. * Create a new VectorSplitterBlock
  63318. * @param name defines the block name
  63319. */
  63320. constructor(name: string);
  63321. /**
  63322. * Gets the current class name
  63323. * @returns the class name
  63324. */
  63325. getClassName(): string;
  63326. /**
  63327. * Gets the xyzw component (input)
  63328. */
  63329. get xyzw(): NodeMaterialConnectionPoint;
  63330. /**
  63331. * Gets the xyz component (input)
  63332. */
  63333. get xyzIn(): NodeMaterialConnectionPoint;
  63334. /**
  63335. * Gets the xy component (input)
  63336. */
  63337. get xyIn(): NodeMaterialConnectionPoint;
  63338. /**
  63339. * Gets the xyz component (output)
  63340. */
  63341. get xyzOut(): NodeMaterialConnectionPoint;
  63342. /**
  63343. * Gets the xy component (output)
  63344. */
  63345. get xyOut(): NodeMaterialConnectionPoint;
  63346. /**
  63347. * Gets the x component (output)
  63348. */
  63349. get x(): NodeMaterialConnectionPoint;
  63350. /**
  63351. * Gets the y component (output)
  63352. */
  63353. get y(): NodeMaterialConnectionPoint;
  63354. /**
  63355. * Gets the z component (output)
  63356. */
  63357. get z(): NodeMaterialConnectionPoint;
  63358. /**
  63359. * Gets the w component (output)
  63360. */
  63361. get w(): NodeMaterialConnectionPoint;
  63362. protected _inputRename(name: string): string;
  63363. protected _outputRename(name: string): string;
  63364. protected _buildBlock(state: NodeMaterialBuildState): this;
  63365. }
  63366. }
  63367. declare module BABYLON {
  63368. /**
  63369. * Block used to lerp between 2 values
  63370. */
  63371. export class LerpBlock extends NodeMaterialBlock {
  63372. /**
  63373. * Creates a new LerpBlock
  63374. * @param name defines the block name
  63375. */
  63376. constructor(name: string);
  63377. /**
  63378. * Gets the current class name
  63379. * @returns the class name
  63380. */
  63381. getClassName(): string;
  63382. /**
  63383. * Gets the left operand input component
  63384. */
  63385. get left(): NodeMaterialConnectionPoint;
  63386. /**
  63387. * Gets the right operand input component
  63388. */
  63389. get right(): NodeMaterialConnectionPoint;
  63390. /**
  63391. * Gets the gradient operand input component
  63392. */
  63393. get gradient(): NodeMaterialConnectionPoint;
  63394. /**
  63395. * Gets the output component
  63396. */
  63397. get output(): NodeMaterialConnectionPoint;
  63398. protected _buildBlock(state: NodeMaterialBuildState): this;
  63399. }
  63400. }
  63401. declare module BABYLON {
  63402. /**
  63403. * Block used to divide 2 vectors
  63404. */
  63405. export class DivideBlock extends NodeMaterialBlock {
  63406. /**
  63407. * Creates a new DivideBlock
  63408. * @param name defines the block name
  63409. */
  63410. constructor(name: string);
  63411. /**
  63412. * Gets the current class name
  63413. * @returns the class name
  63414. */
  63415. getClassName(): string;
  63416. /**
  63417. * Gets the left operand input component
  63418. */
  63419. get left(): NodeMaterialConnectionPoint;
  63420. /**
  63421. * Gets the right operand input component
  63422. */
  63423. get right(): NodeMaterialConnectionPoint;
  63424. /**
  63425. * Gets the output component
  63426. */
  63427. get output(): NodeMaterialConnectionPoint;
  63428. protected _buildBlock(state: NodeMaterialBuildState): this;
  63429. }
  63430. }
  63431. declare module BABYLON {
  63432. /**
  63433. * Block used to subtract 2 vectors
  63434. */
  63435. export class SubtractBlock extends NodeMaterialBlock {
  63436. /**
  63437. * Creates a new SubtractBlock
  63438. * @param name defines the block name
  63439. */
  63440. constructor(name: string);
  63441. /**
  63442. * Gets the current class name
  63443. * @returns the class name
  63444. */
  63445. getClassName(): string;
  63446. /**
  63447. * Gets the left operand input component
  63448. */
  63449. get left(): NodeMaterialConnectionPoint;
  63450. /**
  63451. * Gets the right operand input component
  63452. */
  63453. get right(): NodeMaterialConnectionPoint;
  63454. /**
  63455. * Gets the output component
  63456. */
  63457. get output(): NodeMaterialConnectionPoint;
  63458. protected _buildBlock(state: NodeMaterialBuildState): this;
  63459. }
  63460. }
  63461. declare module BABYLON {
  63462. /**
  63463. * Block used to step a value
  63464. */
  63465. export class StepBlock extends NodeMaterialBlock {
  63466. /**
  63467. * Creates a new StepBlock
  63468. * @param name defines the block name
  63469. */
  63470. constructor(name: string);
  63471. /**
  63472. * Gets the current class name
  63473. * @returns the class name
  63474. */
  63475. getClassName(): string;
  63476. /**
  63477. * Gets the value operand input component
  63478. */
  63479. get value(): NodeMaterialConnectionPoint;
  63480. /**
  63481. * Gets the edge operand input component
  63482. */
  63483. get edge(): NodeMaterialConnectionPoint;
  63484. /**
  63485. * Gets the output component
  63486. */
  63487. get output(): NodeMaterialConnectionPoint;
  63488. protected _buildBlock(state: NodeMaterialBuildState): this;
  63489. }
  63490. }
  63491. declare module BABYLON {
  63492. /**
  63493. * Block used to get the opposite (1 - x) of a value
  63494. */
  63495. export class OneMinusBlock extends NodeMaterialBlock {
  63496. /**
  63497. * Creates a new OneMinusBlock
  63498. * @param name defines the block name
  63499. */
  63500. constructor(name: string);
  63501. /**
  63502. * Gets the current class name
  63503. * @returns the class name
  63504. */
  63505. getClassName(): string;
  63506. /**
  63507. * Gets the input component
  63508. */
  63509. get input(): NodeMaterialConnectionPoint;
  63510. /**
  63511. * Gets the output component
  63512. */
  63513. get output(): NodeMaterialConnectionPoint;
  63514. protected _buildBlock(state: NodeMaterialBuildState): this;
  63515. }
  63516. }
  63517. declare module BABYLON {
  63518. /**
  63519. * Block used to get the view direction
  63520. */
  63521. export class ViewDirectionBlock extends NodeMaterialBlock {
  63522. /**
  63523. * Creates a new ViewDirectionBlock
  63524. * @param name defines the block name
  63525. */
  63526. constructor(name: string);
  63527. /**
  63528. * Gets the current class name
  63529. * @returns the class name
  63530. */
  63531. getClassName(): string;
  63532. /**
  63533. * Gets the world position component
  63534. */
  63535. get worldPosition(): NodeMaterialConnectionPoint;
  63536. /**
  63537. * Gets the camera position component
  63538. */
  63539. get cameraPosition(): NodeMaterialConnectionPoint;
  63540. /**
  63541. * Gets the output component
  63542. */
  63543. get output(): NodeMaterialConnectionPoint;
  63544. autoConfigure(material: NodeMaterial): void;
  63545. protected _buildBlock(state: NodeMaterialBuildState): this;
  63546. }
  63547. }
  63548. declare module BABYLON {
  63549. /**
  63550. * Block used to compute fresnel value
  63551. */
  63552. export class FresnelBlock extends NodeMaterialBlock {
  63553. /**
  63554. * Create a new FresnelBlock
  63555. * @param name defines the block name
  63556. */
  63557. constructor(name: string);
  63558. /**
  63559. * Gets the current class name
  63560. * @returns the class name
  63561. */
  63562. getClassName(): string;
  63563. /**
  63564. * Gets the world normal input component
  63565. */
  63566. get worldNormal(): NodeMaterialConnectionPoint;
  63567. /**
  63568. * Gets the view direction input component
  63569. */
  63570. get viewDirection(): NodeMaterialConnectionPoint;
  63571. /**
  63572. * Gets the bias input component
  63573. */
  63574. get bias(): NodeMaterialConnectionPoint;
  63575. /**
  63576. * Gets the camera (or eye) position component
  63577. */
  63578. get power(): NodeMaterialConnectionPoint;
  63579. /**
  63580. * Gets the fresnel output component
  63581. */
  63582. get fresnel(): NodeMaterialConnectionPoint;
  63583. autoConfigure(material: NodeMaterial): void;
  63584. protected _buildBlock(state: NodeMaterialBuildState): this;
  63585. }
  63586. }
  63587. declare module BABYLON {
  63588. /**
  63589. * Block used to get the max of 2 values
  63590. */
  63591. export class MaxBlock extends NodeMaterialBlock {
  63592. /**
  63593. * Creates a new MaxBlock
  63594. * @param name defines the block name
  63595. */
  63596. constructor(name: string);
  63597. /**
  63598. * Gets the current class name
  63599. * @returns the class name
  63600. */
  63601. getClassName(): string;
  63602. /**
  63603. * Gets the left operand input component
  63604. */
  63605. get left(): NodeMaterialConnectionPoint;
  63606. /**
  63607. * Gets the right operand input component
  63608. */
  63609. get right(): NodeMaterialConnectionPoint;
  63610. /**
  63611. * Gets the output component
  63612. */
  63613. get output(): NodeMaterialConnectionPoint;
  63614. protected _buildBlock(state: NodeMaterialBuildState): this;
  63615. }
  63616. }
  63617. declare module BABYLON {
  63618. /**
  63619. * Block used to get the min of 2 values
  63620. */
  63621. export class MinBlock extends NodeMaterialBlock {
  63622. /**
  63623. * Creates a new MinBlock
  63624. * @param name defines the block name
  63625. */
  63626. constructor(name: string);
  63627. /**
  63628. * Gets the current class name
  63629. * @returns the class name
  63630. */
  63631. getClassName(): string;
  63632. /**
  63633. * Gets the left operand input component
  63634. */
  63635. get left(): NodeMaterialConnectionPoint;
  63636. /**
  63637. * Gets the right operand input component
  63638. */
  63639. get right(): NodeMaterialConnectionPoint;
  63640. /**
  63641. * Gets the output component
  63642. */
  63643. get output(): NodeMaterialConnectionPoint;
  63644. protected _buildBlock(state: NodeMaterialBuildState): this;
  63645. }
  63646. }
  63647. declare module BABYLON {
  63648. /**
  63649. * Block used to get the distance between 2 values
  63650. */
  63651. export class DistanceBlock extends NodeMaterialBlock {
  63652. /**
  63653. * Creates a new DistanceBlock
  63654. * @param name defines the block name
  63655. */
  63656. constructor(name: string);
  63657. /**
  63658. * Gets the current class name
  63659. * @returns the class name
  63660. */
  63661. getClassName(): string;
  63662. /**
  63663. * Gets the left operand input component
  63664. */
  63665. get left(): NodeMaterialConnectionPoint;
  63666. /**
  63667. * Gets the right operand input component
  63668. */
  63669. get right(): NodeMaterialConnectionPoint;
  63670. /**
  63671. * Gets the output component
  63672. */
  63673. get output(): NodeMaterialConnectionPoint;
  63674. protected _buildBlock(state: NodeMaterialBuildState): this;
  63675. }
  63676. }
  63677. declare module BABYLON {
  63678. /**
  63679. * Block used to get the length of a vector
  63680. */
  63681. export class LengthBlock extends NodeMaterialBlock {
  63682. /**
  63683. * Creates a new LengthBlock
  63684. * @param name defines the block name
  63685. */
  63686. constructor(name: string);
  63687. /**
  63688. * Gets the current class name
  63689. * @returns the class name
  63690. */
  63691. getClassName(): string;
  63692. /**
  63693. * Gets the value input component
  63694. */
  63695. get value(): NodeMaterialConnectionPoint;
  63696. /**
  63697. * Gets the output component
  63698. */
  63699. get output(): NodeMaterialConnectionPoint;
  63700. protected _buildBlock(state: NodeMaterialBuildState): this;
  63701. }
  63702. }
  63703. declare module BABYLON {
  63704. /**
  63705. * Block used to get negative version of a value (i.e. x * -1)
  63706. */
  63707. export class NegateBlock extends NodeMaterialBlock {
  63708. /**
  63709. * Creates a new NegateBlock
  63710. * @param name defines the block name
  63711. */
  63712. constructor(name: string);
  63713. /**
  63714. * Gets the current class name
  63715. * @returns the class name
  63716. */
  63717. getClassName(): string;
  63718. /**
  63719. * Gets the value input component
  63720. */
  63721. get value(): NodeMaterialConnectionPoint;
  63722. /**
  63723. * Gets the output component
  63724. */
  63725. get output(): NodeMaterialConnectionPoint;
  63726. protected _buildBlock(state: NodeMaterialBuildState): this;
  63727. }
  63728. }
  63729. declare module BABYLON {
  63730. /**
  63731. * Block used to get the value of the first parameter raised to the power of the second
  63732. */
  63733. export class PowBlock extends NodeMaterialBlock {
  63734. /**
  63735. * Creates a new PowBlock
  63736. * @param name defines the block name
  63737. */
  63738. constructor(name: string);
  63739. /**
  63740. * Gets the current class name
  63741. * @returns the class name
  63742. */
  63743. getClassName(): string;
  63744. /**
  63745. * Gets the value operand input component
  63746. */
  63747. get value(): NodeMaterialConnectionPoint;
  63748. /**
  63749. * Gets the power operand input component
  63750. */
  63751. get power(): NodeMaterialConnectionPoint;
  63752. /**
  63753. * Gets the output component
  63754. */
  63755. get output(): NodeMaterialConnectionPoint;
  63756. protected _buildBlock(state: NodeMaterialBuildState): this;
  63757. }
  63758. }
  63759. declare module BABYLON {
  63760. /**
  63761. * Block used to get a random number
  63762. */
  63763. export class RandomNumberBlock extends NodeMaterialBlock {
  63764. /**
  63765. * Creates a new RandomNumberBlock
  63766. * @param name defines the block name
  63767. */
  63768. constructor(name: string);
  63769. /**
  63770. * Gets the current class name
  63771. * @returns the class name
  63772. */
  63773. getClassName(): string;
  63774. /**
  63775. * Gets the seed input component
  63776. */
  63777. get seed(): NodeMaterialConnectionPoint;
  63778. /**
  63779. * Gets the output component
  63780. */
  63781. get output(): NodeMaterialConnectionPoint;
  63782. protected _buildBlock(state: NodeMaterialBuildState): this;
  63783. }
  63784. }
  63785. declare module BABYLON {
  63786. /**
  63787. * Block used to compute arc tangent of 2 values
  63788. */
  63789. export class ArcTan2Block extends NodeMaterialBlock {
  63790. /**
  63791. * Creates a new ArcTan2Block
  63792. * @param name defines the block name
  63793. */
  63794. constructor(name: string);
  63795. /**
  63796. * Gets the current class name
  63797. * @returns the class name
  63798. */
  63799. getClassName(): string;
  63800. /**
  63801. * Gets the x operand input component
  63802. */
  63803. get x(): NodeMaterialConnectionPoint;
  63804. /**
  63805. * Gets the y operand input component
  63806. */
  63807. get y(): NodeMaterialConnectionPoint;
  63808. /**
  63809. * Gets the output component
  63810. */
  63811. get output(): NodeMaterialConnectionPoint;
  63812. protected _buildBlock(state: NodeMaterialBuildState): this;
  63813. }
  63814. }
  63815. declare module BABYLON {
  63816. /**
  63817. * Block used to smooth step a value
  63818. */
  63819. export class SmoothStepBlock extends NodeMaterialBlock {
  63820. /**
  63821. * Creates a new SmoothStepBlock
  63822. * @param name defines the block name
  63823. */
  63824. constructor(name: string);
  63825. /**
  63826. * Gets the current class name
  63827. * @returns the class name
  63828. */
  63829. getClassName(): string;
  63830. /**
  63831. * Gets the value operand input component
  63832. */
  63833. get value(): NodeMaterialConnectionPoint;
  63834. /**
  63835. * Gets the first edge operand input component
  63836. */
  63837. get edge0(): NodeMaterialConnectionPoint;
  63838. /**
  63839. * Gets the second edge operand input component
  63840. */
  63841. get edge1(): NodeMaterialConnectionPoint;
  63842. /**
  63843. * Gets the output component
  63844. */
  63845. get output(): NodeMaterialConnectionPoint;
  63846. protected _buildBlock(state: NodeMaterialBuildState): this;
  63847. }
  63848. }
  63849. declare module BABYLON {
  63850. /**
  63851. * Block used to get the reciprocal (1 / x) of a value
  63852. */
  63853. export class ReciprocalBlock extends NodeMaterialBlock {
  63854. /**
  63855. * Creates a new ReciprocalBlock
  63856. * @param name defines the block name
  63857. */
  63858. constructor(name: string);
  63859. /**
  63860. * Gets the current class name
  63861. * @returns the class name
  63862. */
  63863. getClassName(): string;
  63864. /**
  63865. * Gets the input component
  63866. */
  63867. get input(): NodeMaterialConnectionPoint;
  63868. /**
  63869. * Gets the output component
  63870. */
  63871. get output(): NodeMaterialConnectionPoint;
  63872. protected _buildBlock(state: NodeMaterialBuildState): this;
  63873. }
  63874. }
  63875. declare module BABYLON {
  63876. /**
  63877. * Block used to replace a color by another one
  63878. */
  63879. export class ReplaceColorBlock extends NodeMaterialBlock {
  63880. /**
  63881. * Creates a new ReplaceColorBlock
  63882. * @param name defines the block name
  63883. */
  63884. constructor(name: string);
  63885. /**
  63886. * Gets the current class name
  63887. * @returns the class name
  63888. */
  63889. getClassName(): string;
  63890. /**
  63891. * Gets the value input component
  63892. */
  63893. get value(): NodeMaterialConnectionPoint;
  63894. /**
  63895. * Gets the reference input component
  63896. */
  63897. get reference(): NodeMaterialConnectionPoint;
  63898. /**
  63899. * Gets the distance input component
  63900. */
  63901. get distance(): NodeMaterialConnectionPoint;
  63902. /**
  63903. * Gets the replacement input component
  63904. */
  63905. get replacement(): NodeMaterialConnectionPoint;
  63906. /**
  63907. * Gets the output component
  63908. */
  63909. get output(): NodeMaterialConnectionPoint;
  63910. protected _buildBlock(state: NodeMaterialBuildState): this;
  63911. }
  63912. }
  63913. declare module BABYLON {
  63914. /**
  63915. * Block used to posterize a value
  63916. * @see https://en.wikipedia.org/wiki/Posterization
  63917. */
  63918. export class PosterizeBlock extends NodeMaterialBlock {
  63919. /**
  63920. * Creates a new PosterizeBlock
  63921. * @param name defines the block name
  63922. */
  63923. constructor(name: string);
  63924. /**
  63925. * Gets the current class name
  63926. * @returns the class name
  63927. */
  63928. getClassName(): string;
  63929. /**
  63930. * Gets the value input component
  63931. */
  63932. get value(): NodeMaterialConnectionPoint;
  63933. /**
  63934. * Gets the steps input component
  63935. */
  63936. get steps(): NodeMaterialConnectionPoint;
  63937. /**
  63938. * Gets the output component
  63939. */
  63940. get output(): NodeMaterialConnectionPoint;
  63941. protected _buildBlock(state: NodeMaterialBuildState): this;
  63942. }
  63943. }
  63944. declare module BABYLON {
  63945. /**
  63946. * Operations supported by the Wave block
  63947. */
  63948. export enum WaveBlockKind {
  63949. /** SawTooth */
  63950. SawTooth = 0,
  63951. /** Square */
  63952. Square = 1,
  63953. /** Triangle */
  63954. Triangle = 2
  63955. }
  63956. /**
  63957. * Block used to apply wave operation to floats
  63958. */
  63959. export class WaveBlock extends NodeMaterialBlock {
  63960. /**
  63961. * Gets or sets the kibnd of wave to be applied by the block
  63962. */
  63963. kind: WaveBlockKind;
  63964. /**
  63965. * Creates a new WaveBlock
  63966. * @param name defines the block name
  63967. */
  63968. constructor(name: string);
  63969. /**
  63970. * Gets the current class name
  63971. * @returns the class name
  63972. */
  63973. getClassName(): string;
  63974. /**
  63975. * Gets the input component
  63976. */
  63977. get input(): NodeMaterialConnectionPoint;
  63978. /**
  63979. * Gets the output component
  63980. */
  63981. get output(): NodeMaterialConnectionPoint;
  63982. protected _buildBlock(state: NodeMaterialBuildState): this;
  63983. serialize(): any;
  63984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63985. }
  63986. }
  63987. declare module BABYLON {
  63988. /**
  63989. * Class used to store a color step for the GradientBlock
  63990. */
  63991. export class GradientBlockColorStep {
  63992. private _step;
  63993. /**
  63994. * Gets value indicating which step this color is associated with (between 0 and 1)
  63995. */
  63996. get step(): number;
  63997. /**
  63998. * Sets a value indicating which step this color is associated with (between 0 and 1)
  63999. */
  64000. set step(val: number);
  64001. private _color;
  64002. /**
  64003. * Gets the color associated with this step
  64004. */
  64005. get color(): Color3;
  64006. /**
  64007. * Sets the color associated with this step
  64008. */
  64009. set color(val: Color3);
  64010. /**
  64011. * Creates a new GradientBlockColorStep
  64012. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64013. * @param color defines the color associated with this step
  64014. */
  64015. constructor(step: number, color: Color3);
  64016. }
  64017. /**
  64018. * Block used to return a color from a gradient based on an input value between 0 and 1
  64019. */
  64020. export class GradientBlock extends NodeMaterialBlock {
  64021. /**
  64022. * Gets or sets the list of color steps
  64023. */
  64024. colorSteps: GradientBlockColorStep[];
  64025. /** Gets an observable raised when the value is changed */
  64026. onValueChangedObservable: Observable<GradientBlock>;
  64027. /** calls observable when the value is changed*/
  64028. colorStepsUpdated(): void;
  64029. /**
  64030. * Creates a new GradientBlock
  64031. * @param name defines the block name
  64032. */
  64033. constructor(name: string);
  64034. /**
  64035. * Gets the current class name
  64036. * @returns the class name
  64037. */
  64038. getClassName(): string;
  64039. /**
  64040. * Gets the gradient input component
  64041. */
  64042. get gradient(): NodeMaterialConnectionPoint;
  64043. /**
  64044. * Gets the output component
  64045. */
  64046. get output(): NodeMaterialConnectionPoint;
  64047. private _writeColorConstant;
  64048. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64049. serialize(): any;
  64050. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64051. protected _dumpPropertiesCode(): string;
  64052. }
  64053. }
  64054. declare module BABYLON {
  64055. /**
  64056. * Block used to normalize lerp between 2 values
  64057. */
  64058. export class NLerpBlock extends NodeMaterialBlock {
  64059. /**
  64060. * Creates a new NLerpBlock
  64061. * @param name defines the block name
  64062. */
  64063. constructor(name: string);
  64064. /**
  64065. * Gets the current class name
  64066. * @returns the class name
  64067. */
  64068. getClassName(): string;
  64069. /**
  64070. * Gets the left operand input component
  64071. */
  64072. get left(): NodeMaterialConnectionPoint;
  64073. /**
  64074. * Gets the right operand input component
  64075. */
  64076. get right(): NodeMaterialConnectionPoint;
  64077. /**
  64078. * Gets the gradient operand input component
  64079. */
  64080. get gradient(): NodeMaterialConnectionPoint;
  64081. /**
  64082. * Gets the output component
  64083. */
  64084. get output(): NodeMaterialConnectionPoint;
  64085. protected _buildBlock(state: NodeMaterialBuildState): this;
  64086. }
  64087. }
  64088. declare module BABYLON {
  64089. /**
  64090. * block used to Generate a Worley Noise 3D Noise Pattern
  64091. */
  64092. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64093. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64094. manhattanDistance: boolean;
  64095. /**
  64096. * Creates a new WorleyNoise3DBlock
  64097. * @param name defines the block name
  64098. */
  64099. constructor(name: string);
  64100. /**
  64101. * Gets the current class name
  64102. * @returns the class name
  64103. */
  64104. getClassName(): string;
  64105. /**
  64106. * Gets the seed input component
  64107. */
  64108. get seed(): NodeMaterialConnectionPoint;
  64109. /**
  64110. * Gets the jitter input component
  64111. */
  64112. get jitter(): NodeMaterialConnectionPoint;
  64113. /**
  64114. * Gets the output component
  64115. */
  64116. get output(): NodeMaterialConnectionPoint;
  64117. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64118. /**
  64119. * Exposes the properties to the UI?
  64120. */
  64121. protected _dumpPropertiesCode(): string;
  64122. /**
  64123. * Exposes the properties to the Seralize?
  64124. */
  64125. serialize(): any;
  64126. /**
  64127. * Exposes the properties to the deseralize?
  64128. */
  64129. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64130. }
  64131. }
  64132. declare module BABYLON {
  64133. /**
  64134. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64135. */
  64136. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64137. /**
  64138. * Creates a new SimplexPerlin3DBlock
  64139. * @param name defines the block name
  64140. */
  64141. constructor(name: string);
  64142. /**
  64143. * Gets the current class name
  64144. * @returns the class name
  64145. */
  64146. getClassName(): string;
  64147. /**
  64148. * Gets the seed operand input component
  64149. */
  64150. get seed(): NodeMaterialConnectionPoint;
  64151. /**
  64152. * Gets the output component
  64153. */
  64154. get output(): NodeMaterialConnectionPoint;
  64155. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64156. }
  64157. }
  64158. declare module BABYLON {
  64159. /**
  64160. * Block used to blend normals
  64161. */
  64162. export class NormalBlendBlock extends NodeMaterialBlock {
  64163. /**
  64164. * Creates a new NormalBlendBlock
  64165. * @param name defines the block name
  64166. */
  64167. constructor(name: string);
  64168. /**
  64169. * Gets the current class name
  64170. * @returns the class name
  64171. */
  64172. getClassName(): string;
  64173. /**
  64174. * Gets the first input component
  64175. */
  64176. get normalMap0(): NodeMaterialConnectionPoint;
  64177. /**
  64178. * Gets the second input component
  64179. */
  64180. get normalMap1(): NodeMaterialConnectionPoint;
  64181. /**
  64182. * Gets the output component
  64183. */
  64184. get output(): NodeMaterialConnectionPoint;
  64185. protected _buildBlock(state: NodeMaterialBuildState): this;
  64186. }
  64187. }
  64188. declare module BABYLON {
  64189. /**
  64190. * Block used to rotate a 2d vector by a given angle
  64191. */
  64192. export class Rotate2dBlock extends NodeMaterialBlock {
  64193. /**
  64194. * Creates a new Rotate2dBlock
  64195. * @param name defines the block name
  64196. */
  64197. constructor(name: string);
  64198. /**
  64199. * Gets the current class name
  64200. * @returns the class name
  64201. */
  64202. getClassName(): string;
  64203. /**
  64204. * Gets the input vector
  64205. */
  64206. get input(): NodeMaterialConnectionPoint;
  64207. /**
  64208. * Gets the input angle
  64209. */
  64210. get angle(): NodeMaterialConnectionPoint;
  64211. /**
  64212. * Gets the output component
  64213. */
  64214. get output(): NodeMaterialConnectionPoint;
  64215. autoConfigure(material: NodeMaterial): void;
  64216. protected _buildBlock(state: NodeMaterialBuildState): this;
  64217. }
  64218. }
  64219. declare module BABYLON {
  64220. /**
  64221. * Block used to get the reflected vector from a direction and a normal
  64222. */
  64223. export class ReflectBlock extends NodeMaterialBlock {
  64224. /**
  64225. * Creates a new ReflectBlock
  64226. * @param name defines the block name
  64227. */
  64228. constructor(name: string);
  64229. /**
  64230. * Gets the current class name
  64231. * @returns the class name
  64232. */
  64233. getClassName(): string;
  64234. /**
  64235. * Gets the incident component
  64236. */
  64237. get incident(): NodeMaterialConnectionPoint;
  64238. /**
  64239. * Gets the normal component
  64240. */
  64241. get normal(): NodeMaterialConnectionPoint;
  64242. /**
  64243. * Gets the output component
  64244. */
  64245. get output(): NodeMaterialConnectionPoint;
  64246. protected _buildBlock(state: NodeMaterialBuildState): this;
  64247. }
  64248. }
  64249. declare module BABYLON {
  64250. /**
  64251. * Block used to get the refracted vector from a direction and a normal
  64252. */
  64253. export class RefractBlock extends NodeMaterialBlock {
  64254. /**
  64255. * Creates a new RefractBlock
  64256. * @param name defines the block name
  64257. */
  64258. constructor(name: string);
  64259. /**
  64260. * Gets the current class name
  64261. * @returns the class name
  64262. */
  64263. getClassName(): string;
  64264. /**
  64265. * Gets the incident component
  64266. */
  64267. get incident(): NodeMaterialConnectionPoint;
  64268. /**
  64269. * Gets the normal component
  64270. */
  64271. get normal(): NodeMaterialConnectionPoint;
  64272. /**
  64273. * Gets the index of refraction component
  64274. */
  64275. get ior(): NodeMaterialConnectionPoint;
  64276. /**
  64277. * Gets the output component
  64278. */
  64279. get output(): NodeMaterialConnectionPoint;
  64280. protected _buildBlock(state: NodeMaterialBuildState): this;
  64281. }
  64282. }
  64283. declare module BABYLON {
  64284. /**
  64285. * Block used to desaturate a color
  64286. */
  64287. export class DesaturateBlock extends NodeMaterialBlock {
  64288. /**
  64289. * Creates a new DesaturateBlock
  64290. * @param name defines the block name
  64291. */
  64292. constructor(name: string);
  64293. /**
  64294. * Gets the current class name
  64295. * @returns the class name
  64296. */
  64297. getClassName(): string;
  64298. /**
  64299. * Gets the color operand input component
  64300. */
  64301. get color(): NodeMaterialConnectionPoint;
  64302. /**
  64303. * Gets the level operand input component
  64304. */
  64305. get level(): NodeMaterialConnectionPoint;
  64306. /**
  64307. * Gets the output component
  64308. */
  64309. get output(): NodeMaterialConnectionPoint;
  64310. protected _buildBlock(state: NodeMaterialBuildState): this;
  64311. }
  64312. }
  64313. declare module BABYLON {
  64314. /**
  64315. * Block used to implement the ambient occlusion module of the PBR material
  64316. */
  64317. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64318. /**
  64319. * Create a new AmbientOcclusionBlock
  64320. * @param name defines the block name
  64321. */
  64322. constructor(name: string);
  64323. /**
  64324. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64325. */
  64326. useAmbientInGrayScale: boolean;
  64327. /**
  64328. * Initialize the block and prepare the context for build
  64329. * @param state defines the state that will be used for the build
  64330. */
  64331. initialize(state: NodeMaterialBuildState): void;
  64332. /**
  64333. * Gets the current class name
  64334. * @returns the class name
  64335. */
  64336. getClassName(): string;
  64337. /**
  64338. * Gets the texture input component
  64339. */
  64340. get texture(): NodeMaterialConnectionPoint;
  64341. /**
  64342. * Gets the texture intensity component
  64343. */
  64344. get intensity(): NodeMaterialConnectionPoint;
  64345. /**
  64346. * Gets the direct light intensity input component
  64347. */
  64348. get directLightIntensity(): NodeMaterialConnectionPoint;
  64349. /**
  64350. * Gets the ambient occlusion object output component
  64351. */
  64352. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64353. /**
  64354. * Gets the main code of the block (fragment side)
  64355. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64356. * @returns the shader code
  64357. */
  64358. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64359. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64360. protected _buildBlock(state: NodeMaterialBuildState): this;
  64361. protected _dumpPropertiesCode(): string;
  64362. serialize(): any;
  64363. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64364. }
  64365. }
  64366. declare module BABYLON {
  64367. /**
  64368. * Block used to implement the reflection module of the PBR material
  64369. */
  64370. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64371. /** @hidden */
  64372. _defineLODReflectionAlpha: string;
  64373. /** @hidden */
  64374. _defineLinearSpecularReflection: string;
  64375. private _vEnvironmentIrradianceName;
  64376. /** @hidden */
  64377. _vReflectionMicrosurfaceInfosName: string;
  64378. /** @hidden */
  64379. _vReflectionInfosName: string;
  64380. /** @hidden */
  64381. _vReflectionFilteringInfoName: string;
  64382. private _scene;
  64383. /**
  64384. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64385. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64386. * It's less burden on the user side in the editor part.
  64387. */
  64388. /** @hidden */
  64389. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64390. /** @hidden */
  64391. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64392. /** @hidden */
  64393. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64394. /**
  64395. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64396. * diffuse part of the IBL.
  64397. */
  64398. useSphericalHarmonics: boolean;
  64399. /**
  64400. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64401. */
  64402. forceIrradianceInFragment: boolean;
  64403. /**
  64404. * Create a new ReflectionBlock
  64405. * @param name defines the block name
  64406. */
  64407. constructor(name: string);
  64408. /**
  64409. * Gets the current class name
  64410. * @returns the class name
  64411. */
  64412. getClassName(): string;
  64413. /**
  64414. * Gets the position input component
  64415. */
  64416. get position(): NodeMaterialConnectionPoint;
  64417. /**
  64418. * Gets the world position input component
  64419. */
  64420. get worldPosition(): NodeMaterialConnectionPoint;
  64421. /**
  64422. * Gets the world normal input component
  64423. */
  64424. get worldNormal(): NodeMaterialConnectionPoint;
  64425. /**
  64426. * Gets the world input component
  64427. */
  64428. get world(): NodeMaterialConnectionPoint;
  64429. /**
  64430. * Gets the camera (or eye) position component
  64431. */
  64432. get cameraPosition(): NodeMaterialConnectionPoint;
  64433. /**
  64434. * Gets the view input component
  64435. */
  64436. get view(): NodeMaterialConnectionPoint;
  64437. /**
  64438. * Gets the color input component
  64439. */
  64440. get color(): NodeMaterialConnectionPoint;
  64441. /**
  64442. * Gets the reflection object output component
  64443. */
  64444. get reflection(): NodeMaterialConnectionPoint;
  64445. /**
  64446. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64447. */
  64448. get hasTexture(): boolean;
  64449. /**
  64450. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64451. */
  64452. get reflectionColor(): string;
  64453. protected _getTexture(): Nullable<BaseTexture>;
  64454. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64455. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64456. /**
  64457. * Gets the code to inject in the vertex shader
  64458. * @param state current state of the node material building
  64459. * @returns the shader code
  64460. */
  64461. handleVertexSide(state: NodeMaterialBuildState): string;
  64462. /**
  64463. * Gets the main code of the block (fragment side)
  64464. * @param state current state of the node material building
  64465. * @param normalVarName name of the existing variable corresponding to the normal
  64466. * @returns the shader code
  64467. */
  64468. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64469. protected _buildBlock(state: NodeMaterialBuildState): this;
  64470. protected _dumpPropertiesCode(): string;
  64471. serialize(): any;
  64472. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64473. }
  64474. }
  64475. declare module BABYLON {
  64476. /**
  64477. * Block used to implement the sheen module of the PBR material
  64478. */
  64479. export class SheenBlock extends NodeMaterialBlock {
  64480. /**
  64481. * Create a new SheenBlock
  64482. * @param name defines the block name
  64483. */
  64484. constructor(name: string);
  64485. /**
  64486. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64487. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64488. * making it easier to setup and tweak the effect
  64489. */
  64490. albedoScaling: boolean;
  64491. /**
  64492. * Defines if the sheen is linked to the sheen color.
  64493. */
  64494. linkSheenWithAlbedo: boolean;
  64495. /**
  64496. * Initialize the block and prepare the context for build
  64497. * @param state defines the state that will be used for the build
  64498. */
  64499. initialize(state: NodeMaterialBuildState): void;
  64500. /**
  64501. * Gets the current class name
  64502. * @returns the class name
  64503. */
  64504. getClassName(): string;
  64505. /**
  64506. * Gets the intensity input component
  64507. */
  64508. get intensity(): NodeMaterialConnectionPoint;
  64509. /**
  64510. * Gets the color input component
  64511. */
  64512. get color(): NodeMaterialConnectionPoint;
  64513. /**
  64514. * Gets the roughness input component
  64515. */
  64516. get roughness(): NodeMaterialConnectionPoint;
  64517. /**
  64518. * Gets the sheen object output component
  64519. */
  64520. get sheen(): NodeMaterialConnectionPoint;
  64521. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64522. /**
  64523. * Gets the main code of the block (fragment side)
  64524. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64525. * @returns the shader code
  64526. */
  64527. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64528. protected _buildBlock(state: NodeMaterialBuildState): this;
  64529. protected _dumpPropertiesCode(): string;
  64530. serialize(): any;
  64531. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64532. }
  64533. }
  64534. declare module BABYLON {
  64535. /**
  64536. * Block used to implement the reflectivity module of the PBR material
  64537. */
  64538. export class ReflectivityBlock extends NodeMaterialBlock {
  64539. private _metallicReflectanceColor;
  64540. private _metallicF0Factor;
  64541. /** @hidden */
  64542. _vMetallicReflectanceFactorsName: string;
  64543. /**
  64544. * The property below is set by the main PBR block prior to calling methods of this class.
  64545. */
  64546. /** @hidden */
  64547. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64548. /**
  64549. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64550. */
  64551. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64552. /**
  64553. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64554. */
  64555. useMetallnessFromMetallicTextureBlue: boolean;
  64556. /**
  64557. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64558. */
  64559. useRoughnessFromMetallicTextureAlpha: boolean;
  64560. /**
  64561. * Specifies if the metallic texture contains the roughness information in its green channel.
  64562. */
  64563. useRoughnessFromMetallicTextureGreen: boolean;
  64564. /**
  64565. * Create a new ReflectivityBlock
  64566. * @param name defines the block name
  64567. */
  64568. constructor(name: string);
  64569. /**
  64570. * Initialize the block and prepare the context for build
  64571. * @param state defines the state that will be used for the build
  64572. */
  64573. initialize(state: NodeMaterialBuildState): void;
  64574. /**
  64575. * Gets the current class name
  64576. * @returns the class name
  64577. */
  64578. getClassName(): string;
  64579. /**
  64580. * Gets the metallic input component
  64581. */
  64582. get metallic(): NodeMaterialConnectionPoint;
  64583. /**
  64584. * Gets the roughness input component
  64585. */
  64586. get roughness(): NodeMaterialConnectionPoint;
  64587. /**
  64588. * Gets the texture input component
  64589. */
  64590. get texture(): NodeMaterialConnectionPoint;
  64591. /**
  64592. * Gets the reflectivity object output component
  64593. */
  64594. get reflectivity(): NodeMaterialConnectionPoint;
  64595. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64596. /**
  64597. * Gets the main code of the block (fragment side)
  64598. * @param state current state of the node material building
  64599. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64600. * @returns the shader code
  64601. */
  64602. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64603. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64604. protected _buildBlock(state: NodeMaterialBuildState): this;
  64605. protected _dumpPropertiesCode(): string;
  64606. serialize(): any;
  64607. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64608. }
  64609. }
  64610. declare module BABYLON {
  64611. /**
  64612. * Block used to implement the anisotropy module of the PBR material
  64613. */
  64614. export class AnisotropyBlock extends NodeMaterialBlock {
  64615. /**
  64616. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64617. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64618. * It's less burden on the user side in the editor part.
  64619. */
  64620. /** @hidden */
  64621. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64622. /** @hidden */
  64623. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64624. /**
  64625. * Create a new AnisotropyBlock
  64626. * @param name defines the block name
  64627. */
  64628. constructor(name: string);
  64629. /**
  64630. * Initialize the block and prepare the context for build
  64631. * @param state defines the state that will be used for the build
  64632. */
  64633. initialize(state: NodeMaterialBuildState): void;
  64634. /**
  64635. * Gets the current class name
  64636. * @returns the class name
  64637. */
  64638. getClassName(): string;
  64639. /**
  64640. * Gets the intensity input component
  64641. */
  64642. get intensity(): NodeMaterialConnectionPoint;
  64643. /**
  64644. * Gets the direction input component
  64645. */
  64646. get direction(): NodeMaterialConnectionPoint;
  64647. /**
  64648. * Gets the texture input component
  64649. */
  64650. get texture(): NodeMaterialConnectionPoint;
  64651. /**
  64652. * Gets the uv input component
  64653. */
  64654. get uv(): NodeMaterialConnectionPoint;
  64655. /**
  64656. * Gets the worldTangent input component
  64657. */
  64658. get worldTangent(): NodeMaterialConnectionPoint;
  64659. /**
  64660. * Gets the anisotropy object output component
  64661. */
  64662. get anisotropy(): NodeMaterialConnectionPoint;
  64663. private _generateTBNSpace;
  64664. /**
  64665. * Gets the main code of the block (fragment side)
  64666. * @param state current state of the node material building
  64667. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64668. * @returns the shader code
  64669. */
  64670. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64672. protected _buildBlock(state: NodeMaterialBuildState): this;
  64673. }
  64674. }
  64675. declare module BABYLON {
  64676. /**
  64677. * Block used to implement the clear coat module of the PBR material
  64678. */
  64679. export class ClearCoatBlock extends NodeMaterialBlock {
  64680. private _scene;
  64681. /**
  64682. * Create a new ClearCoatBlock
  64683. * @param name defines the block name
  64684. */
  64685. constructor(name: string);
  64686. /**
  64687. * Initialize the block and prepare the context for build
  64688. * @param state defines the state that will be used for the build
  64689. */
  64690. initialize(state: NodeMaterialBuildState): void;
  64691. /**
  64692. * Gets the current class name
  64693. * @returns the class name
  64694. */
  64695. getClassName(): string;
  64696. /**
  64697. * Gets the intensity input component
  64698. */
  64699. get intensity(): NodeMaterialConnectionPoint;
  64700. /**
  64701. * Gets the roughness input component
  64702. */
  64703. get roughness(): NodeMaterialConnectionPoint;
  64704. /**
  64705. * Gets the ior input component
  64706. */
  64707. get ior(): NodeMaterialConnectionPoint;
  64708. /**
  64709. * Gets the texture input component
  64710. */
  64711. get texture(): NodeMaterialConnectionPoint;
  64712. /**
  64713. * Gets the bump texture input component
  64714. */
  64715. get bumpTexture(): NodeMaterialConnectionPoint;
  64716. /**
  64717. * Gets the uv input component
  64718. */
  64719. get uv(): NodeMaterialConnectionPoint;
  64720. /**
  64721. * Gets the tint color input component
  64722. */
  64723. get tintColor(): NodeMaterialConnectionPoint;
  64724. /**
  64725. * Gets the tint "at distance" input component
  64726. */
  64727. get tintAtDistance(): NodeMaterialConnectionPoint;
  64728. /**
  64729. * Gets the tint thickness input component
  64730. */
  64731. get tintThickness(): NodeMaterialConnectionPoint;
  64732. /**
  64733. * Gets the world tangent input component
  64734. */
  64735. get worldTangent(): NodeMaterialConnectionPoint;
  64736. /**
  64737. * Gets the clear coat object output component
  64738. */
  64739. get clearcoat(): NodeMaterialConnectionPoint;
  64740. autoConfigure(material: NodeMaterial): void;
  64741. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64742. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64743. private _generateTBNSpace;
  64744. /**
  64745. * Gets the main code of the block (fragment side)
  64746. * @param state current state of the node material building
  64747. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64748. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64749. * @param worldPosVarName name of the variable holding the world position
  64750. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64751. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64752. * @param worldNormalVarName name of the variable holding the world normal
  64753. * @returns the shader code
  64754. */
  64755. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64756. protected _buildBlock(state: NodeMaterialBuildState): this;
  64757. }
  64758. }
  64759. declare module BABYLON {
  64760. /**
  64761. * Block used to implement the sub surface module of the PBR material
  64762. */
  64763. export class SubSurfaceBlock extends NodeMaterialBlock {
  64764. /**
  64765. * Create a new SubSurfaceBlock
  64766. * @param name defines the block name
  64767. */
  64768. constructor(name: string);
  64769. /**
  64770. * Stores the intensity of the different subsurface effects in the thickness texture.
  64771. * * the green channel is the translucency intensity.
  64772. * * the blue channel is the scattering intensity.
  64773. * * the alpha channel is the refraction intensity.
  64774. */
  64775. useMaskFromThicknessTexture: boolean;
  64776. /**
  64777. * Initialize the block and prepare the context for build
  64778. * @param state defines the state that will be used for the build
  64779. */
  64780. initialize(state: NodeMaterialBuildState): void;
  64781. /**
  64782. * Gets the current class name
  64783. * @returns the class name
  64784. */
  64785. getClassName(): string;
  64786. /**
  64787. * Gets the min thickness input component
  64788. */
  64789. get minThickness(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the max thickness input component
  64792. */
  64793. get maxThickness(): NodeMaterialConnectionPoint;
  64794. /**
  64795. * Gets the thickness texture component
  64796. */
  64797. get thicknessTexture(): NodeMaterialConnectionPoint;
  64798. /**
  64799. * Gets the tint color input component
  64800. */
  64801. get tintColor(): NodeMaterialConnectionPoint;
  64802. /**
  64803. * Gets the translucency intensity input component
  64804. */
  64805. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64806. /**
  64807. * Gets the translucency diffusion distance input component
  64808. */
  64809. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64810. /**
  64811. * Gets the refraction object parameters
  64812. */
  64813. get refraction(): NodeMaterialConnectionPoint;
  64814. /**
  64815. * Gets the sub surface object output component
  64816. */
  64817. get subsurface(): NodeMaterialConnectionPoint;
  64818. autoConfigure(material: NodeMaterial): void;
  64819. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64820. /**
  64821. * Gets the main code of the block (fragment side)
  64822. * @param state current state of the node material building
  64823. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64824. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64825. * @param worldPosVarName name of the variable holding the world position
  64826. * @returns the shader code
  64827. */
  64828. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64829. protected _buildBlock(state: NodeMaterialBuildState): this;
  64830. }
  64831. }
  64832. declare module BABYLON {
  64833. /**
  64834. * Block used to implement the PBR metallic/roughness model
  64835. */
  64836. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64837. /**
  64838. * Gets or sets the light associated with this block
  64839. */
  64840. light: Nullable<Light>;
  64841. private _lightId;
  64842. private _scene;
  64843. private _environmentBRDFTexture;
  64844. private _environmentBrdfSamplerName;
  64845. private _vNormalWName;
  64846. private _invertNormalName;
  64847. /**
  64848. * Create a new ReflectionBlock
  64849. * @param name defines the block name
  64850. */
  64851. constructor(name: string);
  64852. /**
  64853. * Intensity of the direct lights e.g. the four lights available in your scene.
  64854. * This impacts both the direct diffuse and specular highlights.
  64855. */
  64856. directIntensity: number;
  64857. /**
  64858. * Intensity of the environment e.g. how much the environment will light the object
  64859. * either through harmonics for rough material or through the refelction for shiny ones.
  64860. */
  64861. environmentIntensity: number;
  64862. /**
  64863. * This is a special control allowing the reduction of the specular highlights coming from the
  64864. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64865. */
  64866. specularIntensity: number;
  64867. /**
  64868. * Defines the falloff type used in this material.
  64869. * It by default is Physical.
  64870. */
  64871. lightFalloff: number;
  64872. /**
  64873. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64874. */
  64875. useAlphaFromAlbedoTexture: boolean;
  64876. /**
  64877. * Specifies that alpha test should be used
  64878. */
  64879. useAlphaTest: boolean;
  64880. /**
  64881. * Defines the alpha limits in alpha test mode.
  64882. */
  64883. alphaTestCutoff: number;
  64884. /**
  64885. * Specifies that alpha blending should be used
  64886. */
  64887. useAlphaBlending: boolean;
  64888. /**
  64889. * Defines if the alpha value should be determined via the rgb values.
  64890. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64891. */
  64892. opacityRGB: boolean;
  64893. /**
  64894. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64895. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64896. */
  64897. useRadianceOverAlpha: boolean;
  64898. /**
  64899. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64900. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64901. */
  64902. useSpecularOverAlpha: boolean;
  64903. /**
  64904. * Enables specular anti aliasing in the PBR shader.
  64905. * It will both interacts on the Geometry for analytical and IBL lighting.
  64906. * It also prefilter the roughness map based on the bump values.
  64907. */
  64908. enableSpecularAntiAliasing: boolean;
  64909. /**
  64910. * Enables realtime filtering on the texture.
  64911. */
  64912. realTimeFiltering: boolean;
  64913. /**
  64914. * Quality switch for realtime filtering
  64915. */
  64916. realTimeFilteringQuality: number;
  64917. /**
  64918. * Defines if the material uses energy conservation.
  64919. */
  64920. useEnergyConservation: boolean;
  64921. /**
  64922. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64923. * too much the area relying on ambient texture to define their ambient occlusion.
  64924. */
  64925. useRadianceOcclusion: boolean;
  64926. /**
  64927. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64928. * makes the reflect vector face the model (under horizon).
  64929. */
  64930. useHorizonOcclusion: boolean;
  64931. /**
  64932. * If set to true, no lighting calculations will be applied.
  64933. */
  64934. unlit: boolean;
  64935. /**
  64936. * Force normal to face away from face.
  64937. */
  64938. forceNormalForward: boolean;
  64939. /**
  64940. * Defines the material debug mode.
  64941. * It helps seeing only some components of the material while troubleshooting.
  64942. */
  64943. debugMode: number;
  64944. /**
  64945. * Specify from where on screen the debug mode should start.
  64946. * The value goes from -1 (full screen) to 1 (not visible)
  64947. * It helps with side by side comparison against the final render
  64948. * This defaults to 0
  64949. */
  64950. debugLimit: number;
  64951. /**
  64952. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64953. * You can use the factor to better multiply the final value.
  64954. */
  64955. debugFactor: number;
  64956. /**
  64957. * Initialize the block and prepare the context for build
  64958. * @param state defines the state that will be used for the build
  64959. */
  64960. initialize(state: NodeMaterialBuildState): void;
  64961. /**
  64962. * Gets the current class name
  64963. * @returns the class name
  64964. */
  64965. getClassName(): string;
  64966. /**
  64967. * Gets the world position input component
  64968. */
  64969. get worldPosition(): NodeMaterialConnectionPoint;
  64970. /**
  64971. * Gets the world normal input component
  64972. */
  64973. get worldNormal(): NodeMaterialConnectionPoint;
  64974. /**
  64975. * Gets the perturbed normal input component
  64976. */
  64977. get perturbedNormal(): NodeMaterialConnectionPoint;
  64978. /**
  64979. * Gets the camera position input component
  64980. */
  64981. get cameraPosition(): NodeMaterialConnectionPoint;
  64982. /**
  64983. * Gets the base color input component
  64984. */
  64985. get baseColor(): NodeMaterialConnectionPoint;
  64986. /**
  64987. * Gets the opacity texture input component
  64988. */
  64989. get opacityTexture(): NodeMaterialConnectionPoint;
  64990. /**
  64991. * Gets the ambient color input component
  64992. */
  64993. get ambientColor(): NodeMaterialConnectionPoint;
  64994. /**
  64995. * Gets the reflectivity object parameters
  64996. */
  64997. get reflectivity(): NodeMaterialConnectionPoint;
  64998. /**
  64999. * Gets the ambient occlusion object parameters
  65000. */
  65001. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65002. /**
  65003. * Gets the reflection object parameters
  65004. */
  65005. get reflection(): NodeMaterialConnectionPoint;
  65006. /**
  65007. * Gets the sheen object parameters
  65008. */
  65009. get sheen(): NodeMaterialConnectionPoint;
  65010. /**
  65011. * Gets the clear coat object parameters
  65012. */
  65013. get clearcoat(): NodeMaterialConnectionPoint;
  65014. /**
  65015. * Gets the sub surface object parameters
  65016. */
  65017. get subsurface(): NodeMaterialConnectionPoint;
  65018. /**
  65019. * Gets the anisotropy object parameters
  65020. */
  65021. get anisotropy(): NodeMaterialConnectionPoint;
  65022. /**
  65023. * Gets the ambient output component
  65024. */
  65025. get ambient(): NodeMaterialConnectionPoint;
  65026. /**
  65027. * Gets the diffuse output component
  65028. */
  65029. get diffuse(): NodeMaterialConnectionPoint;
  65030. /**
  65031. * Gets the specular output component
  65032. */
  65033. get specular(): NodeMaterialConnectionPoint;
  65034. /**
  65035. * Gets the sheen output component
  65036. */
  65037. get sheenDir(): NodeMaterialConnectionPoint;
  65038. /**
  65039. * Gets the clear coat output component
  65040. */
  65041. get clearcoatDir(): NodeMaterialConnectionPoint;
  65042. /**
  65043. * Gets the indirect diffuse output component
  65044. */
  65045. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65046. /**
  65047. * Gets the indirect specular output component
  65048. */
  65049. get specularIndirect(): NodeMaterialConnectionPoint;
  65050. /**
  65051. * Gets the indirect sheen output component
  65052. */
  65053. get sheenIndirect(): NodeMaterialConnectionPoint;
  65054. /**
  65055. * Gets the indirect clear coat output component
  65056. */
  65057. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65058. /**
  65059. * Gets the refraction output component
  65060. */
  65061. get refraction(): NodeMaterialConnectionPoint;
  65062. /**
  65063. * Gets the global lighting output component
  65064. */
  65065. get lighting(): NodeMaterialConnectionPoint;
  65066. /**
  65067. * Gets the shadow output component
  65068. */
  65069. get shadow(): NodeMaterialConnectionPoint;
  65070. /**
  65071. * Gets the alpha output component
  65072. */
  65073. get alpha(): NodeMaterialConnectionPoint;
  65074. autoConfigure(material: NodeMaterial): void;
  65075. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65076. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65077. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65078. private _injectVertexCode;
  65079. /**
  65080. * Gets the code corresponding to the albedo/opacity module
  65081. * @returns the shader code
  65082. */
  65083. getAlbedoOpacityCode(): string;
  65084. protected _buildBlock(state: NodeMaterialBuildState): this;
  65085. protected _dumpPropertiesCode(): string;
  65086. serialize(): any;
  65087. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65088. }
  65089. }
  65090. declare module BABYLON {
  65091. /**
  65092. * Block used to compute value of one parameter modulo another
  65093. */
  65094. export class ModBlock extends NodeMaterialBlock {
  65095. /**
  65096. * Creates a new ModBlock
  65097. * @param name defines the block name
  65098. */
  65099. constructor(name: string);
  65100. /**
  65101. * Gets the current class name
  65102. * @returns the class name
  65103. */
  65104. getClassName(): string;
  65105. /**
  65106. * Gets the left operand input component
  65107. */
  65108. get left(): NodeMaterialConnectionPoint;
  65109. /**
  65110. * Gets the right operand input component
  65111. */
  65112. get right(): NodeMaterialConnectionPoint;
  65113. /**
  65114. * Gets the output component
  65115. */
  65116. get output(): NodeMaterialConnectionPoint;
  65117. protected _buildBlock(state: NodeMaterialBuildState): this;
  65118. }
  65119. }
  65120. declare module BABYLON {
  65121. /**
  65122. * Configuration for Draco compression
  65123. */
  65124. export interface IDracoCompressionConfiguration {
  65125. /**
  65126. * Configuration for the decoder.
  65127. */
  65128. decoder: {
  65129. /**
  65130. * The url to the WebAssembly module.
  65131. */
  65132. wasmUrl?: string;
  65133. /**
  65134. * The url to the WebAssembly binary.
  65135. */
  65136. wasmBinaryUrl?: string;
  65137. /**
  65138. * The url to the fallback JavaScript module.
  65139. */
  65140. fallbackUrl?: string;
  65141. };
  65142. }
  65143. /**
  65144. * Draco compression (https://google.github.io/draco/)
  65145. *
  65146. * This class wraps the Draco module.
  65147. *
  65148. * **Encoder**
  65149. *
  65150. * The encoder is not currently implemented.
  65151. *
  65152. * **Decoder**
  65153. *
  65154. * 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.
  65155. *
  65156. * To update the configuration, use the following code:
  65157. * ```javascript
  65158. * DracoCompression.Configuration = {
  65159. * decoder: {
  65160. * wasmUrl: "<url to the WebAssembly library>",
  65161. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65162. * fallbackUrl: "<url to the fallback JavaScript library>",
  65163. * }
  65164. * };
  65165. * ```
  65166. *
  65167. * 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.
  65168. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65169. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65170. *
  65171. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65172. * ```javascript
  65173. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65174. * ```
  65175. *
  65176. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65177. */
  65178. export class DracoCompression implements IDisposable {
  65179. private _workerPoolPromise?;
  65180. private _decoderModulePromise?;
  65181. /**
  65182. * The configuration. Defaults to the following urls:
  65183. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65184. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65185. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65186. */
  65187. static Configuration: IDracoCompressionConfiguration;
  65188. /**
  65189. * Returns true if the decoder configuration is available.
  65190. */
  65191. static get DecoderAvailable(): boolean;
  65192. /**
  65193. * Default number of workers to create when creating the draco compression object.
  65194. */
  65195. static DefaultNumWorkers: number;
  65196. private static GetDefaultNumWorkers;
  65197. private static _Default;
  65198. /**
  65199. * Default instance for the draco compression object.
  65200. */
  65201. static get Default(): DracoCompression;
  65202. /**
  65203. * Constructor
  65204. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65205. */
  65206. constructor(numWorkers?: number);
  65207. /**
  65208. * Stop all async operations and release resources.
  65209. */
  65210. dispose(): void;
  65211. /**
  65212. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65213. * @returns a promise that resolves when ready
  65214. */
  65215. whenReadyAsync(): Promise<void>;
  65216. /**
  65217. * Decode Draco compressed mesh data to vertex data.
  65218. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65219. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65220. * @returns A promise that resolves with the decoded vertex data
  65221. */
  65222. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65223. [kind: string]: number;
  65224. }): Promise<VertexData>;
  65225. }
  65226. }
  65227. declare module BABYLON {
  65228. /**
  65229. * Class for building Constructive Solid Geometry
  65230. */
  65231. export class CSG {
  65232. private polygons;
  65233. /**
  65234. * The world matrix
  65235. */
  65236. matrix: Matrix;
  65237. /**
  65238. * Stores the position
  65239. */
  65240. position: Vector3;
  65241. /**
  65242. * Stores the rotation
  65243. */
  65244. rotation: Vector3;
  65245. /**
  65246. * Stores the rotation quaternion
  65247. */
  65248. rotationQuaternion: Nullable<Quaternion>;
  65249. /**
  65250. * Stores the scaling vector
  65251. */
  65252. scaling: Vector3;
  65253. /**
  65254. * Convert the Mesh to CSG
  65255. * @param mesh The Mesh to convert to CSG
  65256. * @returns A new CSG from the Mesh
  65257. */
  65258. static FromMesh(mesh: Mesh): CSG;
  65259. /**
  65260. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65261. * @param polygons Polygons used to construct a CSG solid
  65262. */
  65263. private static FromPolygons;
  65264. /**
  65265. * Clones, or makes a deep copy, of the CSG
  65266. * @returns A new CSG
  65267. */
  65268. clone(): CSG;
  65269. /**
  65270. * Unions this CSG with another CSG
  65271. * @param csg The CSG to union against this CSG
  65272. * @returns The unioned CSG
  65273. */
  65274. union(csg: CSG): CSG;
  65275. /**
  65276. * Unions this CSG with another CSG in place
  65277. * @param csg The CSG to union against this CSG
  65278. */
  65279. unionInPlace(csg: CSG): void;
  65280. /**
  65281. * Subtracts this CSG with another CSG
  65282. * @param csg The CSG to subtract against this CSG
  65283. * @returns A new CSG
  65284. */
  65285. subtract(csg: CSG): CSG;
  65286. /**
  65287. * Subtracts this CSG with another CSG in place
  65288. * @param csg The CSG to subtact against this CSG
  65289. */
  65290. subtractInPlace(csg: CSG): void;
  65291. /**
  65292. * Intersect this CSG with another CSG
  65293. * @param csg The CSG to intersect against this CSG
  65294. * @returns A new CSG
  65295. */
  65296. intersect(csg: CSG): CSG;
  65297. /**
  65298. * Intersects this CSG with another CSG in place
  65299. * @param csg The CSG to intersect against this CSG
  65300. */
  65301. intersectInPlace(csg: CSG): void;
  65302. /**
  65303. * Return a new CSG solid with solid and empty space switched. This solid is
  65304. * not modified.
  65305. * @returns A new CSG solid with solid and empty space switched
  65306. */
  65307. inverse(): CSG;
  65308. /**
  65309. * Inverses the CSG in place
  65310. */
  65311. inverseInPlace(): void;
  65312. /**
  65313. * This is used to keep meshes transformations so they can be restored
  65314. * when we build back a Babylon Mesh
  65315. * NB : All CSG operations are performed in world coordinates
  65316. * @param csg The CSG to copy the transform attributes from
  65317. * @returns This CSG
  65318. */
  65319. copyTransformAttributes(csg: CSG): CSG;
  65320. /**
  65321. * Build Raw mesh from CSG
  65322. * Coordinates here are in world space
  65323. * @param name The name of the mesh geometry
  65324. * @param scene The Scene
  65325. * @param keepSubMeshes Specifies if the submeshes should be kept
  65326. * @returns A new Mesh
  65327. */
  65328. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65329. /**
  65330. * Build Mesh from CSG taking material and transforms into account
  65331. * @param name The name of the Mesh
  65332. * @param material The material of the Mesh
  65333. * @param scene The Scene
  65334. * @param keepSubMeshes Specifies if submeshes should be kept
  65335. * @returns The new Mesh
  65336. */
  65337. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65338. }
  65339. }
  65340. declare module BABYLON {
  65341. /**
  65342. * Class used to create a trail following a mesh
  65343. */
  65344. export class TrailMesh extends Mesh {
  65345. private _generator;
  65346. private _autoStart;
  65347. private _running;
  65348. private _diameter;
  65349. private _length;
  65350. private _sectionPolygonPointsCount;
  65351. private _sectionVectors;
  65352. private _sectionNormalVectors;
  65353. private _beforeRenderObserver;
  65354. /**
  65355. * @constructor
  65356. * @param name The value used by scene.getMeshByName() to do a lookup.
  65357. * @param generator The mesh or transform node to generate a trail.
  65358. * @param scene The scene to add this mesh to.
  65359. * @param diameter Diameter of trailing mesh. Default is 1.
  65360. * @param length Length of trailing mesh. Default is 60.
  65361. * @param autoStart Automatically start trailing mesh. Default true.
  65362. */
  65363. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65364. /**
  65365. * "TrailMesh"
  65366. * @returns "TrailMesh"
  65367. */
  65368. getClassName(): string;
  65369. private _createMesh;
  65370. /**
  65371. * Start trailing mesh.
  65372. */
  65373. start(): void;
  65374. /**
  65375. * Stop trailing mesh.
  65376. */
  65377. stop(): void;
  65378. /**
  65379. * Update trailing mesh geometry.
  65380. */
  65381. update(): void;
  65382. /**
  65383. * Returns a new TrailMesh object.
  65384. * @param name is a string, the name given to the new mesh
  65385. * @param newGenerator use new generator object for cloned trail mesh
  65386. * @returns a new mesh
  65387. */
  65388. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65389. /**
  65390. * Serializes this trail mesh
  65391. * @param serializationObject object to write serialization to
  65392. */
  65393. serialize(serializationObject: any): void;
  65394. /**
  65395. * Parses a serialized trail mesh
  65396. * @param parsedMesh the serialized mesh
  65397. * @param scene the scene to create the trail mesh in
  65398. * @returns the created trail mesh
  65399. */
  65400. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65401. }
  65402. }
  65403. declare module BABYLON {
  65404. /**
  65405. * Class containing static functions to help procedurally build meshes
  65406. */
  65407. export class TiledBoxBuilder {
  65408. /**
  65409. * Creates a box mesh
  65410. * 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)
  65411. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65413. * * 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
  65414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65415. * @param name defines the name of the mesh
  65416. * @param options defines the options used to create the mesh
  65417. * @param scene defines the hosting scene
  65418. * @returns the box mesh
  65419. */
  65420. static CreateTiledBox(name: string, options: {
  65421. pattern?: number;
  65422. width?: number;
  65423. height?: number;
  65424. depth?: number;
  65425. tileSize?: number;
  65426. tileWidth?: number;
  65427. tileHeight?: number;
  65428. alignHorizontal?: number;
  65429. alignVertical?: number;
  65430. faceUV?: Vector4[];
  65431. faceColors?: Color4[];
  65432. sideOrientation?: number;
  65433. updatable?: boolean;
  65434. }, scene?: Nullable<Scene>): Mesh;
  65435. }
  65436. }
  65437. declare module BABYLON {
  65438. /**
  65439. * Class containing static functions to help procedurally build meshes
  65440. */
  65441. export class TorusKnotBuilder {
  65442. /**
  65443. * Creates a torus knot mesh
  65444. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65445. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65446. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65447. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65449. * * 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
  65450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65451. * @param name defines the name of the mesh
  65452. * @param options defines the options used to create the mesh
  65453. * @param scene defines the hosting scene
  65454. * @returns the torus knot mesh
  65455. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65456. */
  65457. static CreateTorusKnot(name: string, options: {
  65458. radius?: number;
  65459. tube?: number;
  65460. radialSegments?: number;
  65461. tubularSegments?: number;
  65462. p?: number;
  65463. q?: number;
  65464. updatable?: boolean;
  65465. sideOrientation?: number;
  65466. frontUVs?: Vector4;
  65467. backUVs?: Vector4;
  65468. }, scene: any): Mesh;
  65469. }
  65470. }
  65471. declare module BABYLON {
  65472. /**
  65473. * Polygon
  65474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65475. */
  65476. export class Polygon {
  65477. /**
  65478. * Creates a rectangle
  65479. * @param xmin bottom X coord
  65480. * @param ymin bottom Y coord
  65481. * @param xmax top X coord
  65482. * @param ymax top Y coord
  65483. * @returns points that make the resulting rectation
  65484. */
  65485. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65486. /**
  65487. * Creates a circle
  65488. * @param radius radius of circle
  65489. * @param cx scale in x
  65490. * @param cy scale in y
  65491. * @param numberOfSides number of sides that make up the circle
  65492. * @returns points that make the resulting circle
  65493. */
  65494. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65495. /**
  65496. * Creates a polygon from input string
  65497. * @param input Input polygon data
  65498. * @returns the parsed points
  65499. */
  65500. static Parse(input: string): Vector2[];
  65501. /**
  65502. * Starts building a polygon from x and y coordinates
  65503. * @param x x coordinate
  65504. * @param y y coordinate
  65505. * @returns the started path2
  65506. */
  65507. static StartingAt(x: number, y: number): Path2;
  65508. }
  65509. /**
  65510. * Builds a polygon
  65511. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65512. */
  65513. export class PolygonMeshBuilder {
  65514. private _points;
  65515. private _outlinepoints;
  65516. private _holes;
  65517. private _name;
  65518. private _scene;
  65519. private _epoints;
  65520. private _eholes;
  65521. private _addToepoint;
  65522. /**
  65523. * Babylon reference to the earcut plugin.
  65524. */
  65525. bjsEarcut: any;
  65526. /**
  65527. * Creates a PolygonMeshBuilder
  65528. * @param name name of the builder
  65529. * @param contours Path of the polygon
  65530. * @param scene scene to add to when creating the mesh
  65531. * @param earcutInjection can be used to inject your own earcut reference
  65532. */
  65533. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65534. /**
  65535. * Adds a whole within the polygon
  65536. * @param hole Array of points defining the hole
  65537. * @returns this
  65538. */
  65539. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65540. /**
  65541. * Creates the polygon
  65542. * @param updatable If the mesh should be updatable
  65543. * @param depth The depth of the mesh created
  65544. * @returns the created mesh
  65545. */
  65546. build(updatable?: boolean, depth?: number): Mesh;
  65547. /**
  65548. * Creates the polygon
  65549. * @param depth The depth of the mesh created
  65550. * @returns the created VertexData
  65551. */
  65552. buildVertexData(depth?: number): VertexData;
  65553. /**
  65554. * Adds a side to the polygon
  65555. * @param positions points that make the polygon
  65556. * @param normals normals of the polygon
  65557. * @param uvs uvs of the polygon
  65558. * @param indices indices of the polygon
  65559. * @param bounds bounds of the polygon
  65560. * @param points points of the polygon
  65561. * @param depth depth of the polygon
  65562. * @param flip flip of the polygon
  65563. */
  65564. private addSide;
  65565. }
  65566. }
  65567. declare module BABYLON {
  65568. /**
  65569. * Class containing static functions to help procedurally build meshes
  65570. */
  65571. export class PolygonBuilder {
  65572. /**
  65573. * Creates a polygon mesh
  65574. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65575. * * 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
  65576. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * 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)
  65579. * * Remember you can only change the shape positions, not their number when updating a polygon
  65580. * @param name defines the name of the mesh
  65581. * @param options defines the options used to create the mesh
  65582. * @param scene defines the hosting scene
  65583. * @param earcutInjection can be used to inject your own earcut reference
  65584. * @returns the polygon mesh
  65585. */
  65586. static CreatePolygon(name: string, options: {
  65587. shape: Vector3[];
  65588. holes?: Vector3[][];
  65589. depth?: number;
  65590. faceUV?: Vector4[];
  65591. faceColors?: Color4[];
  65592. updatable?: boolean;
  65593. sideOrientation?: number;
  65594. frontUVs?: Vector4;
  65595. backUVs?: Vector4;
  65596. wrap?: boolean;
  65597. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65598. /**
  65599. * Creates an extruded polygon mesh, with depth in the Y direction.
  65600. * * 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)
  65601. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65602. * @param name defines the name of the mesh
  65603. * @param options defines the options used to create the mesh
  65604. * @param scene defines the hosting scene
  65605. * @param earcutInjection can be used to inject your own earcut reference
  65606. * @returns the polygon mesh
  65607. */
  65608. static ExtrudePolygon(name: string, options: {
  65609. shape: Vector3[];
  65610. holes?: Vector3[][];
  65611. depth?: number;
  65612. faceUV?: Vector4[];
  65613. faceColors?: Color4[];
  65614. updatable?: boolean;
  65615. sideOrientation?: number;
  65616. frontUVs?: Vector4;
  65617. backUVs?: Vector4;
  65618. wrap?: boolean;
  65619. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65620. }
  65621. }
  65622. declare module BABYLON {
  65623. /**
  65624. * Class containing static functions to help procedurally build meshes
  65625. */
  65626. export class LatheBuilder {
  65627. /**
  65628. * Creates lathe mesh.
  65629. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65630. * * 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
  65631. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65632. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65633. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65634. * * 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
  65635. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65636. * * 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
  65637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65638. * * 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
  65639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65641. * @param name defines the name of the mesh
  65642. * @param options defines the options used to create the mesh
  65643. * @param scene defines the hosting scene
  65644. * @returns the lathe mesh
  65645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65646. */
  65647. static CreateLathe(name: string, options: {
  65648. shape: Vector3[];
  65649. radius?: number;
  65650. tessellation?: number;
  65651. clip?: number;
  65652. arc?: number;
  65653. closed?: boolean;
  65654. updatable?: boolean;
  65655. sideOrientation?: number;
  65656. frontUVs?: Vector4;
  65657. backUVs?: Vector4;
  65658. cap?: number;
  65659. invertUV?: boolean;
  65660. }, scene?: Nullable<Scene>): Mesh;
  65661. }
  65662. }
  65663. declare module BABYLON {
  65664. /**
  65665. * Class containing static functions to help procedurally build meshes
  65666. */
  65667. export class TiledPlaneBuilder {
  65668. /**
  65669. * Creates a tiled plane mesh
  65670. * * The parameter `pattern` will, depending on value, do nothing or
  65671. * * * flip (reflect about central vertical) alternate tiles across and up
  65672. * * * flip every tile on alternate rows
  65673. * * * rotate (180 degs) alternate tiles across and up
  65674. * * * rotate every tile on alternate rows
  65675. * * * flip and rotate alternate tiles across and up
  65676. * * * flip and rotate every tile on alternate rows
  65677. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65678. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65679. * * 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
  65680. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65681. * * 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)
  65682. * * 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)
  65683. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65684. * @param name defines the name of the mesh
  65685. * @param options defines the options used to create the mesh
  65686. * @param scene defines the hosting scene
  65687. * @returns the box mesh
  65688. */
  65689. static CreateTiledPlane(name: string, options: {
  65690. pattern?: number;
  65691. tileSize?: number;
  65692. tileWidth?: number;
  65693. tileHeight?: number;
  65694. size?: number;
  65695. width?: number;
  65696. height?: number;
  65697. alignHorizontal?: number;
  65698. alignVertical?: number;
  65699. sideOrientation?: number;
  65700. frontUVs?: Vector4;
  65701. backUVs?: Vector4;
  65702. updatable?: boolean;
  65703. }, scene?: Nullable<Scene>): Mesh;
  65704. }
  65705. }
  65706. declare module BABYLON {
  65707. /**
  65708. * Class containing static functions to help procedurally build meshes
  65709. */
  65710. export class TubeBuilder {
  65711. /**
  65712. * Creates a tube mesh.
  65713. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65714. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65715. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65716. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65717. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65718. * * 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)
  65719. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65720. * * 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
  65721. * * 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
  65722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65723. * * 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
  65724. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65726. * @param name defines the name of the mesh
  65727. * @param options defines the options used to create the mesh
  65728. * @param scene defines the hosting scene
  65729. * @returns the tube mesh
  65730. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65731. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65732. */
  65733. static CreateTube(name: string, options: {
  65734. path: Vector3[];
  65735. radius?: number;
  65736. tessellation?: number;
  65737. radiusFunction?: {
  65738. (i: number, distance: number): number;
  65739. };
  65740. cap?: number;
  65741. arc?: number;
  65742. updatable?: boolean;
  65743. sideOrientation?: number;
  65744. frontUVs?: Vector4;
  65745. backUVs?: Vector4;
  65746. instance?: Mesh;
  65747. invertUV?: boolean;
  65748. }, scene?: Nullable<Scene>): Mesh;
  65749. }
  65750. }
  65751. declare module BABYLON {
  65752. /**
  65753. * Class containing static functions to help procedurally build meshes
  65754. */
  65755. export class IcoSphereBuilder {
  65756. /**
  65757. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65758. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65759. * * 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`)
  65760. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65761. * * 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
  65762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65763. * * 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
  65764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65765. * @param name defines the name of the mesh
  65766. * @param options defines the options used to create the mesh
  65767. * @param scene defines the hosting scene
  65768. * @returns the icosahedron mesh
  65769. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65770. */
  65771. static CreateIcoSphere(name: string, options: {
  65772. radius?: number;
  65773. radiusX?: number;
  65774. radiusY?: number;
  65775. radiusZ?: number;
  65776. flat?: boolean;
  65777. subdivisions?: number;
  65778. sideOrientation?: number;
  65779. frontUVs?: Vector4;
  65780. backUVs?: Vector4;
  65781. updatable?: boolean;
  65782. }, scene?: Nullable<Scene>): Mesh;
  65783. }
  65784. }
  65785. declare module BABYLON {
  65786. /**
  65787. * Class containing static functions to help procedurally build meshes
  65788. */
  65789. export class DecalBuilder {
  65790. /**
  65791. * Creates a decal mesh.
  65792. * 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
  65793. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65794. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65795. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65796. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65797. * @param name defines the name of the mesh
  65798. * @param sourceMesh defines the mesh where the decal must be applied
  65799. * @param options defines the options used to create the mesh
  65800. * @param scene defines the hosting scene
  65801. * @returns the decal mesh
  65802. * @see https://doc.babylonjs.com/how_to/decals
  65803. */
  65804. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65805. position?: Vector3;
  65806. normal?: Vector3;
  65807. size?: Vector3;
  65808. angle?: number;
  65809. }): Mesh;
  65810. }
  65811. }
  65812. declare module BABYLON {
  65813. /**
  65814. * Class containing static functions to help procedurally build meshes
  65815. */
  65816. export class MeshBuilder {
  65817. /**
  65818. * Creates a box mesh
  65819. * * The parameter `size` sets the size (float) of each box side (default 1)
  65820. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65821. * * 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)
  65822. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65824. * * 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
  65825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65826. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65827. * @param name defines the name of the mesh
  65828. * @param options defines the options used to create the mesh
  65829. * @param scene defines the hosting scene
  65830. * @returns the box mesh
  65831. */
  65832. static CreateBox(name: string, options: {
  65833. size?: number;
  65834. width?: number;
  65835. height?: number;
  65836. depth?: number;
  65837. faceUV?: Vector4[];
  65838. faceColors?: Color4[];
  65839. sideOrientation?: number;
  65840. frontUVs?: Vector4;
  65841. backUVs?: Vector4;
  65842. wrap?: boolean;
  65843. topBaseAt?: number;
  65844. bottomBaseAt?: number;
  65845. updatable?: boolean;
  65846. }, scene?: Nullable<Scene>): Mesh;
  65847. /**
  65848. * Creates a tiled box mesh
  65849. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65851. * @param name defines the name of the mesh
  65852. * @param options defines the options used to create the mesh
  65853. * @param scene defines the hosting scene
  65854. * @returns the tiled box mesh
  65855. */
  65856. static CreateTiledBox(name: string, options: {
  65857. pattern?: number;
  65858. size?: number;
  65859. width?: number;
  65860. height?: number;
  65861. depth: number;
  65862. tileSize?: number;
  65863. tileWidth?: number;
  65864. tileHeight?: number;
  65865. faceUV?: Vector4[];
  65866. faceColors?: Color4[];
  65867. alignHorizontal?: number;
  65868. alignVertical?: number;
  65869. sideOrientation?: number;
  65870. updatable?: boolean;
  65871. }, scene?: Nullable<Scene>): Mesh;
  65872. /**
  65873. * Creates a sphere mesh
  65874. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65875. * * 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`)
  65876. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65877. * * 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
  65878. * * 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)
  65879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65880. * * 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
  65881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65882. * @param name defines the name of the mesh
  65883. * @param options defines the options used to create the mesh
  65884. * @param scene defines the hosting scene
  65885. * @returns the sphere mesh
  65886. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65887. */
  65888. static CreateSphere(name: string, options: {
  65889. segments?: number;
  65890. diameter?: number;
  65891. diameterX?: number;
  65892. diameterY?: number;
  65893. diameterZ?: number;
  65894. arc?: number;
  65895. slice?: number;
  65896. sideOrientation?: number;
  65897. frontUVs?: Vector4;
  65898. backUVs?: Vector4;
  65899. updatable?: boolean;
  65900. }, scene?: Nullable<Scene>): Mesh;
  65901. /**
  65902. * Creates a plane polygonal mesh. By default, this is a disc
  65903. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65904. * * 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
  65905. * * 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
  65906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65907. * * 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
  65908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65909. * @param name defines the name of the mesh
  65910. * @param options defines the options used to create the mesh
  65911. * @param scene defines the hosting scene
  65912. * @returns the plane polygonal mesh
  65913. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65914. */
  65915. static CreateDisc(name: string, options: {
  65916. radius?: number;
  65917. tessellation?: number;
  65918. arc?: number;
  65919. updatable?: boolean;
  65920. sideOrientation?: number;
  65921. frontUVs?: Vector4;
  65922. backUVs?: Vector4;
  65923. }, scene?: Nullable<Scene>): Mesh;
  65924. /**
  65925. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65926. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65927. * * 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`)
  65928. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65929. * * 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
  65930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65931. * * 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
  65932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the icosahedron mesh
  65937. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65938. */
  65939. static CreateIcoSphere(name: string, options: {
  65940. radius?: number;
  65941. radiusX?: number;
  65942. radiusY?: number;
  65943. radiusZ?: number;
  65944. flat?: boolean;
  65945. subdivisions?: number;
  65946. sideOrientation?: number;
  65947. frontUVs?: Vector4;
  65948. backUVs?: Vector4;
  65949. updatable?: boolean;
  65950. }, scene?: Nullable<Scene>): Mesh;
  65951. /**
  65952. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65953. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65954. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65955. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65956. * * 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
  65957. * * 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
  65958. * * 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
  65959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65960. * * 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
  65961. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65962. * * 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
  65963. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65964. * * 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
  65965. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65967. * @param name defines the name of the mesh
  65968. * @param options defines the options used to create the mesh
  65969. * @param scene defines the hosting scene
  65970. * @returns the ribbon mesh
  65971. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65972. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65973. */
  65974. static CreateRibbon(name: string, options: {
  65975. pathArray: Vector3[][];
  65976. closeArray?: boolean;
  65977. closePath?: boolean;
  65978. offset?: number;
  65979. updatable?: boolean;
  65980. sideOrientation?: number;
  65981. frontUVs?: Vector4;
  65982. backUVs?: Vector4;
  65983. instance?: Mesh;
  65984. invertUV?: boolean;
  65985. uvs?: Vector2[];
  65986. colors?: Color4[];
  65987. }, scene?: Nullable<Scene>): Mesh;
  65988. /**
  65989. * Creates a cylinder or a cone mesh
  65990. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65991. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65992. * * 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.
  65993. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65994. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65995. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65996. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65997. * * 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).
  65998. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65999. * * 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).
  66000. * * 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
  66001. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66002. * * 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
  66003. * * 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.
  66004. * * If `enclose` is false, a ring surface is one element.
  66005. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66006. * * 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
  66007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66008. * * 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
  66009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66010. * @param name defines the name of the mesh
  66011. * @param options defines the options used to create the mesh
  66012. * @param scene defines the hosting scene
  66013. * @returns the cylinder mesh
  66014. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66015. */
  66016. static CreateCylinder(name: string, options: {
  66017. height?: number;
  66018. diameterTop?: number;
  66019. diameterBottom?: number;
  66020. diameter?: number;
  66021. tessellation?: number;
  66022. subdivisions?: number;
  66023. arc?: number;
  66024. faceColors?: Color4[];
  66025. faceUV?: Vector4[];
  66026. updatable?: boolean;
  66027. hasRings?: boolean;
  66028. enclose?: boolean;
  66029. cap?: number;
  66030. sideOrientation?: number;
  66031. frontUVs?: Vector4;
  66032. backUVs?: Vector4;
  66033. }, scene?: Nullable<Scene>): Mesh;
  66034. /**
  66035. * Creates a torus mesh
  66036. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66037. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66038. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66040. * * 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
  66041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66042. * @param name defines the name of the mesh
  66043. * @param options defines the options used to create the mesh
  66044. * @param scene defines the hosting scene
  66045. * @returns the torus mesh
  66046. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66047. */
  66048. static CreateTorus(name: string, options: {
  66049. diameter?: number;
  66050. thickness?: number;
  66051. tessellation?: number;
  66052. updatable?: boolean;
  66053. sideOrientation?: number;
  66054. frontUVs?: Vector4;
  66055. backUVs?: Vector4;
  66056. }, scene?: Nullable<Scene>): Mesh;
  66057. /**
  66058. * Creates a torus knot mesh
  66059. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66060. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66061. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66062. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66064. * * 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
  66065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66066. * @param name defines the name of the mesh
  66067. * @param options defines the options used to create the mesh
  66068. * @param scene defines the hosting scene
  66069. * @returns the torus knot mesh
  66070. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66071. */
  66072. static CreateTorusKnot(name: string, options: {
  66073. radius?: number;
  66074. tube?: number;
  66075. radialSegments?: number;
  66076. tubularSegments?: number;
  66077. p?: number;
  66078. q?: number;
  66079. updatable?: boolean;
  66080. sideOrientation?: number;
  66081. frontUVs?: Vector4;
  66082. backUVs?: Vector4;
  66083. }, scene?: Nullable<Scene>): Mesh;
  66084. /**
  66085. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66086. * * 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
  66087. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66088. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66089. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66090. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66091. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66092. * * 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
  66093. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66096. * @param name defines the name of the new line system
  66097. * @param options defines the options used to create the line system
  66098. * @param scene defines the hosting scene
  66099. * @returns a new line system mesh
  66100. */
  66101. static CreateLineSystem(name: string, options: {
  66102. lines: Vector3[][];
  66103. updatable?: boolean;
  66104. instance?: Nullable<LinesMesh>;
  66105. colors?: Nullable<Color4[][]>;
  66106. useVertexAlpha?: boolean;
  66107. }, scene: Nullable<Scene>): LinesMesh;
  66108. /**
  66109. * Creates a line mesh
  66110. * 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
  66111. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66112. * * The parameter `points` is an array successive Vector3
  66113. * * 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
  66114. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66115. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66116. * * When updating an instance, remember that only point positions can change, not the number of points
  66117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66119. * @param name defines the name of the new line system
  66120. * @param options defines the options used to create the line system
  66121. * @param scene defines the hosting scene
  66122. * @returns a new line mesh
  66123. */
  66124. static CreateLines(name: string, options: {
  66125. points: Vector3[];
  66126. updatable?: boolean;
  66127. instance?: Nullable<LinesMesh>;
  66128. colors?: Color4[];
  66129. useVertexAlpha?: boolean;
  66130. }, scene?: Nullable<Scene>): LinesMesh;
  66131. /**
  66132. * Creates a dashed line mesh
  66133. * * 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
  66134. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66135. * * The parameter `points` is an array successive Vector3
  66136. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66137. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66138. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66139. * * 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
  66140. * * When updating an instance, remember that only point positions can change, not the number of points
  66141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66142. * @param name defines the name of the mesh
  66143. * @param options defines the options used to create the mesh
  66144. * @param scene defines the hosting scene
  66145. * @returns the dashed line mesh
  66146. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66147. */
  66148. static CreateDashedLines(name: string, options: {
  66149. points: Vector3[];
  66150. dashSize?: number;
  66151. gapSize?: number;
  66152. dashNb?: number;
  66153. updatable?: boolean;
  66154. instance?: LinesMesh;
  66155. }, scene?: Nullable<Scene>): LinesMesh;
  66156. /**
  66157. * 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.
  66158. * * 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.
  66159. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66160. * * 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.
  66161. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66162. * * 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
  66163. * * 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
  66164. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66166. * * 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
  66167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66169. * @param name defines the name of the mesh
  66170. * @param options defines the options used to create the mesh
  66171. * @param scene defines the hosting scene
  66172. * @returns the extruded shape mesh
  66173. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66175. */
  66176. static ExtrudeShape(name: string, options: {
  66177. shape: Vector3[];
  66178. path: Vector3[];
  66179. scale?: number;
  66180. rotation?: number;
  66181. cap?: number;
  66182. updatable?: boolean;
  66183. sideOrientation?: number;
  66184. frontUVs?: Vector4;
  66185. backUVs?: Vector4;
  66186. instance?: Mesh;
  66187. invertUV?: boolean;
  66188. }, scene?: Nullable<Scene>): Mesh;
  66189. /**
  66190. * Creates an custom extruded shape mesh.
  66191. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66192. * * 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.
  66193. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66194. * * 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
  66195. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66196. * * 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
  66197. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66198. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66199. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66200. * * 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
  66201. * * 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
  66202. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66204. * * 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
  66205. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66207. * @param name defines the name of the mesh
  66208. * @param options defines the options used to create the mesh
  66209. * @param scene defines the hosting scene
  66210. * @returns the custom extruded shape mesh
  66211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66212. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66214. */
  66215. static ExtrudeShapeCustom(name: string, options: {
  66216. shape: Vector3[];
  66217. path: Vector3[];
  66218. scaleFunction?: any;
  66219. rotationFunction?: any;
  66220. ribbonCloseArray?: boolean;
  66221. ribbonClosePath?: boolean;
  66222. cap?: number;
  66223. updatable?: boolean;
  66224. sideOrientation?: number;
  66225. frontUVs?: Vector4;
  66226. backUVs?: Vector4;
  66227. instance?: Mesh;
  66228. invertUV?: boolean;
  66229. }, scene?: Nullable<Scene>): Mesh;
  66230. /**
  66231. * Creates lathe mesh.
  66232. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66233. * * 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
  66234. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66235. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66236. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66237. * * 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
  66238. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66239. * * 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
  66240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66241. * * 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
  66242. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66244. * @param name defines the name of the mesh
  66245. * @param options defines the options used to create the mesh
  66246. * @param scene defines the hosting scene
  66247. * @returns the lathe mesh
  66248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66249. */
  66250. static CreateLathe(name: string, options: {
  66251. shape: Vector3[];
  66252. radius?: number;
  66253. tessellation?: number;
  66254. clip?: number;
  66255. arc?: number;
  66256. closed?: boolean;
  66257. updatable?: boolean;
  66258. sideOrientation?: number;
  66259. frontUVs?: Vector4;
  66260. backUVs?: Vector4;
  66261. cap?: number;
  66262. invertUV?: boolean;
  66263. }, scene?: Nullable<Scene>): Mesh;
  66264. /**
  66265. * Creates a tiled plane mesh
  66266. * * You can set a limited pattern arrangement with the tiles
  66267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66268. * * 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
  66269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66270. * @param name defines the name of the mesh
  66271. * @param options defines the options used to create the mesh
  66272. * @param scene defines the hosting scene
  66273. * @returns the plane mesh
  66274. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66275. */
  66276. static CreateTiledPlane(name: string, options: {
  66277. pattern?: number;
  66278. tileSize?: number;
  66279. tileWidth?: number;
  66280. tileHeight?: number;
  66281. size?: number;
  66282. width?: number;
  66283. height?: number;
  66284. alignHorizontal?: number;
  66285. alignVertical?: number;
  66286. sideOrientation?: number;
  66287. frontUVs?: Vector4;
  66288. backUVs?: Vector4;
  66289. updatable?: boolean;
  66290. }, scene?: Nullable<Scene>): Mesh;
  66291. /**
  66292. * Creates a plane mesh
  66293. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66294. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66295. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66297. * * 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
  66298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66299. * @param name defines the name of the mesh
  66300. * @param options defines the options used to create the mesh
  66301. * @param scene defines the hosting scene
  66302. * @returns the plane mesh
  66303. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66304. */
  66305. static CreatePlane(name: string, options: {
  66306. size?: number;
  66307. width?: number;
  66308. height?: number;
  66309. sideOrientation?: number;
  66310. frontUVs?: Vector4;
  66311. backUVs?: Vector4;
  66312. updatable?: boolean;
  66313. sourcePlane?: Plane;
  66314. }, scene?: Nullable<Scene>): Mesh;
  66315. /**
  66316. * Creates a ground mesh
  66317. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66318. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66320. * @param name defines the name of the mesh
  66321. * @param options defines the options used to create the mesh
  66322. * @param scene defines the hosting scene
  66323. * @returns the ground mesh
  66324. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66325. */
  66326. static CreateGround(name: string, options: {
  66327. width?: number;
  66328. height?: number;
  66329. subdivisions?: number;
  66330. subdivisionsX?: number;
  66331. subdivisionsY?: number;
  66332. updatable?: boolean;
  66333. }, scene?: Nullable<Scene>): Mesh;
  66334. /**
  66335. * Creates a tiled ground mesh
  66336. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66337. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66338. * * 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
  66339. * * 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
  66340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66341. * @param name defines the name of the mesh
  66342. * @param options defines the options used to create the mesh
  66343. * @param scene defines the hosting scene
  66344. * @returns the tiled ground mesh
  66345. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66346. */
  66347. static CreateTiledGround(name: string, options: {
  66348. xmin: number;
  66349. zmin: number;
  66350. xmax: number;
  66351. zmax: number;
  66352. subdivisions?: {
  66353. w: number;
  66354. h: number;
  66355. };
  66356. precision?: {
  66357. w: number;
  66358. h: number;
  66359. };
  66360. updatable?: boolean;
  66361. }, scene?: Nullable<Scene>): Mesh;
  66362. /**
  66363. * Creates a ground mesh from a height map
  66364. * * The parameter `url` sets the URL of the height map image resource.
  66365. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66366. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66367. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66368. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66369. * * 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.
  66370. * * 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).
  66371. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66373. * @param name defines the name of the mesh
  66374. * @param url defines the url to the height map
  66375. * @param options defines the options used to create the mesh
  66376. * @param scene defines the hosting scene
  66377. * @returns the ground mesh
  66378. * @see https://doc.babylonjs.com/babylon101/height_map
  66379. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66380. */
  66381. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66382. width?: number;
  66383. height?: number;
  66384. subdivisions?: number;
  66385. minHeight?: number;
  66386. maxHeight?: number;
  66387. colorFilter?: Color3;
  66388. alphaFilter?: number;
  66389. updatable?: boolean;
  66390. onReady?: (mesh: GroundMesh) => void;
  66391. }, scene?: Nullable<Scene>): GroundMesh;
  66392. /**
  66393. * Creates a polygon mesh
  66394. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66395. * * 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
  66396. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66398. * * 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)
  66399. * * Remember you can only change the shape positions, not their number when updating a polygon
  66400. * @param name defines the name of the mesh
  66401. * @param options defines the options used to create the mesh
  66402. * @param scene defines the hosting scene
  66403. * @param earcutInjection can be used to inject your own earcut reference
  66404. * @returns the polygon mesh
  66405. */
  66406. static CreatePolygon(name: string, options: {
  66407. shape: Vector3[];
  66408. holes?: Vector3[][];
  66409. depth?: number;
  66410. faceUV?: Vector4[];
  66411. faceColors?: Color4[];
  66412. updatable?: boolean;
  66413. sideOrientation?: number;
  66414. frontUVs?: Vector4;
  66415. backUVs?: Vector4;
  66416. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66417. /**
  66418. * Creates an extruded polygon mesh, with depth in the Y direction.
  66419. * * 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)
  66420. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66421. * @param name defines the name of the mesh
  66422. * @param options defines the options used to create the mesh
  66423. * @param scene defines the hosting scene
  66424. * @param earcutInjection can be used to inject your own earcut reference
  66425. * @returns the polygon mesh
  66426. */
  66427. static ExtrudePolygon(name: string, options: {
  66428. shape: Vector3[];
  66429. holes?: Vector3[][];
  66430. depth?: number;
  66431. faceUV?: Vector4[];
  66432. faceColors?: Color4[];
  66433. updatable?: boolean;
  66434. sideOrientation?: number;
  66435. frontUVs?: Vector4;
  66436. backUVs?: Vector4;
  66437. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66438. /**
  66439. * Creates a tube mesh.
  66440. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66441. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66442. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66443. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66444. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66445. * * 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)
  66446. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66447. * * 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
  66448. * * 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
  66449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66450. * * 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
  66451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66453. * @param name defines the name of the mesh
  66454. * @param options defines the options used to create the mesh
  66455. * @param scene defines the hosting scene
  66456. * @returns the tube mesh
  66457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66458. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66459. */
  66460. static CreateTube(name: string, options: {
  66461. path: Vector3[];
  66462. radius?: number;
  66463. tessellation?: number;
  66464. radiusFunction?: {
  66465. (i: number, distance: number): number;
  66466. };
  66467. cap?: number;
  66468. arc?: number;
  66469. updatable?: boolean;
  66470. sideOrientation?: number;
  66471. frontUVs?: Vector4;
  66472. backUVs?: Vector4;
  66473. instance?: Mesh;
  66474. invertUV?: boolean;
  66475. }, scene?: Nullable<Scene>): Mesh;
  66476. /**
  66477. * Creates a polyhedron mesh
  66478. * * 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
  66479. * * The parameter `size` (positive float, default 1) sets the polygon size
  66480. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66481. * * 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`
  66482. * * 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
  66483. * * 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)`)
  66484. * * 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
  66485. * * 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
  66486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66487. * * 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
  66488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66489. * @param name defines the name of the mesh
  66490. * @param options defines the options used to create the mesh
  66491. * @param scene defines the hosting scene
  66492. * @returns the polyhedron mesh
  66493. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66494. */
  66495. static CreatePolyhedron(name: string, options: {
  66496. type?: number;
  66497. size?: number;
  66498. sizeX?: number;
  66499. sizeY?: number;
  66500. sizeZ?: number;
  66501. custom?: any;
  66502. faceUV?: Vector4[];
  66503. faceColors?: Color4[];
  66504. flat?: boolean;
  66505. updatable?: boolean;
  66506. sideOrientation?: number;
  66507. frontUVs?: Vector4;
  66508. backUVs?: Vector4;
  66509. }, scene?: Nullable<Scene>): Mesh;
  66510. /**
  66511. * Creates a decal mesh.
  66512. * 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
  66513. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66514. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66515. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66516. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66517. * @param name defines the name of the mesh
  66518. * @param sourceMesh defines the mesh where the decal must be applied
  66519. * @param options defines the options used to create the mesh
  66520. * @param scene defines the hosting scene
  66521. * @returns the decal mesh
  66522. * @see https://doc.babylonjs.com/how_to/decals
  66523. */
  66524. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66525. position?: Vector3;
  66526. normal?: Vector3;
  66527. size?: Vector3;
  66528. angle?: number;
  66529. }): Mesh;
  66530. /**
  66531. * Creates a Capsule Mesh
  66532. * @param name defines the name of the mesh.
  66533. * @param options the constructors options used to shape the mesh.
  66534. * @param scene defines the scene the mesh is scoped to.
  66535. * @returns the capsule mesh
  66536. * @see https://doc.babylonjs.com/how_to/capsule_shape
  66537. */
  66538. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  66539. }
  66540. }
  66541. declare module BABYLON {
  66542. /**
  66543. * A simplifier interface for future simplification implementations
  66544. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66545. */
  66546. export interface ISimplifier {
  66547. /**
  66548. * Simplification of a given mesh according to the given settings.
  66549. * Since this requires computation, it is assumed that the function runs async.
  66550. * @param settings The settings of the simplification, including quality and distance
  66551. * @param successCallback A callback that will be called after the mesh was simplified.
  66552. * @param errorCallback in case of an error, this callback will be called. optional.
  66553. */
  66554. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66555. }
  66556. /**
  66557. * Expected simplification settings.
  66558. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66559. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66560. */
  66561. export interface ISimplificationSettings {
  66562. /**
  66563. * Gets or sets the expected quality
  66564. */
  66565. quality: number;
  66566. /**
  66567. * Gets or sets the distance when this optimized version should be used
  66568. */
  66569. distance: number;
  66570. /**
  66571. * Gets an already optimized mesh
  66572. */
  66573. optimizeMesh?: boolean;
  66574. }
  66575. /**
  66576. * Class used to specify simplification options
  66577. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66578. */
  66579. export class SimplificationSettings implements ISimplificationSettings {
  66580. /** expected quality */
  66581. quality: number;
  66582. /** distance when this optimized version should be used */
  66583. distance: number;
  66584. /** already optimized mesh */
  66585. optimizeMesh?: boolean | undefined;
  66586. /**
  66587. * Creates a SimplificationSettings
  66588. * @param quality expected quality
  66589. * @param distance distance when this optimized version should be used
  66590. * @param optimizeMesh already optimized mesh
  66591. */
  66592. constructor(
  66593. /** expected quality */
  66594. quality: number,
  66595. /** distance when this optimized version should be used */
  66596. distance: number,
  66597. /** already optimized mesh */
  66598. optimizeMesh?: boolean | undefined);
  66599. }
  66600. /**
  66601. * Interface used to define a simplification task
  66602. */
  66603. export interface ISimplificationTask {
  66604. /**
  66605. * Array of settings
  66606. */
  66607. settings: Array<ISimplificationSettings>;
  66608. /**
  66609. * Simplification type
  66610. */
  66611. simplificationType: SimplificationType;
  66612. /**
  66613. * Mesh to simplify
  66614. */
  66615. mesh: Mesh;
  66616. /**
  66617. * Callback called on success
  66618. */
  66619. successCallback?: () => void;
  66620. /**
  66621. * Defines if parallel processing can be used
  66622. */
  66623. parallelProcessing: boolean;
  66624. }
  66625. /**
  66626. * Queue used to order the simplification tasks
  66627. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66628. */
  66629. export class SimplificationQueue {
  66630. private _simplificationArray;
  66631. /**
  66632. * Gets a boolean indicating that the process is still running
  66633. */
  66634. running: boolean;
  66635. /**
  66636. * Creates a new queue
  66637. */
  66638. constructor();
  66639. /**
  66640. * Adds a new simplification task
  66641. * @param task defines a task to add
  66642. */
  66643. addTask(task: ISimplificationTask): void;
  66644. /**
  66645. * Execute next task
  66646. */
  66647. executeNext(): void;
  66648. /**
  66649. * Execute a simplification task
  66650. * @param task defines the task to run
  66651. */
  66652. runSimplification(task: ISimplificationTask): void;
  66653. private getSimplifier;
  66654. }
  66655. /**
  66656. * The implemented types of simplification
  66657. * At the moment only Quadratic Error Decimation is implemented
  66658. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66659. */
  66660. export enum SimplificationType {
  66661. /** Quadratic error decimation */
  66662. QUADRATIC = 0
  66663. }
  66664. /**
  66665. * An implementation of the Quadratic Error simplification algorithm.
  66666. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66667. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66668. * @author RaananW
  66669. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66670. */
  66671. export class QuadraticErrorSimplification implements ISimplifier {
  66672. private _mesh;
  66673. private triangles;
  66674. private vertices;
  66675. private references;
  66676. private _reconstructedMesh;
  66677. /** Gets or sets the number pf sync interations */
  66678. syncIterations: number;
  66679. /** Gets or sets the aggressiveness of the simplifier */
  66680. aggressiveness: number;
  66681. /** Gets or sets the number of allowed iterations for decimation */
  66682. decimationIterations: number;
  66683. /** Gets or sets the espilon to use for bounding box computation */
  66684. boundingBoxEpsilon: number;
  66685. /**
  66686. * Creates a new QuadraticErrorSimplification
  66687. * @param _mesh defines the target mesh
  66688. */
  66689. constructor(_mesh: Mesh);
  66690. /**
  66691. * Simplification of a given mesh according to the given settings.
  66692. * Since this requires computation, it is assumed that the function runs async.
  66693. * @param settings The settings of the simplification, including quality and distance
  66694. * @param successCallback A callback that will be called after the mesh was simplified.
  66695. */
  66696. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66697. private runDecimation;
  66698. private initWithMesh;
  66699. private init;
  66700. private reconstructMesh;
  66701. private initDecimatedMesh;
  66702. private isFlipped;
  66703. private updateTriangles;
  66704. private identifyBorder;
  66705. private updateMesh;
  66706. private vertexError;
  66707. private calculateError;
  66708. }
  66709. }
  66710. declare module BABYLON {
  66711. interface Scene {
  66712. /** @hidden (Backing field) */
  66713. _simplificationQueue: SimplificationQueue;
  66714. /**
  66715. * Gets or sets the simplification queue attached to the scene
  66716. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66717. */
  66718. simplificationQueue: SimplificationQueue;
  66719. }
  66720. interface Mesh {
  66721. /**
  66722. * Simplify the mesh according to the given array of settings.
  66723. * Function will return immediately and will simplify async
  66724. * @param settings a collection of simplification settings
  66725. * @param parallelProcessing should all levels calculate parallel or one after the other
  66726. * @param simplificationType the type of simplification to run
  66727. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66728. * @returns the current mesh
  66729. */
  66730. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66731. }
  66732. /**
  66733. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66734. * created in a scene
  66735. */
  66736. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66737. /**
  66738. * The component name helpfull to identify the component in the list of scene components.
  66739. */
  66740. readonly name: string;
  66741. /**
  66742. * The scene the component belongs to.
  66743. */
  66744. scene: Scene;
  66745. /**
  66746. * Creates a new instance of the component for the given scene
  66747. * @param scene Defines the scene to register the component in
  66748. */
  66749. constructor(scene: Scene);
  66750. /**
  66751. * Registers the component in a given scene
  66752. */
  66753. register(): void;
  66754. /**
  66755. * Rebuilds the elements related to this component in case of
  66756. * context lost for instance.
  66757. */
  66758. rebuild(): void;
  66759. /**
  66760. * Disposes the component and the associated ressources
  66761. */
  66762. dispose(): void;
  66763. private _beforeCameraUpdate;
  66764. }
  66765. }
  66766. declare module BABYLON {
  66767. interface Mesh {
  66768. /**
  66769. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66770. */
  66771. thinInstanceEnablePicking: boolean;
  66772. /**
  66773. * Creates a new thin instance
  66774. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66775. * @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
  66776. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66777. */
  66778. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66779. /**
  66780. * Adds the transformation (matrix) of the current mesh as a thin instance
  66781. * @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
  66782. * @returns the thin instance index number
  66783. */
  66784. thinInstanceAddSelf(refresh: boolean): number;
  66785. /**
  66786. * Registers a custom attribute to be used with thin instances
  66787. * @param kind name of the attribute
  66788. * @param stride size in floats of the attribute
  66789. */
  66790. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66791. /**
  66792. * Sets the matrix of a thin instance
  66793. * @param index index of the thin instance
  66794. * @param matrix matrix to set
  66795. * @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
  66796. */
  66797. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66798. /**
  66799. * Sets the value of a custom attribute for a thin instance
  66800. * @param kind name of the attribute
  66801. * @param index index of the thin instance
  66802. * @param value value to set
  66803. * @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
  66804. */
  66805. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66806. /**
  66807. * 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.
  66808. */
  66809. thinInstanceCount: number;
  66810. /**
  66811. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66812. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66813. * @param buffer buffer to set
  66814. * @param stride size in floats of each value of the buffer
  66815. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66816. */
  66817. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66818. /**
  66819. * Gets the list of world matrices
  66820. * @return an array containing all the world matrices from the thin instances
  66821. */
  66822. thinInstanceGetWorldMatrices(): Matrix[];
  66823. /**
  66824. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66825. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66826. */
  66827. thinInstanceBufferUpdated(kind: string): void;
  66828. /**
  66829. * Applies a partial update to a buffer directly on the GPU
  66830. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  66831. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66832. * @param data the data to set in the GPU buffer
  66833. * @param offset the offset in the GPU buffer where to update the data
  66834. */
  66835. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  66836. /**
  66837. * Refreshes the bounding info, taking into account all the thin instances defined
  66838. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66839. */
  66840. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66841. /** @hidden */
  66842. _thinInstanceInitializeUserStorage(): void;
  66843. /** @hidden */
  66844. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66845. /** @hidden */
  66846. _userThinInstanceBuffersStorage: {
  66847. data: {
  66848. [key: string]: Float32Array;
  66849. };
  66850. sizes: {
  66851. [key: string]: number;
  66852. };
  66853. vertexBuffers: {
  66854. [key: string]: Nullable<VertexBuffer>;
  66855. };
  66856. strides: {
  66857. [key: string]: number;
  66858. };
  66859. };
  66860. }
  66861. }
  66862. declare module BABYLON {
  66863. /**
  66864. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66865. */
  66866. export interface INavigationEnginePlugin {
  66867. /**
  66868. * plugin name
  66869. */
  66870. name: string;
  66871. /**
  66872. * Creates a navigation mesh
  66873. * @param meshes array of all the geometry used to compute the navigatio mesh
  66874. * @param parameters bunch of parameters used to filter geometry
  66875. */
  66876. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66877. /**
  66878. * Create a navigation mesh debug mesh
  66879. * @param scene is where the mesh will be added
  66880. * @returns debug display mesh
  66881. */
  66882. createDebugNavMesh(scene: Scene): Mesh;
  66883. /**
  66884. * Get a navigation mesh constrained position, closest to the parameter position
  66885. * @param position world position
  66886. * @returns the closest point to position constrained by the navigation mesh
  66887. */
  66888. getClosestPoint(position: Vector3): Vector3;
  66889. /**
  66890. * Get a navigation mesh constrained position, closest to the parameter position
  66891. * @param position world position
  66892. * @param result output the closest point to position constrained by the navigation mesh
  66893. */
  66894. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66895. /**
  66896. * Get a navigation mesh constrained position, within a particular radius
  66897. * @param position world position
  66898. * @param maxRadius the maximum distance to the constrained world position
  66899. * @returns the closest point to position constrained by the navigation mesh
  66900. */
  66901. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66902. /**
  66903. * Get a navigation mesh constrained position, within a particular radius
  66904. * @param position world position
  66905. * @param maxRadius the maximum distance to the constrained world position
  66906. * @param result output the closest point to position constrained by the navigation mesh
  66907. */
  66908. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66909. /**
  66910. * Compute the final position from a segment made of destination-position
  66911. * @param position world position
  66912. * @param destination world position
  66913. * @returns the resulting point along the navmesh
  66914. */
  66915. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66916. /**
  66917. * Compute the final position from a segment made of destination-position
  66918. * @param position world position
  66919. * @param destination world position
  66920. * @param result output the resulting point along the navmesh
  66921. */
  66922. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66923. /**
  66924. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66925. * @param start world position
  66926. * @param end world position
  66927. * @returns array containing world position composing the path
  66928. */
  66929. computePath(start: Vector3, end: Vector3): Vector3[];
  66930. /**
  66931. * If this plugin is supported
  66932. * @returns true if plugin is supported
  66933. */
  66934. isSupported(): boolean;
  66935. /**
  66936. * Create a new Crowd so you can add agents
  66937. * @param maxAgents the maximum agent count in the crowd
  66938. * @param maxAgentRadius the maximum radius an agent can have
  66939. * @param scene to attach the crowd to
  66940. * @returns the crowd you can add agents to
  66941. */
  66942. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66943. /**
  66944. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66945. * The queries will try to find a solution within those bounds
  66946. * default is (1,1,1)
  66947. * @param extent x,y,z value that define the extent around the queries point of reference
  66948. */
  66949. setDefaultQueryExtent(extent: Vector3): void;
  66950. /**
  66951. * Get the Bounding box extent specified by setDefaultQueryExtent
  66952. * @returns the box extent values
  66953. */
  66954. getDefaultQueryExtent(): Vector3;
  66955. /**
  66956. * build the navmesh from a previously saved state using getNavmeshData
  66957. * @param data the Uint8Array returned by getNavmeshData
  66958. */
  66959. buildFromNavmeshData(data: Uint8Array): void;
  66960. /**
  66961. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66962. * @returns data the Uint8Array that can be saved and reused
  66963. */
  66964. getNavmeshData(): Uint8Array;
  66965. /**
  66966. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66967. * @param result output the box extent values
  66968. */
  66969. getDefaultQueryExtentToRef(result: Vector3): void;
  66970. /**
  66971. * Release all resources
  66972. */
  66973. dispose(): void;
  66974. }
  66975. /**
  66976. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66977. */
  66978. export interface ICrowd {
  66979. /**
  66980. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66981. * You can attach anything to that node. The node position is updated in the scene update tick.
  66982. * @param pos world position that will be constrained by the navigation mesh
  66983. * @param parameters agent parameters
  66984. * @param transform hooked to the agent that will be update by the scene
  66985. * @returns agent index
  66986. */
  66987. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66988. /**
  66989. * Returns the agent position in world space
  66990. * @param index agent index returned by addAgent
  66991. * @returns world space position
  66992. */
  66993. getAgentPosition(index: number): Vector3;
  66994. /**
  66995. * Gets the agent position result in world space
  66996. * @param index agent index returned by addAgent
  66997. * @param result output world space position
  66998. */
  66999. getAgentPositionToRef(index: number, result: Vector3): void;
  67000. /**
  67001. * Gets the agent velocity in world space
  67002. * @param index agent index returned by addAgent
  67003. * @returns world space velocity
  67004. */
  67005. getAgentVelocity(index: number): Vector3;
  67006. /**
  67007. * Gets the agent velocity result in world space
  67008. * @param index agent index returned by addAgent
  67009. * @param result output world space velocity
  67010. */
  67011. getAgentVelocityToRef(index: number, result: Vector3): void;
  67012. /**
  67013. * remove a particular agent previously created
  67014. * @param index agent index returned by addAgent
  67015. */
  67016. removeAgent(index: number): void;
  67017. /**
  67018. * get the list of all agents attached to this crowd
  67019. * @returns list of agent indices
  67020. */
  67021. getAgents(): number[];
  67022. /**
  67023. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67024. * @param deltaTime in seconds
  67025. */
  67026. update(deltaTime: number): void;
  67027. /**
  67028. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67029. * @param index agent index returned by addAgent
  67030. * @param destination targeted world position
  67031. */
  67032. agentGoto(index: number, destination: Vector3): void;
  67033. /**
  67034. * Teleport the agent to a new position
  67035. * @param index agent index returned by addAgent
  67036. * @param destination targeted world position
  67037. */
  67038. agentTeleport(index: number, destination: Vector3): void;
  67039. /**
  67040. * Update agent parameters
  67041. * @param index agent index returned by addAgent
  67042. * @param parameters agent parameters
  67043. */
  67044. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67045. /**
  67046. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67047. * The queries will try to find a solution within those bounds
  67048. * default is (1,1,1)
  67049. * @param extent x,y,z value that define the extent around the queries point of reference
  67050. */
  67051. setDefaultQueryExtent(extent: Vector3): void;
  67052. /**
  67053. * Get the Bounding box extent specified by setDefaultQueryExtent
  67054. * @returns the box extent values
  67055. */
  67056. getDefaultQueryExtent(): Vector3;
  67057. /**
  67058. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67059. * @param result output the box extent values
  67060. */
  67061. getDefaultQueryExtentToRef(result: Vector3): void;
  67062. /**
  67063. * Release all resources
  67064. */
  67065. dispose(): void;
  67066. }
  67067. /**
  67068. * Configures an agent
  67069. */
  67070. export interface IAgentParameters {
  67071. /**
  67072. * Agent radius. [Limit: >= 0]
  67073. */
  67074. radius: number;
  67075. /**
  67076. * Agent height. [Limit: > 0]
  67077. */
  67078. height: number;
  67079. /**
  67080. * Maximum allowed acceleration. [Limit: >= 0]
  67081. */
  67082. maxAcceleration: number;
  67083. /**
  67084. * Maximum allowed speed. [Limit: >= 0]
  67085. */
  67086. maxSpeed: number;
  67087. /**
  67088. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67089. */
  67090. collisionQueryRange: number;
  67091. /**
  67092. * The path visibility optimization range. [Limit: > 0]
  67093. */
  67094. pathOptimizationRange: number;
  67095. /**
  67096. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67097. */
  67098. separationWeight: number;
  67099. }
  67100. /**
  67101. * Configures the navigation mesh creation
  67102. */
  67103. export interface INavMeshParameters {
  67104. /**
  67105. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67106. */
  67107. cs: number;
  67108. /**
  67109. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67110. */
  67111. ch: number;
  67112. /**
  67113. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67114. */
  67115. walkableSlopeAngle: number;
  67116. /**
  67117. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67118. * be considered walkable. [Limit: >= 3] [Units: vx]
  67119. */
  67120. walkableHeight: number;
  67121. /**
  67122. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67123. */
  67124. walkableClimb: number;
  67125. /**
  67126. * The distance to erode/shrink the walkable area of the heightfield away from
  67127. * obstructions. [Limit: >=0] [Units: vx]
  67128. */
  67129. walkableRadius: number;
  67130. /**
  67131. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67132. */
  67133. maxEdgeLen: number;
  67134. /**
  67135. * The maximum distance a simplfied contour's border edges should deviate
  67136. * the original raw contour. [Limit: >=0] [Units: vx]
  67137. */
  67138. maxSimplificationError: number;
  67139. /**
  67140. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67141. */
  67142. minRegionArea: number;
  67143. /**
  67144. * Any regions with a span count smaller than this value will, if possible,
  67145. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67146. */
  67147. mergeRegionArea: number;
  67148. /**
  67149. * The maximum number of vertices allowed for polygons generated during the
  67150. * contour to polygon conversion process. [Limit: >= 3]
  67151. */
  67152. maxVertsPerPoly: number;
  67153. /**
  67154. * Sets the sampling distance to use when generating the detail mesh.
  67155. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67156. */
  67157. detailSampleDist: number;
  67158. /**
  67159. * The maximum distance the detail mesh surface should deviate from heightfield
  67160. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67161. */
  67162. detailSampleMaxError: number;
  67163. }
  67164. }
  67165. declare module BABYLON {
  67166. /**
  67167. * RecastJS navigation plugin
  67168. */
  67169. export class RecastJSPlugin implements INavigationEnginePlugin {
  67170. /**
  67171. * Reference to the Recast library
  67172. */
  67173. bjsRECAST: any;
  67174. /**
  67175. * plugin name
  67176. */
  67177. name: string;
  67178. /**
  67179. * the first navmesh created. We might extend this to support multiple navmeshes
  67180. */
  67181. navMesh: any;
  67182. /**
  67183. * Initializes the recastJS plugin
  67184. * @param recastInjection can be used to inject your own recast reference
  67185. */
  67186. constructor(recastInjection?: any);
  67187. /**
  67188. * Creates a navigation mesh
  67189. * @param meshes array of all the geometry used to compute the navigatio mesh
  67190. * @param parameters bunch of parameters used to filter geometry
  67191. */
  67192. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67193. /**
  67194. * Create a navigation mesh debug mesh
  67195. * @param scene is where the mesh will be added
  67196. * @returns debug display mesh
  67197. */
  67198. createDebugNavMesh(scene: Scene): Mesh;
  67199. /**
  67200. * Get a navigation mesh constrained position, closest to the parameter position
  67201. * @param position world position
  67202. * @returns the closest point to position constrained by the navigation mesh
  67203. */
  67204. getClosestPoint(position: Vector3): Vector3;
  67205. /**
  67206. * Get a navigation mesh constrained position, closest to the parameter position
  67207. * @param position world position
  67208. * @param result output the closest point to position constrained by the navigation mesh
  67209. */
  67210. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67211. /**
  67212. * Get a navigation mesh constrained position, within a particular radius
  67213. * @param position world position
  67214. * @param maxRadius the maximum distance to the constrained world position
  67215. * @returns the closest point to position constrained by the navigation mesh
  67216. */
  67217. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67218. /**
  67219. * Get a navigation mesh constrained position, within a particular radius
  67220. * @param position world position
  67221. * @param maxRadius the maximum distance to the constrained world position
  67222. * @param result output the closest point to position constrained by the navigation mesh
  67223. */
  67224. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67225. /**
  67226. * Compute the final position from a segment made of destination-position
  67227. * @param position world position
  67228. * @param destination world position
  67229. * @returns the resulting point along the navmesh
  67230. */
  67231. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67232. /**
  67233. * Compute the final position from a segment made of destination-position
  67234. * @param position world position
  67235. * @param destination world position
  67236. * @param result output the resulting point along the navmesh
  67237. */
  67238. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67239. /**
  67240. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67241. * @param start world position
  67242. * @param end world position
  67243. * @returns array containing world position composing the path
  67244. */
  67245. computePath(start: Vector3, end: Vector3): Vector3[];
  67246. /**
  67247. * Create a new Crowd so you can add agents
  67248. * @param maxAgents the maximum agent count in the crowd
  67249. * @param maxAgentRadius the maximum radius an agent can have
  67250. * @param scene to attach the crowd to
  67251. * @returns the crowd you can add agents to
  67252. */
  67253. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67254. /**
  67255. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67256. * The queries will try to find a solution within those bounds
  67257. * default is (1,1,1)
  67258. * @param extent x,y,z value that define the extent around the queries point of reference
  67259. */
  67260. setDefaultQueryExtent(extent: Vector3): void;
  67261. /**
  67262. * Get the Bounding box extent specified by setDefaultQueryExtent
  67263. * @returns the box extent values
  67264. */
  67265. getDefaultQueryExtent(): Vector3;
  67266. /**
  67267. * build the navmesh from a previously saved state using getNavmeshData
  67268. * @param data the Uint8Array returned by getNavmeshData
  67269. */
  67270. buildFromNavmeshData(data: Uint8Array): void;
  67271. /**
  67272. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67273. * @returns data the Uint8Array that can be saved and reused
  67274. */
  67275. getNavmeshData(): Uint8Array;
  67276. /**
  67277. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67278. * @param result output the box extent values
  67279. */
  67280. getDefaultQueryExtentToRef(result: Vector3): void;
  67281. /**
  67282. * Disposes
  67283. */
  67284. dispose(): void;
  67285. /**
  67286. * If this plugin is supported
  67287. * @returns true if plugin is supported
  67288. */
  67289. isSupported(): boolean;
  67290. }
  67291. /**
  67292. * Recast detour crowd implementation
  67293. */
  67294. export class RecastJSCrowd implements ICrowd {
  67295. /**
  67296. * Recast/detour plugin
  67297. */
  67298. bjsRECASTPlugin: RecastJSPlugin;
  67299. /**
  67300. * Link to the detour crowd
  67301. */
  67302. recastCrowd: any;
  67303. /**
  67304. * One transform per agent
  67305. */
  67306. transforms: TransformNode[];
  67307. /**
  67308. * All agents created
  67309. */
  67310. agents: number[];
  67311. /**
  67312. * Link to the scene is kept to unregister the crowd from the scene
  67313. */
  67314. private _scene;
  67315. /**
  67316. * Observer for crowd updates
  67317. */
  67318. private _onBeforeAnimationsObserver;
  67319. /**
  67320. * Constructor
  67321. * @param plugin recastJS plugin
  67322. * @param maxAgents the maximum agent count in the crowd
  67323. * @param maxAgentRadius the maximum radius an agent can have
  67324. * @param scene to attach the crowd to
  67325. * @returns the crowd you can add agents to
  67326. */
  67327. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67328. /**
  67329. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67330. * You can attach anything to that node. The node position is updated in the scene update tick.
  67331. * @param pos world position that will be constrained by the navigation mesh
  67332. * @param parameters agent parameters
  67333. * @param transform hooked to the agent that will be update by the scene
  67334. * @returns agent index
  67335. */
  67336. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67337. /**
  67338. * Returns the agent position in world space
  67339. * @param index agent index returned by addAgent
  67340. * @returns world space position
  67341. */
  67342. getAgentPosition(index: number): Vector3;
  67343. /**
  67344. * Returns the agent position result in world space
  67345. * @param index agent index returned by addAgent
  67346. * @param result output world space position
  67347. */
  67348. getAgentPositionToRef(index: number, result: Vector3): void;
  67349. /**
  67350. * Returns the agent velocity in world space
  67351. * @param index agent index returned by addAgent
  67352. * @returns world space velocity
  67353. */
  67354. getAgentVelocity(index: number): Vector3;
  67355. /**
  67356. * Returns the agent velocity result in world space
  67357. * @param index agent index returned by addAgent
  67358. * @param result output world space velocity
  67359. */
  67360. getAgentVelocityToRef(index: number, result: Vector3): void;
  67361. /**
  67362. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67363. * @param index agent index returned by addAgent
  67364. * @param destination targeted world position
  67365. */
  67366. agentGoto(index: number, destination: Vector3): void;
  67367. /**
  67368. * Teleport the agent to a new position
  67369. * @param index agent index returned by addAgent
  67370. * @param destination targeted world position
  67371. */
  67372. agentTeleport(index: number, destination: Vector3): void;
  67373. /**
  67374. * Update agent parameters
  67375. * @param index agent index returned by addAgent
  67376. * @param parameters agent parameters
  67377. */
  67378. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67379. /**
  67380. * remove a particular agent previously created
  67381. * @param index agent index returned by addAgent
  67382. */
  67383. removeAgent(index: number): void;
  67384. /**
  67385. * get the list of all agents attached to this crowd
  67386. * @returns list of agent indices
  67387. */
  67388. getAgents(): number[];
  67389. /**
  67390. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67391. * @param deltaTime in seconds
  67392. */
  67393. update(deltaTime: number): void;
  67394. /**
  67395. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67396. * The queries will try to find a solution within those bounds
  67397. * default is (1,1,1)
  67398. * @param extent x,y,z value that define the extent around the queries point of reference
  67399. */
  67400. setDefaultQueryExtent(extent: Vector3): void;
  67401. /**
  67402. * Get the Bounding box extent specified by setDefaultQueryExtent
  67403. * @returns the box extent values
  67404. */
  67405. getDefaultQueryExtent(): Vector3;
  67406. /**
  67407. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67408. * @param result output the box extent values
  67409. */
  67410. getDefaultQueryExtentToRef(result: Vector3): void;
  67411. /**
  67412. * Release all resources
  67413. */
  67414. dispose(): void;
  67415. }
  67416. }
  67417. declare module BABYLON {
  67418. /**
  67419. * Class used to enable access to IndexedDB
  67420. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67421. */
  67422. export class Database implements IOfflineProvider {
  67423. private _callbackManifestChecked;
  67424. private _currentSceneUrl;
  67425. private _db;
  67426. private _enableSceneOffline;
  67427. private _enableTexturesOffline;
  67428. private _manifestVersionFound;
  67429. private _mustUpdateRessources;
  67430. private _hasReachedQuota;
  67431. private _isSupported;
  67432. private _idbFactory;
  67433. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67434. private static IsUASupportingBlobStorage;
  67435. /**
  67436. * Gets a boolean indicating if Database storate is enabled (off by default)
  67437. */
  67438. static IDBStorageEnabled: boolean;
  67439. /**
  67440. * Gets a boolean indicating if scene must be saved in the database
  67441. */
  67442. get enableSceneOffline(): boolean;
  67443. /**
  67444. * Gets a boolean indicating if textures must be saved in the database
  67445. */
  67446. get enableTexturesOffline(): boolean;
  67447. /**
  67448. * Creates a new Database
  67449. * @param urlToScene defines the url to load the scene
  67450. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67451. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67452. */
  67453. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67454. private static _ParseURL;
  67455. private static _ReturnFullUrlLocation;
  67456. private _checkManifestFile;
  67457. /**
  67458. * Open the database and make it available
  67459. * @param successCallback defines the callback to call on success
  67460. * @param errorCallback defines the callback to call on error
  67461. */
  67462. open(successCallback: () => void, errorCallback: () => void): void;
  67463. /**
  67464. * Loads an image from the database
  67465. * @param url defines the url to load from
  67466. * @param image defines the target DOM image
  67467. */
  67468. loadImage(url: string, image: HTMLImageElement): void;
  67469. private _loadImageFromDBAsync;
  67470. private _saveImageIntoDBAsync;
  67471. private _checkVersionFromDB;
  67472. private _loadVersionFromDBAsync;
  67473. private _saveVersionIntoDBAsync;
  67474. /**
  67475. * Loads a file from database
  67476. * @param url defines the URL to load from
  67477. * @param sceneLoaded defines a callback to call on success
  67478. * @param progressCallBack defines a callback to call when progress changed
  67479. * @param errorCallback defines a callback to call on error
  67480. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67481. */
  67482. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67483. private _loadFileAsync;
  67484. private _saveFileAsync;
  67485. /**
  67486. * Validates if xhr data is correct
  67487. * @param xhr defines the request to validate
  67488. * @param dataType defines the expected data type
  67489. * @returns true if data is correct
  67490. */
  67491. private static _ValidateXHRData;
  67492. }
  67493. }
  67494. declare module BABYLON {
  67495. /** @hidden */
  67496. export var gpuUpdateParticlesPixelShader: {
  67497. name: string;
  67498. shader: string;
  67499. };
  67500. }
  67501. declare module BABYLON {
  67502. /** @hidden */
  67503. export var gpuUpdateParticlesVertexShader: {
  67504. name: string;
  67505. shader: string;
  67506. };
  67507. }
  67508. declare module BABYLON {
  67509. /** @hidden */
  67510. export var clipPlaneFragmentDeclaration2: {
  67511. name: string;
  67512. shader: string;
  67513. };
  67514. }
  67515. declare module BABYLON {
  67516. /** @hidden */
  67517. export var gpuRenderParticlesPixelShader: {
  67518. name: string;
  67519. shader: string;
  67520. };
  67521. }
  67522. declare module BABYLON {
  67523. /** @hidden */
  67524. export var clipPlaneVertexDeclaration2: {
  67525. name: string;
  67526. shader: string;
  67527. };
  67528. }
  67529. declare module BABYLON {
  67530. /** @hidden */
  67531. export var gpuRenderParticlesVertexShader: {
  67532. name: string;
  67533. shader: string;
  67534. };
  67535. }
  67536. declare module BABYLON {
  67537. /**
  67538. * This represents a GPU particle system in Babylon
  67539. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67540. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67541. */
  67542. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67543. /**
  67544. * The layer mask we are rendering the particles through.
  67545. */
  67546. layerMask: number;
  67547. private _capacity;
  67548. private _activeCount;
  67549. private _currentActiveCount;
  67550. private _accumulatedCount;
  67551. private _renderEffect;
  67552. private _updateEffect;
  67553. private _buffer0;
  67554. private _buffer1;
  67555. private _spriteBuffer;
  67556. private _updateVAO;
  67557. private _renderVAO;
  67558. private _targetIndex;
  67559. private _sourceBuffer;
  67560. private _targetBuffer;
  67561. private _currentRenderId;
  67562. private _started;
  67563. private _stopped;
  67564. private _timeDelta;
  67565. private _randomTexture;
  67566. private _randomTexture2;
  67567. private _attributesStrideSize;
  67568. private _updateEffectOptions;
  67569. private _randomTextureSize;
  67570. private _actualFrame;
  67571. private _customEffect;
  67572. private readonly _rawTextureWidth;
  67573. /**
  67574. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67575. */
  67576. static get IsSupported(): boolean;
  67577. /**
  67578. * An event triggered when the system is disposed.
  67579. */
  67580. onDisposeObservable: Observable<IParticleSystem>;
  67581. /**
  67582. * Gets the maximum number of particles active at the same time.
  67583. * @returns The max number of active particles.
  67584. */
  67585. getCapacity(): number;
  67586. /**
  67587. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67588. * to override the particles.
  67589. */
  67590. forceDepthWrite: boolean;
  67591. /**
  67592. * Gets or set the number of active particles
  67593. */
  67594. get activeParticleCount(): number;
  67595. set activeParticleCount(value: number);
  67596. private _preWarmDone;
  67597. /**
  67598. * Specifies if the particles are updated in emitter local space or world space.
  67599. */
  67600. isLocal: boolean;
  67601. /** Gets or sets a matrix to use to compute projection */
  67602. defaultProjectionMatrix: Matrix;
  67603. /**
  67604. * Is this system ready to be used/rendered
  67605. * @return true if the system is ready
  67606. */
  67607. isReady(): boolean;
  67608. /**
  67609. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67610. * @returns True if it has been started, otherwise false.
  67611. */
  67612. isStarted(): boolean;
  67613. /**
  67614. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67615. * @returns True if it has been stopped, otherwise false.
  67616. */
  67617. isStopped(): boolean;
  67618. /**
  67619. * Gets a boolean indicating that the system is stopping
  67620. * @returns true if the system is currently stopping
  67621. */
  67622. isStopping(): boolean;
  67623. /**
  67624. * Gets the number of particles active at the same time.
  67625. * @returns The number of active particles.
  67626. */
  67627. getActiveCount(): number;
  67628. /**
  67629. * Starts the particle system and begins to emit
  67630. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67631. */
  67632. start(delay?: number): void;
  67633. /**
  67634. * Stops the particle system.
  67635. */
  67636. stop(): void;
  67637. /**
  67638. * Remove all active particles
  67639. */
  67640. reset(): void;
  67641. /**
  67642. * Returns the string "GPUParticleSystem"
  67643. * @returns a string containing the class name
  67644. */
  67645. getClassName(): string;
  67646. /**
  67647. * Gets the custom effect used to render the particles
  67648. * @param blendMode Blend mode for which the effect should be retrieved
  67649. * @returns The effect
  67650. */
  67651. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67652. /**
  67653. * Sets the custom effect used to render the particles
  67654. * @param effect The effect to set
  67655. * @param blendMode Blend mode for which the effect should be set
  67656. */
  67657. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67658. /** @hidden */
  67659. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67660. /**
  67661. * Observable that will be called just before the particles are drawn
  67662. */
  67663. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67664. /**
  67665. * Gets the name of the particle vertex shader
  67666. */
  67667. get vertexShaderName(): string;
  67668. private _colorGradientsTexture;
  67669. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67670. /**
  67671. * Adds a new color gradient
  67672. * @param gradient defines the gradient to use (between 0 and 1)
  67673. * @param color1 defines the color to affect to the specified gradient
  67674. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67675. * @returns the current particle system
  67676. */
  67677. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67678. private _refreshColorGradient;
  67679. /** Force the system to rebuild all gradients that need to be resync */
  67680. forceRefreshGradients(): void;
  67681. /**
  67682. * Remove a specific color gradient
  67683. * @param gradient defines the gradient to remove
  67684. * @returns the current particle system
  67685. */
  67686. removeColorGradient(gradient: number): GPUParticleSystem;
  67687. private _angularSpeedGradientsTexture;
  67688. private _sizeGradientsTexture;
  67689. private _velocityGradientsTexture;
  67690. private _limitVelocityGradientsTexture;
  67691. private _dragGradientsTexture;
  67692. private _addFactorGradient;
  67693. /**
  67694. * Adds a new size gradient
  67695. * @param gradient defines the gradient to use (between 0 and 1)
  67696. * @param factor defines the size factor to affect to the specified gradient
  67697. * @returns the current particle system
  67698. */
  67699. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67700. /**
  67701. * Remove a specific size gradient
  67702. * @param gradient defines the gradient to remove
  67703. * @returns the current particle system
  67704. */
  67705. removeSizeGradient(gradient: number): GPUParticleSystem;
  67706. private _refreshFactorGradient;
  67707. /**
  67708. * Adds a new angular speed gradient
  67709. * @param gradient defines the gradient to use (between 0 and 1)
  67710. * @param factor defines the angular speed to affect to the specified gradient
  67711. * @returns the current particle system
  67712. */
  67713. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67714. /**
  67715. * Remove a specific angular speed gradient
  67716. * @param gradient defines the gradient to remove
  67717. * @returns the current particle system
  67718. */
  67719. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67720. /**
  67721. * Adds a new velocity gradient
  67722. * @param gradient defines the gradient to use (between 0 and 1)
  67723. * @param factor defines the velocity to affect to the specified gradient
  67724. * @returns the current particle system
  67725. */
  67726. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67727. /**
  67728. * Remove a specific velocity gradient
  67729. * @param gradient defines the gradient to remove
  67730. * @returns the current particle system
  67731. */
  67732. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67733. /**
  67734. * Adds a new limit velocity gradient
  67735. * @param gradient defines the gradient to use (between 0 and 1)
  67736. * @param factor defines the limit velocity value to affect to the specified gradient
  67737. * @returns the current particle system
  67738. */
  67739. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67740. /**
  67741. * Remove a specific limit velocity gradient
  67742. * @param gradient defines the gradient to remove
  67743. * @returns the current particle system
  67744. */
  67745. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67746. /**
  67747. * Adds a new drag gradient
  67748. * @param gradient defines the gradient to use (between 0 and 1)
  67749. * @param factor defines the drag value to affect to the specified gradient
  67750. * @returns the current particle system
  67751. */
  67752. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67753. /**
  67754. * Remove a specific drag gradient
  67755. * @param gradient defines the gradient to remove
  67756. * @returns the current particle system
  67757. */
  67758. removeDragGradient(gradient: number): GPUParticleSystem;
  67759. /**
  67760. * Not supported by GPUParticleSystem
  67761. * @param gradient defines the gradient to use (between 0 and 1)
  67762. * @param factor defines the emit rate value to affect to the specified gradient
  67763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67764. * @returns the current particle system
  67765. */
  67766. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67767. /**
  67768. * Not supported by GPUParticleSystem
  67769. * @param gradient defines the gradient to remove
  67770. * @returns the current particle system
  67771. */
  67772. removeEmitRateGradient(gradient: number): IParticleSystem;
  67773. /**
  67774. * Not supported by GPUParticleSystem
  67775. * @param gradient defines the gradient to use (between 0 and 1)
  67776. * @param factor defines the start size value to affect to the specified gradient
  67777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67778. * @returns the current particle system
  67779. */
  67780. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67781. /**
  67782. * Not supported by GPUParticleSystem
  67783. * @param gradient defines the gradient to remove
  67784. * @returns the current particle system
  67785. */
  67786. removeStartSizeGradient(gradient: number): IParticleSystem;
  67787. /**
  67788. * Not supported by GPUParticleSystem
  67789. * @param gradient defines the gradient to use (between 0 and 1)
  67790. * @param min defines the color remap minimal range
  67791. * @param max defines the color remap maximal range
  67792. * @returns the current particle system
  67793. */
  67794. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67795. /**
  67796. * Not supported by GPUParticleSystem
  67797. * @param gradient defines the gradient to remove
  67798. * @returns the current particle system
  67799. */
  67800. removeColorRemapGradient(): IParticleSystem;
  67801. /**
  67802. * Not supported by GPUParticleSystem
  67803. * @param gradient defines the gradient to use (between 0 and 1)
  67804. * @param min defines the alpha remap minimal range
  67805. * @param max defines the alpha remap maximal range
  67806. * @returns the current particle system
  67807. */
  67808. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67809. /**
  67810. * Not supported by GPUParticleSystem
  67811. * @param gradient defines the gradient to remove
  67812. * @returns the current particle system
  67813. */
  67814. removeAlphaRemapGradient(): IParticleSystem;
  67815. /**
  67816. * Not supported by GPUParticleSystem
  67817. * @param gradient defines the gradient to use (between 0 and 1)
  67818. * @param color defines the color to affect to the specified gradient
  67819. * @returns the current particle system
  67820. */
  67821. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67822. /**
  67823. * Not supported by GPUParticleSystem
  67824. * @param gradient defines the gradient to remove
  67825. * @returns the current particle system
  67826. */
  67827. removeRampGradient(): IParticleSystem;
  67828. /**
  67829. * Not supported by GPUParticleSystem
  67830. * @returns the list of ramp gradients
  67831. */
  67832. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67833. /**
  67834. * Not supported by GPUParticleSystem
  67835. * Gets or sets a boolean indicating that ramp gradients must be used
  67836. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67837. */
  67838. get useRampGradients(): boolean;
  67839. set useRampGradients(value: boolean);
  67840. /**
  67841. * Not supported by GPUParticleSystem
  67842. * @param gradient defines the gradient to use (between 0 and 1)
  67843. * @param factor defines the life time factor to affect to the specified gradient
  67844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67845. * @returns the current particle system
  67846. */
  67847. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67848. /**
  67849. * Not supported by GPUParticleSystem
  67850. * @param gradient defines the gradient to remove
  67851. * @returns the current particle system
  67852. */
  67853. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67854. /**
  67855. * Instantiates a GPU particle system.
  67856. * 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.
  67857. * @param name The name of the particle system
  67858. * @param options The options used to create the system
  67859. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67860. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67861. * @param customEffect a custom effect used to change the way particles are rendered by default
  67862. */
  67863. constructor(name: string, options: Partial<{
  67864. capacity: number;
  67865. randomTextureSize: number;
  67866. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67867. protected _reset(): void;
  67868. private _createUpdateVAO;
  67869. private _createRenderVAO;
  67870. private _initialize;
  67871. /** @hidden */
  67872. _recreateUpdateEffect(): void;
  67873. private _getEffect;
  67874. /**
  67875. * Fill the defines array according to the current settings of the particle system
  67876. * @param defines Array to be updated
  67877. * @param blendMode blend mode to take into account when updating the array
  67878. */
  67879. fillDefines(defines: Array<string>, blendMode?: number): void;
  67880. /**
  67881. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67882. * @param uniforms Uniforms array to fill
  67883. * @param attributes Attributes array to fill
  67884. * @param samplers Samplers array to fill
  67885. */
  67886. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67887. /** @hidden */
  67888. _recreateRenderEffect(): Effect;
  67889. /**
  67890. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67891. * @param preWarm defines if we are in the pre-warmimg phase
  67892. */
  67893. animate(preWarm?: boolean): void;
  67894. private _createFactorGradientTexture;
  67895. private _createSizeGradientTexture;
  67896. private _createAngularSpeedGradientTexture;
  67897. private _createVelocityGradientTexture;
  67898. private _createLimitVelocityGradientTexture;
  67899. private _createDragGradientTexture;
  67900. private _createColorGradientTexture;
  67901. /**
  67902. * Renders the particle system in its current state
  67903. * @param preWarm defines if the system should only update the particles but not render them
  67904. * @returns the current number of particles
  67905. */
  67906. render(preWarm?: boolean): number;
  67907. /**
  67908. * Rebuilds the particle system
  67909. */
  67910. rebuild(): void;
  67911. private _releaseBuffers;
  67912. private _releaseVAOs;
  67913. /**
  67914. * Disposes the particle system and free the associated resources
  67915. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67916. */
  67917. dispose(disposeTexture?: boolean): void;
  67918. /**
  67919. * Clones the particle system.
  67920. * @param name The name of the cloned object
  67921. * @param newEmitter The new emitter to use
  67922. * @returns the cloned particle system
  67923. */
  67924. clone(name: string, newEmitter: any): GPUParticleSystem;
  67925. /**
  67926. * Serializes the particle system to a JSON object
  67927. * @param serializeTexture defines if the texture must be serialized as well
  67928. * @returns the JSON object
  67929. */
  67930. serialize(serializeTexture?: boolean): any;
  67931. /**
  67932. * Parses a JSON object to create a GPU particle system.
  67933. * @param parsedParticleSystem The JSON object to parse
  67934. * @param sceneOrEngine The scene or the engine to create the particle system in
  67935. * @param rootUrl The root url to use to load external dependencies like texture
  67936. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67937. * @returns the parsed GPU particle system
  67938. */
  67939. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67940. }
  67941. }
  67942. declare module BABYLON {
  67943. /**
  67944. * Represents a set of particle systems working together to create a specific effect
  67945. */
  67946. export class ParticleSystemSet implements IDisposable {
  67947. /**
  67948. * Gets or sets base Assets URL
  67949. */
  67950. static BaseAssetsUrl: string;
  67951. private _emitterCreationOptions;
  67952. private _emitterNode;
  67953. /**
  67954. * Gets the particle system list
  67955. */
  67956. systems: IParticleSystem[];
  67957. /**
  67958. * Gets the emitter node used with this set
  67959. */
  67960. get emitterNode(): Nullable<TransformNode>;
  67961. /**
  67962. * Creates a new emitter mesh as a sphere
  67963. * @param options defines the options used to create the sphere
  67964. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67965. * @param scene defines the hosting scene
  67966. */
  67967. setEmitterAsSphere(options: {
  67968. diameter: number;
  67969. segments: number;
  67970. color: Color3;
  67971. }, renderingGroupId: number, scene: Scene): void;
  67972. /**
  67973. * Starts all particle systems of the set
  67974. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67975. */
  67976. start(emitter?: AbstractMesh): void;
  67977. /**
  67978. * Release all associated resources
  67979. */
  67980. dispose(): void;
  67981. /**
  67982. * Serialize the set into a JSON compatible object
  67983. * @param serializeTexture defines if the texture must be serialized as well
  67984. * @returns a JSON compatible representation of the set
  67985. */
  67986. serialize(serializeTexture?: boolean): any;
  67987. /**
  67988. * Parse a new ParticleSystemSet from a serialized source
  67989. * @param data defines a JSON compatible representation of the set
  67990. * @param scene defines the hosting scene
  67991. * @param gpu defines if we want GPU particles or CPU particles
  67992. * @returns a new ParticleSystemSet
  67993. */
  67994. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67995. }
  67996. }
  67997. declare module BABYLON {
  67998. /**
  67999. * This class is made for on one-liner static method to help creating particle system set.
  68000. */
  68001. export class ParticleHelper {
  68002. /**
  68003. * Gets or sets base Assets URL
  68004. */
  68005. static BaseAssetsUrl: string;
  68006. /** Define the Url to load snippets */
  68007. static SnippetUrl: string;
  68008. /**
  68009. * Create a default particle system that you can tweak
  68010. * @param emitter defines the emitter to use
  68011. * @param capacity defines the system capacity (default is 500 particles)
  68012. * @param scene defines the hosting scene
  68013. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68014. * @returns the new Particle system
  68015. */
  68016. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68017. /**
  68018. * This is the main static method (one-liner) of this helper to create different particle systems
  68019. * @param type This string represents the type to the particle system to create
  68020. * @param scene The scene where the particle system should live
  68021. * @param gpu If the system will use gpu
  68022. * @returns the ParticleSystemSet created
  68023. */
  68024. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68025. /**
  68026. * Static function used to export a particle system to a ParticleSystemSet variable.
  68027. * Please note that the emitter shape is not exported
  68028. * @param systems defines the particle systems to export
  68029. * @returns the created particle system set
  68030. */
  68031. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68032. /**
  68033. * Creates a particle system from a snippet saved in a remote file
  68034. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68035. * @param url defines the url to load from
  68036. * @param scene defines the hosting scene
  68037. * @param gpu If the system will use gpu
  68038. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68039. * @returns a promise that will resolve to the new particle system
  68040. */
  68041. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68042. /**
  68043. * Creates a particle system from a snippet saved by the particle system editor
  68044. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68045. * @param scene defines the hosting scene
  68046. * @param gpu If the system will use gpu
  68047. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68048. * @returns a promise that will resolve to the new particle system
  68049. */
  68050. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68051. }
  68052. }
  68053. declare module BABYLON {
  68054. interface Engine {
  68055. /**
  68056. * Create an effect to use with particle systems.
  68057. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68058. * the particle system for which you want to create a custom effect in the last parameter
  68059. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68060. * @param uniformsNames defines a list of attribute names
  68061. * @param samplers defines an array of string used to represent textures
  68062. * @param defines defines the string containing the defines to use to compile the shaders
  68063. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68064. * @param onCompiled defines a function to call when the effect creation is successful
  68065. * @param onError defines a function to call when the effect creation has failed
  68066. * @param particleSystem the particle system you want to create the effect for
  68067. * @returns the new Effect
  68068. */
  68069. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68070. }
  68071. interface Mesh {
  68072. /**
  68073. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68074. * @returns an array of IParticleSystem
  68075. */
  68076. getEmittedParticleSystems(): IParticleSystem[];
  68077. /**
  68078. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68079. * @returns an array of IParticleSystem
  68080. */
  68081. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68082. }
  68083. }
  68084. declare module BABYLON {
  68085. /** Defines the 4 color options */
  68086. export enum PointColor {
  68087. /** color value */
  68088. Color = 2,
  68089. /** uv value */
  68090. UV = 1,
  68091. /** random value */
  68092. Random = 0,
  68093. /** stated value */
  68094. Stated = 3
  68095. }
  68096. /**
  68097. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68098. * 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.
  68099. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68100. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68101. *
  68102. * Full documentation here : TO BE ENTERED
  68103. */
  68104. export class PointsCloudSystem implements IDisposable {
  68105. /**
  68106. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68107. * Example : var p = SPS.particles[i];
  68108. */
  68109. particles: CloudPoint[];
  68110. /**
  68111. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68112. */
  68113. nbParticles: number;
  68114. /**
  68115. * This a counter for your own usage. It's not set by any SPS functions.
  68116. */
  68117. counter: number;
  68118. /**
  68119. * The PCS name. This name is also given to the underlying mesh.
  68120. */
  68121. name: string;
  68122. /**
  68123. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68124. */
  68125. mesh: Mesh;
  68126. /**
  68127. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68128. * Please read :
  68129. */
  68130. vars: any;
  68131. /**
  68132. * @hidden
  68133. */
  68134. _size: number;
  68135. private _scene;
  68136. private _promises;
  68137. private _positions;
  68138. private _indices;
  68139. private _normals;
  68140. private _colors;
  68141. private _uvs;
  68142. private _indices32;
  68143. private _positions32;
  68144. private _colors32;
  68145. private _uvs32;
  68146. private _updatable;
  68147. private _isVisibilityBoxLocked;
  68148. private _alwaysVisible;
  68149. private _groups;
  68150. private _groupCounter;
  68151. private _computeParticleColor;
  68152. private _computeParticleTexture;
  68153. private _computeParticleRotation;
  68154. private _computeBoundingBox;
  68155. private _isReady;
  68156. /**
  68157. * Creates a PCS (Points Cloud System) object
  68158. * @param name (String) is the PCS name, this will be the underlying mesh name
  68159. * @param pointSize (number) is the size for each point
  68160. * @param scene (Scene) is the scene in which the PCS is added
  68161. * @param options defines the options of the PCS e.g.
  68162. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68163. */
  68164. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68165. updatable?: boolean;
  68166. });
  68167. /**
  68168. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68169. * If no points were added to the PCS, the returned mesh is just a single point.
  68170. * @returns a promise for the created mesh
  68171. */
  68172. buildMeshAsync(): Promise<Mesh>;
  68173. /**
  68174. * @hidden
  68175. */
  68176. private _buildMesh;
  68177. private _addParticle;
  68178. private _randomUnitVector;
  68179. private _getColorIndicesForCoord;
  68180. private _setPointsColorOrUV;
  68181. private _colorFromTexture;
  68182. private _calculateDensity;
  68183. /**
  68184. * Adds points to the PCS in random positions within a unit sphere
  68185. * @param nb (positive integer) the number of particles to be created from this model
  68186. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68187. * @returns the number of groups in the system
  68188. */
  68189. addPoints(nb: number, pointFunction?: any): number;
  68190. /**
  68191. * Adds points to the PCS from the surface of the model shape
  68192. * @param mesh is any Mesh object that will be used as a surface model for the points
  68193. * @param nb (positive integer) the number of particles to be created from this model
  68194. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68195. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68196. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68197. * @returns the number of groups in the system
  68198. */
  68199. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68200. /**
  68201. * Adds points to the PCS inside the model shape
  68202. * @param mesh is any Mesh object that will be used as a surface model for the points
  68203. * @param nb (positive integer) the number of particles to be created from this model
  68204. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68205. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68206. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68207. * @returns the number of groups in the system
  68208. */
  68209. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68210. /**
  68211. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68212. * This method calls `updateParticle()` for each particle of the SPS.
  68213. * For an animated SPS, it is usually called within the render loop.
  68214. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68215. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68216. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68217. * @returns the PCS.
  68218. */
  68219. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68220. /**
  68221. * Disposes the PCS.
  68222. */
  68223. dispose(): void;
  68224. /**
  68225. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68226. * doc :
  68227. * @returns the PCS.
  68228. */
  68229. refreshVisibleSize(): PointsCloudSystem;
  68230. /**
  68231. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68232. * @param size the size (float) of the visibility box
  68233. * note : this doesn't lock the PCS mesh bounding box.
  68234. * doc :
  68235. */
  68236. setVisibilityBox(size: number): void;
  68237. /**
  68238. * Gets whether the PCS is always visible or not
  68239. * doc :
  68240. */
  68241. get isAlwaysVisible(): boolean;
  68242. /**
  68243. * Sets the PCS as always visible or not
  68244. * doc :
  68245. */
  68246. set isAlwaysVisible(val: boolean);
  68247. /**
  68248. * Tells to `setParticles()` to compute the particle rotations or not
  68249. * Default value : false. The PCS is faster when it's set to false
  68250. * Note : particle rotations are only applied to parent particles
  68251. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68252. */
  68253. set computeParticleRotation(val: boolean);
  68254. /**
  68255. * Tells to `setParticles()` to compute the particle colors or not.
  68256. * Default value : true. The PCS is faster when it's set to false.
  68257. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68258. */
  68259. set computeParticleColor(val: boolean);
  68260. set computeParticleTexture(val: boolean);
  68261. /**
  68262. * Gets if `setParticles()` computes the particle colors or not.
  68263. * Default value : false. The PCS is faster when it's set to false.
  68264. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68265. */
  68266. get computeParticleColor(): boolean;
  68267. /**
  68268. * Gets if `setParticles()` computes the particle textures or not.
  68269. * Default value : false. The PCS is faster when it's set to false.
  68270. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68271. */
  68272. get computeParticleTexture(): boolean;
  68273. /**
  68274. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68275. */
  68276. set computeBoundingBox(val: boolean);
  68277. /**
  68278. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68279. */
  68280. get computeBoundingBox(): boolean;
  68281. /**
  68282. * This function does nothing. It may be overwritten to set all the particle first values.
  68283. * The PCS doesn't call this function, you may have to call it by your own.
  68284. * doc :
  68285. */
  68286. initParticles(): void;
  68287. /**
  68288. * This function does nothing. It may be overwritten to recycle a particle
  68289. * The PCS doesn't call this function, you can to call it
  68290. * doc :
  68291. * @param particle The particle to recycle
  68292. * @returns the recycled particle
  68293. */
  68294. recycleParticle(particle: CloudPoint): CloudPoint;
  68295. /**
  68296. * Updates a particle : this function should be overwritten by the user.
  68297. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68298. * doc :
  68299. * @example : just set a particle position or velocity and recycle conditions
  68300. * @param particle The particle to update
  68301. * @returns the updated particle
  68302. */
  68303. updateParticle(particle: CloudPoint): CloudPoint;
  68304. /**
  68305. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68306. * This does nothing and may be overwritten by the user.
  68307. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68308. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68309. * @param update the boolean update value actually passed to setParticles()
  68310. */
  68311. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68312. /**
  68313. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68314. * This will be passed three parameters.
  68315. * This does nothing and may be overwritten by the user.
  68316. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68317. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68318. * @param update the boolean update value actually passed to setParticles()
  68319. */
  68320. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68321. }
  68322. }
  68323. declare module BABYLON {
  68324. /**
  68325. * Represents one particle of a points cloud system.
  68326. */
  68327. export class CloudPoint {
  68328. /**
  68329. * particle global index
  68330. */
  68331. idx: number;
  68332. /**
  68333. * The color of the particle
  68334. */
  68335. color: Nullable<Color4>;
  68336. /**
  68337. * The world space position of the particle.
  68338. */
  68339. position: Vector3;
  68340. /**
  68341. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68342. */
  68343. rotation: Vector3;
  68344. /**
  68345. * The world space rotation quaternion of the particle.
  68346. */
  68347. rotationQuaternion: Nullable<Quaternion>;
  68348. /**
  68349. * The uv of the particle.
  68350. */
  68351. uv: Nullable<Vector2>;
  68352. /**
  68353. * The current speed of the particle.
  68354. */
  68355. velocity: Vector3;
  68356. /**
  68357. * The pivot point in the particle local space.
  68358. */
  68359. pivot: Vector3;
  68360. /**
  68361. * Must the particle be translated from its pivot point in its local space ?
  68362. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68363. * Default : false
  68364. */
  68365. translateFromPivot: boolean;
  68366. /**
  68367. * Index of this particle in the global "positions" array (Internal use)
  68368. * @hidden
  68369. */
  68370. _pos: number;
  68371. /**
  68372. * @hidden Index of this particle in the global "indices" array (Internal use)
  68373. */
  68374. _ind: number;
  68375. /**
  68376. * Group this particle belongs to
  68377. */
  68378. _group: PointsGroup;
  68379. /**
  68380. * Group id of this particle
  68381. */
  68382. groupId: number;
  68383. /**
  68384. * Index of the particle in its group id (Internal use)
  68385. */
  68386. idxInGroup: number;
  68387. /**
  68388. * @hidden Particle BoundingInfo object (Internal use)
  68389. */
  68390. _boundingInfo: BoundingInfo;
  68391. /**
  68392. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68393. */
  68394. _pcs: PointsCloudSystem;
  68395. /**
  68396. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68397. */
  68398. _stillInvisible: boolean;
  68399. /**
  68400. * @hidden Last computed particle rotation matrix
  68401. */
  68402. _rotationMatrix: number[];
  68403. /**
  68404. * Parent particle Id, if any.
  68405. * Default null.
  68406. */
  68407. parentId: Nullable<number>;
  68408. /**
  68409. * @hidden Internal global position in the PCS.
  68410. */
  68411. _globalPosition: Vector3;
  68412. /**
  68413. * Creates a Point Cloud object.
  68414. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68415. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68416. * @param group (PointsGroup) is the group the particle belongs to
  68417. * @param groupId (integer) is the group identifier in the PCS.
  68418. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68419. * @param pcs defines the PCS it is associated to
  68420. */
  68421. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68422. /**
  68423. * get point size
  68424. */
  68425. get size(): Vector3;
  68426. /**
  68427. * Set point size
  68428. */
  68429. set size(scale: Vector3);
  68430. /**
  68431. * Legacy support, changed quaternion to rotationQuaternion
  68432. */
  68433. get quaternion(): Nullable<Quaternion>;
  68434. /**
  68435. * Legacy support, changed quaternion to rotationQuaternion
  68436. */
  68437. set quaternion(q: Nullable<Quaternion>);
  68438. /**
  68439. * Returns a boolean. True if the particle intersects a mesh, else false
  68440. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68441. * @param target is the object (point or mesh) what the intersection is computed against
  68442. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68443. * @returns true if it intersects
  68444. */
  68445. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68446. /**
  68447. * get the rotation matrix of the particle
  68448. * @hidden
  68449. */
  68450. getRotationMatrix(m: Matrix): void;
  68451. }
  68452. /**
  68453. * Represents a group of points in a points cloud system
  68454. * * PCS internal tool, don't use it manually.
  68455. */
  68456. export class PointsGroup {
  68457. /**
  68458. * The group id
  68459. * @hidden
  68460. */
  68461. groupID: number;
  68462. /**
  68463. * image data for group (internal use)
  68464. * @hidden
  68465. */
  68466. _groupImageData: Nullable<ArrayBufferView>;
  68467. /**
  68468. * Image Width (internal use)
  68469. * @hidden
  68470. */
  68471. _groupImgWidth: number;
  68472. /**
  68473. * Image Height (internal use)
  68474. * @hidden
  68475. */
  68476. _groupImgHeight: number;
  68477. /**
  68478. * Custom position function (internal use)
  68479. * @hidden
  68480. */
  68481. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68482. /**
  68483. * density per facet for surface points
  68484. * @hidden
  68485. */
  68486. _groupDensity: number[];
  68487. /**
  68488. * Only when points are colored by texture carries pointer to texture list array
  68489. * @hidden
  68490. */
  68491. _textureNb: number;
  68492. /**
  68493. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68494. * PCS internal tool, don't use it manually.
  68495. * @hidden
  68496. */
  68497. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68498. }
  68499. }
  68500. declare module BABYLON {
  68501. interface Scene {
  68502. /** @hidden (Backing field) */
  68503. _physicsEngine: Nullable<IPhysicsEngine>;
  68504. /** @hidden */
  68505. _physicsTimeAccumulator: number;
  68506. /**
  68507. * Gets the current physics engine
  68508. * @returns a IPhysicsEngine or null if none attached
  68509. */
  68510. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68511. /**
  68512. * Enables physics to the current scene
  68513. * @param gravity defines the scene's gravity for the physics engine
  68514. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68515. * @return a boolean indicating if the physics engine was initialized
  68516. */
  68517. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68518. /**
  68519. * Disables and disposes the physics engine associated with the scene
  68520. */
  68521. disablePhysicsEngine(): void;
  68522. /**
  68523. * Gets a boolean indicating if there is an active physics engine
  68524. * @returns a boolean indicating if there is an active physics engine
  68525. */
  68526. isPhysicsEnabled(): boolean;
  68527. /**
  68528. * Deletes a physics compound impostor
  68529. * @param compound defines the compound to delete
  68530. */
  68531. deleteCompoundImpostor(compound: any): void;
  68532. /**
  68533. * An event triggered when physic simulation is about to be run
  68534. */
  68535. onBeforePhysicsObservable: Observable<Scene>;
  68536. /**
  68537. * An event triggered when physic simulation has been done
  68538. */
  68539. onAfterPhysicsObservable: Observable<Scene>;
  68540. }
  68541. interface AbstractMesh {
  68542. /** @hidden */
  68543. _physicsImpostor: Nullable<PhysicsImpostor>;
  68544. /**
  68545. * Gets or sets impostor used for physic simulation
  68546. * @see https://doc.babylonjs.com/features/physics_engine
  68547. */
  68548. physicsImpostor: Nullable<PhysicsImpostor>;
  68549. /**
  68550. * Gets the current physics impostor
  68551. * @see https://doc.babylonjs.com/features/physics_engine
  68552. * @returns a physics impostor or null
  68553. */
  68554. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68555. /** Apply a physic impulse to the mesh
  68556. * @param force defines the force to apply
  68557. * @param contactPoint defines where to apply the force
  68558. * @returns the current mesh
  68559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68560. */
  68561. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68562. /**
  68563. * Creates a physic joint between two meshes
  68564. * @param otherMesh defines the other mesh to use
  68565. * @param pivot1 defines the pivot to use on this mesh
  68566. * @param pivot2 defines the pivot to use on the other mesh
  68567. * @param options defines additional options (can be plugin dependent)
  68568. * @returns the current mesh
  68569. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68570. */
  68571. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68572. /** @hidden */
  68573. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68574. }
  68575. /**
  68576. * Defines the physics engine scene component responsible to manage a physics engine
  68577. */
  68578. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68579. /**
  68580. * The component name helpful to identify the component in the list of scene components.
  68581. */
  68582. readonly name: string;
  68583. /**
  68584. * The scene the component belongs to.
  68585. */
  68586. scene: Scene;
  68587. /**
  68588. * Creates a new instance of the component for the given scene
  68589. * @param scene Defines the scene to register the component in
  68590. */
  68591. constructor(scene: Scene);
  68592. /**
  68593. * Registers the component in a given scene
  68594. */
  68595. register(): void;
  68596. /**
  68597. * Rebuilds the elements related to this component in case of
  68598. * context lost for instance.
  68599. */
  68600. rebuild(): void;
  68601. /**
  68602. * Disposes the component and the associated ressources
  68603. */
  68604. dispose(): void;
  68605. }
  68606. }
  68607. declare module BABYLON {
  68608. /**
  68609. * A helper for physics simulations
  68610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68611. */
  68612. export class PhysicsHelper {
  68613. private _scene;
  68614. private _physicsEngine;
  68615. /**
  68616. * Initializes the Physics helper
  68617. * @param scene Babylon.js scene
  68618. */
  68619. constructor(scene: Scene);
  68620. /**
  68621. * Applies a radial explosion impulse
  68622. * @param origin the origin of the explosion
  68623. * @param radiusOrEventOptions the radius or the options of radial explosion
  68624. * @param strength the explosion strength
  68625. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68626. * @returns A physics radial explosion event, or null
  68627. */
  68628. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68629. /**
  68630. * Applies a radial explosion force
  68631. * @param origin the origin of the explosion
  68632. * @param radiusOrEventOptions the radius or the options of radial explosion
  68633. * @param strength the explosion strength
  68634. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68635. * @returns A physics radial explosion event, or null
  68636. */
  68637. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68638. /**
  68639. * Creates a gravitational field
  68640. * @param origin the origin of the explosion
  68641. * @param radiusOrEventOptions the radius or the options of radial explosion
  68642. * @param strength the explosion strength
  68643. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68644. * @returns A physics gravitational field event, or null
  68645. */
  68646. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68647. /**
  68648. * Creates a physics updraft event
  68649. * @param origin the origin of the updraft
  68650. * @param radiusOrEventOptions the radius or the options of the updraft
  68651. * @param strength the strength of the updraft
  68652. * @param height the height of the updraft
  68653. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68654. * @returns A physics updraft event, or null
  68655. */
  68656. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68657. /**
  68658. * Creates a physics vortex event
  68659. * @param origin the of the vortex
  68660. * @param radiusOrEventOptions the radius or the options of the vortex
  68661. * @param strength the strength of the vortex
  68662. * @param height the height of the vortex
  68663. * @returns a Physics vortex event, or null
  68664. * A physics vortex event or null
  68665. */
  68666. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68667. }
  68668. /**
  68669. * Represents a physics radial explosion event
  68670. */
  68671. class PhysicsRadialExplosionEvent {
  68672. private _scene;
  68673. private _options;
  68674. private _sphere;
  68675. private _dataFetched;
  68676. /**
  68677. * Initializes a radial explosioin event
  68678. * @param _scene BabylonJS scene
  68679. * @param _options The options for the vortex event
  68680. */
  68681. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68682. /**
  68683. * Returns the data related to the radial explosion event (sphere).
  68684. * @returns The radial explosion event data
  68685. */
  68686. getData(): PhysicsRadialExplosionEventData;
  68687. /**
  68688. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68689. * @param impostor A physics imposter
  68690. * @param origin the origin of the explosion
  68691. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68692. */
  68693. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68694. /**
  68695. * Triggers affecterd impostors callbacks
  68696. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68697. */
  68698. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68699. /**
  68700. * Disposes the sphere.
  68701. * @param force Specifies if the sphere should be disposed by force
  68702. */
  68703. dispose(force?: boolean): void;
  68704. /*** Helpers ***/
  68705. private _prepareSphere;
  68706. private _intersectsWithSphere;
  68707. }
  68708. /**
  68709. * Represents a gravitational field event
  68710. */
  68711. class PhysicsGravitationalFieldEvent {
  68712. private _physicsHelper;
  68713. private _scene;
  68714. private _origin;
  68715. private _options;
  68716. private _tickCallback;
  68717. private _sphere;
  68718. private _dataFetched;
  68719. /**
  68720. * Initializes the physics gravitational field event
  68721. * @param _physicsHelper A physics helper
  68722. * @param _scene BabylonJS scene
  68723. * @param _origin The origin position of the gravitational field event
  68724. * @param _options The options for the vortex event
  68725. */
  68726. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68727. /**
  68728. * Returns the data related to the gravitational field event (sphere).
  68729. * @returns A gravitational field event
  68730. */
  68731. getData(): PhysicsGravitationalFieldEventData;
  68732. /**
  68733. * Enables the gravitational field.
  68734. */
  68735. enable(): void;
  68736. /**
  68737. * Disables the gravitational field.
  68738. */
  68739. disable(): void;
  68740. /**
  68741. * Disposes the sphere.
  68742. * @param force The force to dispose from the gravitational field event
  68743. */
  68744. dispose(force?: boolean): void;
  68745. private _tick;
  68746. }
  68747. /**
  68748. * Represents a physics updraft event
  68749. */
  68750. class PhysicsUpdraftEvent {
  68751. private _scene;
  68752. private _origin;
  68753. private _options;
  68754. private _physicsEngine;
  68755. private _originTop;
  68756. private _originDirection;
  68757. private _tickCallback;
  68758. private _cylinder;
  68759. private _cylinderPosition;
  68760. private _dataFetched;
  68761. /**
  68762. * Initializes the physics updraft event
  68763. * @param _scene BabylonJS scene
  68764. * @param _origin The origin position of the updraft
  68765. * @param _options The options for the updraft event
  68766. */
  68767. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68768. /**
  68769. * Returns the data related to the updraft event (cylinder).
  68770. * @returns A physics updraft event
  68771. */
  68772. getData(): PhysicsUpdraftEventData;
  68773. /**
  68774. * Enables the updraft.
  68775. */
  68776. enable(): void;
  68777. /**
  68778. * Disables the updraft.
  68779. */
  68780. disable(): void;
  68781. /**
  68782. * Disposes the cylinder.
  68783. * @param force Specifies if the updraft should be disposed by force
  68784. */
  68785. dispose(force?: boolean): void;
  68786. private getImpostorHitData;
  68787. private _tick;
  68788. /*** Helpers ***/
  68789. private _prepareCylinder;
  68790. private _intersectsWithCylinder;
  68791. }
  68792. /**
  68793. * Represents a physics vortex event
  68794. */
  68795. class PhysicsVortexEvent {
  68796. private _scene;
  68797. private _origin;
  68798. private _options;
  68799. private _physicsEngine;
  68800. private _originTop;
  68801. private _tickCallback;
  68802. private _cylinder;
  68803. private _cylinderPosition;
  68804. private _dataFetched;
  68805. /**
  68806. * Initializes the physics vortex event
  68807. * @param _scene The BabylonJS scene
  68808. * @param _origin The origin position of the vortex
  68809. * @param _options The options for the vortex event
  68810. */
  68811. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68812. /**
  68813. * Returns the data related to the vortex event (cylinder).
  68814. * @returns The physics vortex event data
  68815. */
  68816. getData(): PhysicsVortexEventData;
  68817. /**
  68818. * Enables the vortex.
  68819. */
  68820. enable(): void;
  68821. /**
  68822. * Disables the cortex.
  68823. */
  68824. disable(): void;
  68825. /**
  68826. * Disposes the sphere.
  68827. * @param force
  68828. */
  68829. dispose(force?: boolean): void;
  68830. private getImpostorHitData;
  68831. private _tick;
  68832. /*** Helpers ***/
  68833. private _prepareCylinder;
  68834. private _intersectsWithCylinder;
  68835. }
  68836. /**
  68837. * Options fot the radial explosion event
  68838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68839. */
  68840. export class PhysicsRadialExplosionEventOptions {
  68841. /**
  68842. * The radius of the sphere for the radial explosion.
  68843. */
  68844. radius: number;
  68845. /**
  68846. * The strenth of the explosion.
  68847. */
  68848. strength: number;
  68849. /**
  68850. * The strenght of the force in correspondence to the distance of the affected object
  68851. */
  68852. falloff: PhysicsRadialImpulseFalloff;
  68853. /**
  68854. * Sphere options for the radial explosion.
  68855. */
  68856. sphere: {
  68857. segments: number;
  68858. diameter: number;
  68859. };
  68860. /**
  68861. * Sphere options for the radial explosion.
  68862. */
  68863. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68864. }
  68865. /**
  68866. * Options fot the updraft event
  68867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68868. */
  68869. export class PhysicsUpdraftEventOptions {
  68870. /**
  68871. * The radius of the cylinder for the vortex
  68872. */
  68873. radius: number;
  68874. /**
  68875. * The strenth of the updraft.
  68876. */
  68877. strength: number;
  68878. /**
  68879. * The height of the cylinder for the updraft.
  68880. */
  68881. height: number;
  68882. /**
  68883. * The mode for the the updraft.
  68884. */
  68885. updraftMode: PhysicsUpdraftMode;
  68886. }
  68887. /**
  68888. * Options fot the vortex event
  68889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68890. */
  68891. export class PhysicsVortexEventOptions {
  68892. /**
  68893. * The radius of the cylinder for the vortex
  68894. */
  68895. radius: number;
  68896. /**
  68897. * The strenth of the vortex.
  68898. */
  68899. strength: number;
  68900. /**
  68901. * The height of the cylinder for the vortex.
  68902. */
  68903. height: number;
  68904. /**
  68905. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68906. */
  68907. centripetalForceThreshold: number;
  68908. /**
  68909. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68910. */
  68911. centripetalForceMultiplier: number;
  68912. /**
  68913. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68914. */
  68915. centrifugalForceMultiplier: number;
  68916. /**
  68917. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68918. */
  68919. updraftForceMultiplier: number;
  68920. }
  68921. /**
  68922. * The strenght of the force in correspondence to the distance of the affected object
  68923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68924. */
  68925. export enum PhysicsRadialImpulseFalloff {
  68926. /** Defines that impulse is constant in strength across it's whole radius */
  68927. Constant = 0,
  68928. /** Defines that impulse gets weaker if it's further from the origin */
  68929. Linear = 1
  68930. }
  68931. /**
  68932. * The strength of the force in correspondence to the distance of the affected object
  68933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68934. */
  68935. export enum PhysicsUpdraftMode {
  68936. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68937. Center = 0,
  68938. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68939. Perpendicular = 1
  68940. }
  68941. /**
  68942. * Interface for a physics hit data
  68943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68944. */
  68945. export interface PhysicsHitData {
  68946. /**
  68947. * The force applied at the contact point
  68948. */
  68949. force: Vector3;
  68950. /**
  68951. * The contact point
  68952. */
  68953. contactPoint: Vector3;
  68954. /**
  68955. * The distance from the origin to the contact point
  68956. */
  68957. distanceFromOrigin: number;
  68958. }
  68959. /**
  68960. * Interface for radial explosion event data
  68961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68962. */
  68963. export interface PhysicsRadialExplosionEventData {
  68964. /**
  68965. * A sphere used for the radial explosion event
  68966. */
  68967. sphere: Mesh;
  68968. }
  68969. /**
  68970. * Interface for gravitational field event data
  68971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68972. */
  68973. export interface PhysicsGravitationalFieldEventData {
  68974. /**
  68975. * A sphere mesh used for the gravitational field event
  68976. */
  68977. sphere: Mesh;
  68978. }
  68979. /**
  68980. * Interface for updraft event data
  68981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68982. */
  68983. export interface PhysicsUpdraftEventData {
  68984. /**
  68985. * A cylinder used for the updraft event
  68986. */
  68987. cylinder: Mesh;
  68988. }
  68989. /**
  68990. * Interface for vortex event data
  68991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68992. */
  68993. export interface PhysicsVortexEventData {
  68994. /**
  68995. * A cylinder used for the vortex event
  68996. */
  68997. cylinder: Mesh;
  68998. }
  68999. /**
  69000. * Interface for an affected physics impostor
  69001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69002. */
  69003. export interface PhysicsAffectedImpostorWithData {
  69004. /**
  69005. * The impostor affected by the effect
  69006. */
  69007. impostor: PhysicsImpostor;
  69008. /**
  69009. * The data about the hit/horce from the explosion
  69010. */
  69011. hitData: PhysicsHitData;
  69012. }
  69013. }
  69014. declare module BABYLON {
  69015. /** @hidden */
  69016. export var blackAndWhitePixelShader: {
  69017. name: string;
  69018. shader: string;
  69019. };
  69020. }
  69021. declare module BABYLON {
  69022. /**
  69023. * Post process used to render in black and white
  69024. */
  69025. export class BlackAndWhitePostProcess extends PostProcess {
  69026. /**
  69027. * Linear about to convert he result to black and white (default: 1)
  69028. */
  69029. degree: number;
  69030. /**
  69031. * Gets a string identifying the name of the class
  69032. * @returns "BlackAndWhitePostProcess" string
  69033. */
  69034. getClassName(): string;
  69035. /**
  69036. * Creates a black and white post process
  69037. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69038. * @param name The name of the effect.
  69039. * @param options The required width/height ratio to downsize to before computing the render pass.
  69040. * @param camera The camera to apply the render pass to.
  69041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69042. * @param engine The engine which the post process will be applied. (default: current engine)
  69043. * @param reusable If the post process can be reused on the same frame. (default: false)
  69044. */
  69045. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69046. /** @hidden */
  69047. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69048. }
  69049. }
  69050. declare module BABYLON {
  69051. /**
  69052. * This represents a set of one or more post processes in Babylon.
  69053. * A post process can be used to apply a shader to a texture after it is rendered.
  69054. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69055. */
  69056. export class PostProcessRenderEffect {
  69057. private _postProcesses;
  69058. private _getPostProcesses;
  69059. private _singleInstance;
  69060. private _cameras;
  69061. private _indicesForCamera;
  69062. /**
  69063. * Name of the effect
  69064. * @hidden
  69065. */
  69066. _name: string;
  69067. /**
  69068. * Instantiates a post process render effect.
  69069. * A post process can be used to apply a shader to a texture after it is rendered.
  69070. * @param engine The engine the effect is tied to
  69071. * @param name The name of the effect
  69072. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69073. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69074. */
  69075. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69076. /**
  69077. * Checks if all the post processes in the effect are supported.
  69078. */
  69079. get isSupported(): boolean;
  69080. /**
  69081. * Updates the current state of the effect
  69082. * @hidden
  69083. */
  69084. _update(): void;
  69085. /**
  69086. * Attaches the effect on cameras
  69087. * @param cameras The camera to attach to.
  69088. * @hidden
  69089. */
  69090. _attachCameras(cameras: Camera): void;
  69091. /**
  69092. * Attaches the effect on cameras
  69093. * @param cameras The camera to attach to.
  69094. * @hidden
  69095. */
  69096. _attachCameras(cameras: Camera[]): void;
  69097. /**
  69098. * Detaches the effect on cameras
  69099. * @param cameras The camera to detatch from.
  69100. * @hidden
  69101. */
  69102. _detachCameras(cameras: Camera): void;
  69103. /**
  69104. * Detatches the effect on cameras
  69105. * @param cameras The camera to detatch from.
  69106. * @hidden
  69107. */
  69108. _detachCameras(cameras: Camera[]): void;
  69109. /**
  69110. * Enables the effect on given cameras
  69111. * @param cameras The camera to enable.
  69112. * @hidden
  69113. */
  69114. _enable(cameras: Camera): void;
  69115. /**
  69116. * Enables the effect on given cameras
  69117. * @param cameras The camera to enable.
  69118. * @hidden
  69119. */
  69120. _enable(cameras: Nullable<Camera[]>): void;
  69121. /**
  69122. * Disables the effect on the given cameras
  69123. * @param cameras The camera to disable.
  69124. * @hidden
  69125. */
  69126. _disable(cameras: Camera): void;
  69127. /**
  69128. * Disables the effect on the given cameras
  69129. * @param cameras The camera to disable.
  69130. * @hidden
  69131. */
  69132. _disable(cameras: Nullable<Camera[]>): void;
  69133. /**
  69134. * Gets a list of the post processes contained in the effect.
  69135. * @param camera The camera to get the post processes on.
  69136. * @returns The list of the post processes in the effect.
  69137. */
  69138. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69139. }
  69140. }
  69141. declare module BABYLON {
  69142. /** @hidden */
  69143. export var extractHighlightsPixelShader: {
  69144. name: string;
  69145. shader: string;
  69146. };
  69147. }
  69148. declare module BABYLON {
  69149. /**
  69150. * 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.
  69151. */
  69152. export class ExtractHighlightsPostProcess extends PostProcess {
  69153. /**
  69154. * The luminance threshold, pixels below this value will be set to black.
  69155. */
  69156. threshold: number;
  69157. /** @hidden */
  69158. _exposure: number;
  69159. /**
  69160. * Post process which has the input texture to be used when performing highlight extraction
  69161. * @hidden
  69162. */
  69163. _inputPostProcess: Nullable<PostProcess>;
  69164. /**
  69165. * Gets a string identifying the name of the class
  69166. * @returns "ExtractHighlightsPostProcess" string
  69167. */
  69168. getClassName(): string;
  69169. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69170. }
  69171. }
  69172. declare module BABYLON {
  69173. /** @hidden */
  69174. export var bloomMergePixelShader: {
  69175. name: string;
  69176. shader: string;
  69177. };
  69178. }
  69179. declare module BABYLON {
  69180. /**
  69181. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69182. */
  69183. export class BloomMergePostProcess extends PostProcess {
  69184. /** Weight of the bloom to be added to the original input. */
  69185. weight: number;
  69186. /**
  69187. * Gets a string identifying the name of the class
  69188. * @returns "BloomMergePostProcess" string
  69189. */
  69190. getClassName(): string;
  69191. /**
  69192. * Creates a new instance of @see BloomMergePostProcess
  69193. * @param name The name of the effect.
  69194. * @param originalFromInput Post process which's input will be used for the merge.
  69195. * @param blurred Blurred highlights post process which's output will be used.
  69196. * @param weight Weight of the bloom to be added to the original input.
  69197. * @param options The required width/height ratio to downsize to before computing the render pass.
  69198. * @param camera The camera to apply the render pass to.
  69199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69200. * @param engine The engine which the post process will be applied. (default: current engine)
  69201. * @param reusable If the post process can be reused on the same frame. (default: false)
  69202. * @param textureType Type of textures used when performing the post process. (default: 0)
  69203. * @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)
  69204. */
  69205. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69206. /** Weight of the bloom to be added to the original input. */
  69207. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69208. }
  69209. }
  69210. declare module BABYLON {
  69211. /**
  69212. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69213. */
  69214. export class BloomEffect extends PostProcessRenderEffect {
  69215. private bloomScale;
  69216. /**
  69217. * @hidden Internal
  69218. */
  69219. _effects: Array<PostProcess>;
  69220. /**
  69221. * @hidden Internal
  69222. */
  69223. _downscale: ExtractHighlightsPostProcess;
  69224. private _blurX;
  69225. private _blurY;
  69226. private _merge;
  69227. /**
  69228. * The luminance threshold to find bright areas of the image to bloom.
  69229. */
  69230. get threshold(): number;
  69231. set threshold(value: number);
  69232. /**
  69233. * The strength of the bloom.
  69234. */
  69235. get weight(): number;
  69236. set weight(value: number);
  69237. /**
  69238. * Specifies the size of the bloom blur kernel, relative to the final output size
  69239. */
  69240. get kernel(): number;
  69241. set kernel(value: number);
  69242. /**
  69243. * Creates a new instance of @see BloomEffect
  69244. * @param scene The scene the effect belongs to.
  69245. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69246. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69247. * @param bloomWeight The the strength of bloom.
  69248. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69249. * @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)
  69250. */
  69251. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69252. /**
  69253. * Disposes each of the internal effects for a given camera.
  69254. * @param camera The camera to dispose the effect on.
  69255. */
  69256. disposeEffects(camera: Camera): void;
  69257. /**
  69258. * @hidden Internal
  69259. */
  69260. _updateEffects(): void;
  69261. /**
  69262. * Internal
  69263. * @returns if all the contained post processes are ready.
  69264. * @hidden
  69265. */
  69266. _isReady(): boolean;
  69267. }
  69268. }
  69269. declare module BABYLON {
  69270. /** @hidden */
  69271. export var chromaticAberrationPixelShader: {
  69272. name: string;
  69273. shader: string;
  69274. };
  69275. }
  69276. declare module BABYLON {
  69277. /**
  69278. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69279. */
  69280. export class ChromaticAberrationPostProcess extends PostProcess {
  69281. /**
  69282. * The amount of seperation of rgb channels (default: 30)
  69283. */
  69284. aberrationAmount: number;
  69285. /**
  69286. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69287. */
  69288. radialIntensity: number;
  69289. /**
  69290. * 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))
  69291. */
  69292. direction: Vector2;
  69293. /**
  69294. * 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))
  69295. */
  69296. centerPosition: Vector2;
  69297. /** The width of the screen to apply the effect on */
  69298. screenWidth: number;
  69299. /** The height of the screen to apply the effect on */
  69300. screenHeight: number;
  69301. /**
  69302. * Gets a string identifying the name of the class
  69303. * @returns "ChromaticAberrationPostProcess" string
  69304. */
  69305. getClassName(): string;
  69306. /**
  69307. * Creates a new instance ChromaticAberrationPostProcess
  69308. * @param name The name of the effect.
  69309. * @param screenWidth The width of the screen to apply the effect on.
  69310. * @param screenHeight The height of the screen to apply the effect on.
  69311. * @param options The required width/height ratio to downsize to before computing the render pass.
  69312. * @param camera The camera to apply the render pass to.
  69313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69314. * @param engine The engine which the post process will be applied. (default: current engine)
  69315. * @param reusable If the post process can be reused on the same frame. (default: false)
  69316. * @param textureType Type of textures used when performing the post process. (default: 0)
  69317. * @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)
  69318. */
  69319. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69320. /** @hidden */
  69321. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69322. }
  69323. }
  69324. declare module BABYLON {
  69325. /** @hidden */
  69326. export var circleOfConfusionPixelShader: {
  69327. name: string;
  69328. shader: string;
  69329. };
  69330. }
  69331. declare module BABYLON {
  69332. /**
  69333. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69334. */
  69335. export class CircleOfConfusionPostProcess extends PostProcess {
  69336. /**
  69337. * 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.
  69338. */
  69339. lensSize: number;
  69340. /**
  69341. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69342. */
  69343. fStop: number;
  69344. /**
  69345. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69346. */
  69347. focusDistance: number;
  69348. /**
  69349. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69350. */
  69351. focalLength: number;
  69352. /**
  69353. * Gets a string identifying the name of the class
  69354. * @returns "CircleOfConfusionPostProcess" string
  69355. */
  69356. getClassName(): string;
  69357. private _depthTexture;
  69358. /**
  69359. * Creates a new instance CircleOfConfusionPostProcess
  69360. * @param name The name of the effect.
  69361. * @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.
  69362. * @param options The required width/height ratio to downsize to before computing the render pass.
  69363. * @param camera The camera to apply the render pass to.
  69364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69365. * @param engine The engine which the post process will be applied. (default: current engine)
  69366. * @param reusable If the post process can be reused on the same frame. (default: false)
  69367. * @param textureType Type of textures used when performing the post process. (default: 0)
  69368. * @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)
  69369. */
  69370. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69371. /**
  69372. * 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.
  69373. */
  69374. set depthTexture(value: RenderTargetTexture);
  69375. }
  69376. }
  69377. declare module BABYLON {
  69378. /** @hidden */
  69379. export var colorCorrectionPixelShader: {
  69380. name: string;
  69381. shader: string;
  69382. };
  69383. }
  69384. declare module BABYLON {
  69385. /**
  69386. *
  69387. * This post-process allows the modification of rendered colors by using
  69388. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69389. *
  69390. * The object needs to be provided an url to a texture containing the color
  69391. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69392. * Use an image editing software to tweak the LUT to match your needs.
  69393. *
  69394. * For an example of a color LUT, see here:
  69395. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69396. * For explanations on color grading, see here:
  69397. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69398. *
  69399. */
  69400. export class ColorCorrectionPostProcess extends PostProcess {
  69401. private _colorTableTexture;
  69402. /**
  69403. * Gets the color table url used to create the LUT texture
  69404. */
  69405. colorTableUrl: string;
  69406. /**
  69407. * Gets a string identifying the name of the class
  69408. * @returns "ColorCorrectionPostProcess" string
  69409. */
  69410. getClassName(): string;
  69411. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69412. /** @hidden */
  69413. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69414. }
  69415. }
  69416. declare module BABYLON {
  69417. /** @hidden */
  69418. export var convolutionPixelShader: {
  69419. name: string;
  69420. shader: string;
  69421. };
  69422. }
  69423. declare module BABYLON {
  69424. /**
  69425. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69426. * input texture to perform effects such as edge detection or sharpening
  69427. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69428. */
  69429. export class ConvolutionPostProcess extends PostProcess {
  69430. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69431. kernel: number[];
  69432. /**
  69433. * Gets a string identifying the name of the class
  69434. * @returns "ConvolutionPostProcess" string
  69435. */
  69436. getClassName(): string;
  69437. /**
  69438. * Creates a new instance ConvolutionPostProcess
  69439. * @param name The name of the effect.
  69440. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69441. * @param options The required width/height ratio to downsize to before computing the render pass.
  69442. * @param camera The camera to apply the render pass to.
  69443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69444. * @param engine The engine which the post process will be applied. (default: current engine)
  69445. * @param reusable If the post process can be reused on the same frame. (default: false)
  69446. * @param textureType Type of textures used when performing the post process. (default: 0)
  69447. */
  69448. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69449. /** @hidden */
  69450. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69451. /**
  69452. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69453. */
  69454. static EdgeDetect0Kernel: number[];
  69455. /**
  69456. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69457. */
  69458. static EdgeDetect1Kernel: number[];
  69459. /**
  69460. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69461. */
  69462. static EdgeDetect2Kernel: number[];
  69463. /**
  69464. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69465. */
  69466. static SharpenKernel: number[];
  69467. /**
  69468. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69469. */
  69470. static EmbossKernel: number[];
  69471. /**
  69472. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69473. */
  69474. static GaussianKernel: number[];
  69475. }
  69476. }
  69477. declare module BABYLON {
  69478. /**
  69479. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69480. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69481. * based on samples that have a large difference in distance than the center pixel.
  69482. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69483. */
  69484. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69485. /**
  69486. * The direction the blur should be applied
  69487. */
  69488. direction: Vector2;
  69489. /**
  69490. * Gets a string identifying the name of the class
  69491. * @returns "DepthOfFieldBlurPostProcess" string
  69492. */
  69493. getClassName(): string;
  69494. /**
  69495. * Creates a new instance CircleOfConfusionPostProcess
  69496. * @param name The name of the effect.
  69497. * @param scene The scene the effect belongs to.
  69498. * @param direction The direction the blur should be applied.
  69499. * @param kernel The size of the kernel used to blur.
  69500. * @param options The required width/height ratio to downsize to before computing the render pass.
  69501. * @param camera The camera to apply the render pass to.
  69502. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69503. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69505. * @param engine The engine which the post process will be applied. (default: current engine)
  69506. * @param reusable If the post process can be reused on the same frame. (default: false)
  69507. * @param textureType Type of textures used when performing the post process. (default: 0)
  69508. * @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)
  69509. */
  69510. 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);
  69511. }
  69512. }
  69513. declare module BABYLON {
  69514. /** @hidden */
  69515. export var depthOfFieldMergePixelShader: {
  69516. name: string;
  69517. shader: string;
  69518. };
  69519. }
  69520. declare module BABYLON {
  69521. /**
  69522. * Options to be set when merging outputs from the default pipeline.
  69523. */
  69524. export class DepthOfFieldMergePostProcessOptions {
  69525. /**
  69526. * The original image to merge on top of
  69527. */
  69528. originalFromInput: PostProcess;
  69529. /**
  69530. * Parameters to perform the merge of the depth of field effect
  69531. */
  69532. depthOfField?: {
  69533. circleOfConfusion: PostProcess;
  69534. blurSteps: Array<PostProcess>;
  69535. };
  69536. /**
  69537. * Parameters to perform the merge of bloom effect
  69538. */
  69539. bloom?: {
  69540. blurred: PostProcess;
  69541. weight: number;
  69542. };
  69543. }
  69544. /**
  69545. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69546. */
  69547. export class DepthOfFieldMergePostProcess extends PostProcess {
  69548. private blurSteps;
  69549. /**
  69550. * Gets a string identifying the name of the class
  69551. * @returns "DepthOfFieldMergePostProcess" string
  69552. */
  69553. getClassName(): string;
  69554. /**
  69555. * Creates a new instance of DepthOfFieldMergePostProcess
  69556. * @param name The name of the effect.
  69557. * @param originalFromInput Post process which's input will be used for the merge.
  69558. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69559. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69560. * @param options The required width/height ratio to downsize to before computing the render pass.
  69561. * @param camera The camera to apply the render pass to.
  69562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69563. * @param engine The engine which the post process will be applied. (default: current engine)
  69564. * @param reusable If the post process can be reused on the same frame. (default: false)
  69565. * @param textureType Type of textures used when performing the post process. (default: 0)
  69566. * @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)
  69567. */
  69568. 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);
  69569. /**
  69570. * Updates the effect with the current post process compile time values and recompiles the shader.
  69571. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69572. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69573. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69574. * @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
  69575. * @param onCompiled Called when the shader has been compiled.
  69576. * @param onError Called if there is an error when compiling a shader.
  69577. */
  69578. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69579. }
  69580. }
  69581. declare module BABYLON {
  69582. /**
  69583. * Specifies the level of max blur that should be applied when using the depth of field effect
  69584. */
  69585. export enum DepthOfFieldEffectBlurLevel {
  69586. /**
  69587. * Subtle blur
  69588. */
  69589. Low = 0,
  69590. /**
  69591. * Medium blur
  69592. */
  69593. Medium = 1,
  69594. /**
  69595. * Large blur
  69596. */
  69597. High = 2
  69598. }
  69599. /**
  69600. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69601. */
  69602. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69603. private _circleOfConfusion;
  69604. /**
  69605. * @hidden Internal, blurs from high to low
  69606. */
  69607. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69608. private _depthOfFieldBlurY;
  69609. private _dofMerge;
  69610. /**
  69611. * @hidden Internal post processes in depth of field effect
  69612. */
  69613. _effects: Array<PostProcess>;
  69614. /**
  69615. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69616. */
  69617. set focalLength(value: number);
  69618. get focalLength(): number;
  69619. /**
  69620. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69621. */
  69622. set fStop(value: number);
  69623. get fStop(): number;
  69624. /**
  69625. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69626. */
  69627. set focusDistance(value: number);
  69628. get focusDistance(): number;
  69629. /**
  69630. * 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.
  69631. */
  69632. set lensSize(value: number);
  69633. get lensSize(): number;
  69634. /**
  69635. * Creates a new instance DepthOfFieldEffect
  69636. * @param scene The scene the effect belongs to.
  69637. * @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.
  69638. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69639. * @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)
  69640. */
  69641. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69642. /**
  69643. * Get the current class name of the current effet
  69644. * @returns "DepthOfFieldEffect"
  69645. */
  69646. getClassName(): string;
  69647. /**
  69648. * 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.
  69649. */
  69650. set depthTexture(value: RenderTargetTexture);
  69651. /**
  69652. * Disposes each of the internal effects for a given camera.
  69653. * @param camera The camera to dispose the effect on.
  69654. */
  69655. disposeEffects(camera: Camera): void;
  69656. /**
  69657. * @hidden Internal
  69658. */
  69659. _updateEffects(): void;
  69660. /**
  69661. * Internal
  69662. * @returns if all the contained post processes are ready.
  69663. * @hidden
  69664. */
  69665. _isReady(): boolean;
  69666. }
  69667. }
  69668. declare module BABYLON {
  69669. /** @hidden */
  69670. export var displayPassPixelShader: {
  69671. name: string;
  69672. shader: string;
  69673. };
  69674. }
  69675. declare module BABYLON {
  69676. /**
  69677. * DisplayPassPostProcess which produces an output the same as it's input
  69678. */
  69679. export class DisplayPassPostProcess extends PostProcess {
  69680. /**
  69681. * Gets a string identifying the name of the class
  69682. * @returns "DisplayPassPostProcess" string
  69683. */
  69684. getClassName(): string;
  69685. /**
  69686. * Creates the DisplayPassPostProcess
  69687. * @param name The name of the effect.
  69688. * @param options The required width/height ratio to downsize to before computing the render pass.
  69689. * @param camera The camera to apply the render pass to.
  69690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69691. * @param engine The engine which the post process will be applied. (default: current engine)
  69692. * @param reusable If the post process can be reused on the same frame. (default: false)
  69693. */
  69694. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69695. /** @hidden */
  69696. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69697. }
  69698. }
  69699. declare module BABYLON {
  69700. /** @hidden */
  69701. export var filterPixelShader: {
  69702. name: string;
  69703. shader: string;
  69704. };
  69705. }
  69706. declare module BABYLON {
  69707. /**
  69708. * Applies a kernel filter to the image
  69709. */
  69710. export class FilterPostProcess extends PostProcess {
  69711. /** The matrix to be applied to the image */
  69712. kernelMatrix: Matrix;
  69713. /**
  69714. * Gets a string identifying the name of the class
  69715. * @returns "FilterPostProcess" string
  69716. */
  69717. getClassName(): string;
  69718. /**
  69719. *
  69720. * @param name The name of the effect.
  69721. * @param kernelMatrix The matrix to be applied to the image
  69722. * @param options The required width/height ratio to downsize to before computing the render pass.
  69723. * @param camera The camera to apply the render pass to.
  69724. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69725. * @param engine The engine which the post process will be applied. (default: current engine)
  69726. * @param reusable If the post process can be reused on the same frame. (default: false)
  69727. */
  69728. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69729. /** @hidden */
  69730. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69731. }
  69732. }
  69733. declare module BABYLON {
  69734. /** @hidden */
  69735. export var fxaaPixelShader: {
  69736. name: string;
  69737. shader: string;
  69738. };
  69739. }
  69740. declare module BABYLON {
  69741. /** @hidden */
  69742. export var fxaaVertexShader: {
  69743. name: string;
  69744. shader: string;
  69745. };
  69746. }
  69747. declare module BABYLON {
  69748. /**
  69749. * Fxaa post process
  69750. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69751. */
  69752. export class FxaaPostProcess extends PostProcess {
  69753. /**
  69754. * Gets a string identifying the name of the class
  69755. * @returns "FxaaPostProcess" string
  69756. */
  69757. getClassName(): string;
  69758. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69759. private _getDefines;
  69760. /** @hidden */
  69761. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69762. }
  69763. }
  69764. declare module BABYLON {
  69765. /** @hidden */
  69766. export var grainPixelShader: {
  69767. name: string;
  69768. shader: string;
  69769. };
  69770. }
  69771. declare module BABYLON {
  69772. /**
  69773. * The GrainPostProcess adds noise to the image at mid luminance levels
  69774. */
  69775. export class GrainPostProcess extends PostProcess {
  69776. /**
  69777. * The intensity of the grain added (default: 30)
  69778. */
  69779. intensity: number;
  69780. /**
  69781. * If the grain should be randomized on every frame
  69782. */
  69783. animated: boolean;
  69784. /**
  69785. * Gets a string identifying the name of the class
  69786. * @returns "GrainPostProcess" string
  69787. */
  69788. getClassName(): string;
  69789. /**
  69790. * Creates a new instance of @see GrainPostProcess
  69791. * @param name The name of the effect.
  69792. * @param options The required width/height ratio to downsize to before computing the render pass.
  69793. * @param camera The camera to apply the render pass to.
  69794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69795. * @param engine The engine which the post process will be applied. (default: current engine)
  69796. * @param reusable If the post process can be reused on the same frame. (default: false)
  69797. * @param textureType Type of textures used when performing the post process. (default: 0)
  69798. * @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)
  69799. */
  69800. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69801. /** @hidden */
  69802. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69803. }
  69804. }
  69805. declare module BABYLON {
  69806. /** @hidden */
  69807. export var highlightsPixelShader: {
  69808. name: string;
  69809. shader: string;
  69810. };
  69811. }
  69812. declare module BABYLON {
  69813. /**
  69814. * Extracts highlights from the image
  69815. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69816. */
  69817. export class HighlightsPostProcess extends PostProcess {
  69818. /**
  69819. * Gets a string identifying the name of the class
  69820. * @returns "HighlightsPostProcess" string
  69821. */
  69822. getClassName(): string;
  69823. /**
  69824. * Extracts highlights from the image
  69825. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69826. * @param name The name of the effect.
  69827. * @param options The required width/height ratio to downsize to before computing the render pass.
  69828. * @param camera The camera to apply the render pass to.
  69829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69830. * @param engine The engine which the post process will be applied. (default: current engine)
  69831. * @param reusable If the post process can be reused on the same frame. (default: false)
  69832. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69833. */
  69834. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69835. }
  69836. }
  69837. declare module BABYLON {
  69838. /** @hidden */
  69839. export var mrtFragmentDeclaration: {
  69840. name: string;
  69841. shader: string;
  69842. };
  69843. }
  69844. declare module BABYLON {
  69845. /** @hidden */
  69846. export var geometryPixelShader: {
  69847. name: string;
  69848. shader: string;
  69849. };
  69850. }
  69851. declare module BABYLON {
  69852. /** @hidden */
  69853. export var geometryVertexShader: {
  69854. name: string;
  69855. shader: string;
  69856. };
  69857. }
  69858. declare module BABYLON {
  69859. /** @hidden */
  69860. interface ISavedTransformationMatrix {
  69861. world: Matrix;
  69862. viewProjection: Matrix;
  69863. }
  69864. /**
  69865. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69866. */
  69867. export class GeometryBufferRenderer {
  69868. /**
  69869. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69870. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69871. */
  69872. static readonly POSITION_TEXTURE_TYPE: number;
  69873. /**
  69874. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69875. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69876. */
  69877. static readonly VELOCITY_TEXTURE_TYPE: number;
  69878. /**
  69879. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69880. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69881. */
  69882. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69883. /**
  69884. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69885. * in order to compute objects velocities when enableVelocity is set to "true"
  69886. * @hidden
  69887. */
  69888. _previousTransformationMatrices: {
  69889. [index: number]: ISavedTransformationMatrix;
  69890. };
  69891. /**
  69892. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69893. * in order to compute objects velocities when enableVelocity is set to "true"
  69894. * @hidden
  69895. */
  69896. _previousBonesTransformationMatrices: {
  69897. [index: number]: Float32Array;
  69898. };
  69899. /**
  69900. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69901. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69902. */
  69903. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69904. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69905. renderTransparentMeshes: boolean;
  69906. private _scene;
  69907. private _resizeObserver;
  69908. private _multiRenderTarget;
  69909. private _ratio;
  69910. private _enablePosition;
  69911. private _enableVelocity;
  69912. private _enableReflectivity;
  69913. private _positionIndex;
  69914. private _velocityIndex;
  69915. private _reflectivityIndex;
  69916. protected _effect: Effect;
  69917. protected _cachedDefines: string;
  69918. /**
  69919. * Set the render list (meshes to be rendered) used in the G buffer.
  69920. */
  69921. set renderList(meshes: Mesh[]);
  69922. /**
  69923. * Gets wether or not G buffer are supported by the running hardware.
  69924. * This requires draw buffer supports
  69925. */
  69926. get isSupported(): boolean;
  69927. /**
  69928. * Returns the index of the given texture type in the G-Buffer textures array
  69929. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69930. * @returns the index of the given texture type in the G-Buffer textures array
  69931. */
  69932. getTextureIndex(textureType: number): number;
  69933. /**
  69934. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69935. */
  69936. get enablePosition(): boolean;
  69937. /**
  69938. * Sets whether or not objects positions are enabled for the G buffer.
  69939. */
  69940. set enablePosition(enable: boolean);
  69941. /**
  69942. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69943. */
  69944. get enableVelocity(): boolean;
  69945. /**
  69946. * Sets wether or not objects velocities are enabled for the G buffer.
  69947. */
  69948. set enableVelocity(enable: boolean);
  69949. /**
  69950. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69951. */
  69952. get enableReflectivity(): boolean;
  69953. /**
  69954. * Sets wether or not objects roughness are enabled for the G buffer.
  69955. */
  69956. set enableReflectivity(enable: boolean);
  69957. /**
  69958. * Gets the scene associated with the buffer.
  69959. */
  69960. get scene(): Scene;
  69961. /**
  69962. * Gets the ratio used by the buffer during its creation.
  69963. * How big is the buffer related to the main canvas.
  69964. */
  69965. get ratio(): number;
  69966. /** @hidden */
  69967. static _SceneComponentInitialization: (scene: Scene) => void;
  69968. /**
  69969. * Creates a new G Buffer for the scene
  69970. * @param scene The scene the buffer belongs to
  69971. * @param ratio How big is the buffer related to the main canvas.
  69972. */
  69973. constructor(scene: Scene, ratio?: number);
  69974. /**
  69975. * Checks wether everything is ready to render a submesh to the G buffer.
  69976. * @param subMesh the submesh to check readiness for
  69977. * @param useInstances is the mesh drawn using instance or not
  69978. * @returns true if ready otherwise false
  69979. */
  69980. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69981. /**
  69982. * Gets the current underlying G Buffer.
  69983. * @returns the buffer
  69984. */
  69985. getGBuffer(): MultiRenderTarget;
  69986. /**
  69987. * Gets the number of samples used to render the buffer (anti aliasing).
  69988. */
  69989. get samples(): number;
  69990. /**
  69991. * Sets the number of samples used to render the buffer (anti aliasing).
  69992. */
  69993. set samples(value: number);
  69994. /**
  69995. * Disposes the renderer and frees up associated resources.
  69996. */
  69997. dispose(): void;
  69998. protected _createRenderTargets(): void;
  69999. private _copyBonesTransformationMatrices;
  70000. }
  70001. }
  70002. declare module BABYLON {
  70003. interface Scene {
  70004. /** @hidden (Backing field) */
  70005. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70006. /**
  70007. * Gets or Sets the current geometry buffer associated to the scene.
  70008. */
  70009. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70010. /**
  70011. * Enables a GeometryBufferRender and associates it with the scene
  70012. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70013. * @returns the GeometryBufferRenderer
  70014. */
  70015. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70016. /**
  70017. * Disables the GeometryBufferRender associated with the scene
  70018. */
  70019. disableGeometryBufferRenderer(): void;
  70020. }
  70021. /**
  70022. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70023. * in several rendering techniques.
  70024. */
  70025. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70026. /**
  70027. * The component name helpful to identify the component in the list of scene components.
  70028. */
  70029. readonly name: string;
  70030. /**
  70031. * The scene the component belongs to.
  70032. */
  70033. scene: Scene;
  70034. /**
  70035. * Creates a new instance of the component for the given scene
  70036. * @param scene Defines the scene to register the component in
  70037. */
  70038. constructor(scene: Scene);
  70039. /**
  70040. * Registers the component in a given scene
  70041. */
  70042. register(): void;
  70043. /**
  70044. * Rebuilds the elements related to this component in case of
  70045. * context lost for instance.
  70046. */
  70047. rebuild(): void;
  70048. /**
  70049. * Disposes the component and the associated ressources
  70050. */
  70051. dispose(): void;
  70052. private _gatherRenderTargets;
  70053. }
  70054. }
  70055. declare module BABYLON {
  70056. /** @hidden */
  70057. export var motionBlurPixelShader: {
  70058. name: string;
  70059. shader: string;
  70060. };
  70061. }
  70062. declare module BABYLON {
  70063. /**
  70064. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70065. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70066. * As an example, all you have to do is to create the post-process:
  70067. * var mb = new BABYLON.MotionBlurPostProcess(
  70068. * 'mb', // The name of the effect.
  70069. * scene, // The scene containing the objects to blur according to their velocity.
  70070. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70071. * camera // The camera to apply the render pass to.
  70072. * );
  70073. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70074. */
  70075. export class MotionBlurPostProcess extends PostProcess {
  70076. /**
  70077. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70078. */
  70079. motionStrength: number;
  70080. /**
  70081. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70082. */
  70083. get motionBlurSamples(): number;
  70084. /**
  70085. * Sets the number of iterations to be used for motion blur quality
  70086. */
  70087. set motionBlurSamples(samples: number);
  70088. private _motionBlurSamples;
  70089. private _geometryBufferRenderer;
  70090. /**
  70091. * Gets a string identifying the name of the class
  70092. * @returns "MotionBlurPostProcess" string
  70093. */
  70094. getClassName(): string;
  70095. /**
  70096. * Creates a new instance MotionBlurPostProcess
  70097. * @param name The name of the effect.
  70098. * @param scene The scene containing the objects to blur according to their velocity.
  70099. * @param options The required width/height ratio to downsize to before computing the render pass.
  70100. * @param camera The camera to apply the render pass to.
  70101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70102. * @param engine The engine which the post process will be applied. (default: current engine)
  70103. * @param reusable If the post process can be reused on the same frame. (default: false)
  70104. * @param textureType Type of textures used when performing the post process. (default: 0)
  70105. * @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)
  70106. */
  70107. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70108. /**
  70109. * Excludes the given skinned mesh from computing bones velocities.
  70110. * 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.
  70111. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70112. */
  70113. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70114. /**
  70115. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70116. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70117. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70118. */
  70119. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70120. /**
  70121. * Disposes the post process.
  70122. * @param camera The camera to dispose the post process on.
  70123. */
  70124. dispose(camera?: Camera): void;
  70125. /** @hidden */
  70126. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70127. }
  70128. }
  70129. declare module BABYLON {
  70130. /** @hidden */
  70131. export var refractionPixelShader: {
  70132. name: string;
  70133. shader: string;
  70134. };
  70135. }
  70136. declare module BABYLON {
  70137. /**
  70138. * Post process which applies a refractin texture
  70139. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70140. */
  70141. export class RefractionPostProcess extends PostProcess {
  70142. private _refTexture;
  70143. private _ownRefractionTexture;
  70144. /** the base color of the refraction (used to taint the rendering) */
  70145. color: Color3;
  70146. /** simulated refraction depth */
  70147. depth: number;
  70148. /** the coefficient of the base color (0 to remove base color tainting) */
  70149. colorLevel: number;
  70150. /** Gets the url used to load the refraction texture */
  70151. refractionTextureUrl: string;
  70152. /**
  70153. * Gets or sets the refraction texture
  70154. * Please note that you are responsible for disposing the texture if you set it manually
  70155. */
  70156. get refractionTexture(): Texture;
  70157. set refractionTexture(value: Texture);
  70158. /**
  70159. * Gets a string identifying the name of the class
  70160. * @returns "RefractionPostProcess" string
  70161. */
  70162. getClassName(): string;
  70163. /**
  70164. * Initializes the RefractionPostProcess
  70165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70166. * @param name The name of the effect.
  70167. * @param refractionTextureUrl Url of the refraction texture to use
  70168. * @param color the base color of the refraction (used to taint the rendering)
  70169. * @param depth simulated refraction depth
  70170. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70171. * @param camera The camera to apply the render pass to.
  70172. * @param options The required width/height ratio to downsize to before computing the render pass.
  70173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70174. * @param engine The engine which the post process will be applied. (default: current engine)
  70175. * @param reusable If the post process can be reused on the same frame. (default: false)
  70176. */
  70177. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70178. /**
  70179. * Disposes of the post process
  70180. * @param camera Camera to dispose post process on
  70181. */
  70182. dispose(camera: Camera): void;
  70183. /** @hidden */
  70184. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70185. }
  70186. }
  70187. declare module BABYLON {
  70188. /** @hidden */
  70189. export var sharpenPixelShader: {
  70190. name: string;
  70191. shader: string;
  70192. };
  70193. }
  70194. declare module BABYLON {
  70195. /**
  70196. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70197. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70198. */
  70199. export class SharpenPostProcess extends PostProcess {
  70200. /**
  70201. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70202. */
  70203. colorAmount: number;
  70204. /**
  70205. * How much sharpness should be applied (default: 0.3)
  70206. */
  70207. edgeAmount: number;
  70208. /**
  70209. * Gets a string identifying the name of the class
  70210. * @returns "SharpenPostProcess" string
  70211. */
  70212. getClassName(): string;
  70213. /**
  70214. * Creates a new instance ConvolutionPostProcess
  70215. * @param name The name of the effect.
  70216. * @param options The required width/height ratio to downsize to before computing the render pass.
  70217. * @param camera The camera to apply the render pass to.
  70218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70219. * @param engine The engine which the post process will be applied. (default: current engine)
  70220. * @param reusable If the post process can be reused on the same frame. (default: false)
  70221. * @param textureType Type of textures used when performing the post process. (default: 0)
  70222. * @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)
  70223. */
  70224. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70225. /** @hidden */
  70226. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70227. }
  70228. }
  70229. declare module BABYLON {
  70230. /**
  70231. * PostProcessRenderPipeline
  70232. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70233. */
  70234. export class PostProcessRenderPipeline {
  70235. private engine;
  70236. private _renderEffects;
  70237. private _renderEffectsForIsolatedPass;
  70238. /**
  70239. * List of inspectable custom properties (used by the Inspector)
  70240. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70241. */
  70242. inspectableCustomProperties: IInspectable[];
  70243. /**
  70244. * @hidden
  70245. */
  70246. protected _cameras: Camera[];
  70247. /** @hidden */
  70248. _name: string;
  70249. /**
  70250. * Gets pipeline name
  70251. */
  70252. get name(): string;
  70253. /** Gets the list of attached cameras */
  70254. get cameras(): Camera[];
  70255. /**
  70256. * Initializes a PostProcessRenderPipeline
  70257. * @param engine engine to add the pipeline to
  70258. * @param name name of the pipeline
  70259. */
  70260. constructor(engine: Engine, name: string);
  70261. /**
  70262. * Gets the class name
  70263. * @returns "PostProcessRenderPipeline"
  70264. */
  70265. getClassName(): string;
  70266. /**
  70267. * If all the render effects in the pipeline are supported
  70268. */
  70269. get isSupported(): boolean;
  70270. /**
  70271. * Adds an effect to the pipeline
  70272. * @param renderEffect the effect to add
  70273. */
  70274. addEffect(renderEffect: PostProcessRenderEffect): void;
  70275. /** @hidden */
  70276. _rebuild(): void;
  70277. /** @hidden */
  70278. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70279. /** @hidden */
  70280. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70281. /** @hidden */
  70282. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70283. /** @hidden */
  70284. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70285. /** @hidden */
  70286. _attachCameras(cameras: Camera, unique: boolean): void;
  70287. /** @hidden */
  70288. _attachCameras(cameras: Camera[], unique: boolean): void;
  70289. /** @hidden */
  70290. _detachCameras(cameras: Camera): void;
  70291. /** @hidden */
  70292. _detachCameras(cameras: Nullable<Camera[]>): void;
  70293. /** @hidden */
  70294. _update(): void;
  70295. /** @hidden */
  70296. _reset(): void;
  70297. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70298. /**
  70299. * Sets the required values to the prepass renderer.
  70300. * @param prePassRenderer defines the prepass renderer to setup.
  70301. * @returns true if the pre pass is needed.
  70302. */
  70303. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70304. /**
  70305. * Disposes of the pipeline
  70306. */
  70307. dispose(): void;
  70308. }
  70309. }
  70310. declare module BABYLON {
  70311. /**
  70312. * PostProcessRenderPipelineManager class
  70313. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70314. */
  70315. export class PostProcessRenderPipelineManager {
  70316. private _renderPipelines;
  70317. /**
  70318. * Initializes a PostProcessRenderPipelineManager
  70319. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70320. */
  70321. constructor();
  70322. /**
  70323. * Gets the list of supported render pipelines
  70324. */
  70325. get supportedPipelines(): PostProcessRenderPipeline[];
  70326. /**
  70327. * Adds a pipeline to the manager
  70328. * @param renderPipeline The pipeline to add
  70329. */
  70330. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70331. /**
  70332. * Attaches a camera to the pipeline
  70333. * @param renderPipelineName The name of the pipeline to attach to
  70334. * @param cameras the camera to attach
  70335. * @param unique if the camera can be attached multiple times to the pipeline
  70336. */
  70337. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70338. /**
  70339. * Detaches a camera from the pipeline
  70340. * @param renderPipelineName The name of the pipeline to detach from
  70341. * @param cameras the camera to detach
  70342. */
  70343. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70344. /**
  70345. * Enables an effect by name on a pipeline
  70346. * @param renderPipelineName the name of the pipeline to enable the effect in
  70347. * @param renderEffectName the name of the effect to enable
  70348. * @param cameras the cameras that the effect should be enabled on
  70349. */
  70350. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70351. /**
  70352. * Disables an effect by name on a pipeline
  70353. * @param renderPipelineName the name of the pipeline to disable the effect in
  70354. * @param renderEffectName the name of the effect to disable
  70355. * @param cameras the cameras that the effect should be disabled on
  70356. */
  70357. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70358. /**
  70359. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70360. */
  70361. update(): void;
  70362. /** @hidden */
  70363. _rebuild(): void;
  70364. /**
  70365. * Disposes of the manager and pipelines
  70366. */
  70367. dispose(): void;
  70368. }
  70369. }
  70370. declare module BABYLON {
  70371. interface Scene {
  70372. /** @hidden (Backing field) */
  70373. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70374. /**
  70375. * Gets the postprocess render pipeline manager
  70376. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70377. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70378. */
  70379. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70380. }
  70381. /**
  70382. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70383. */
  70384. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70385. /**
  70386. * The component name helpfull to identify the component in the list of scene components.
  70387. */
  70388. readonly name: string;
  70389. /**
  70390. * The scene the component belongs to.
  70391. */
  70392. scene: Scene;
  70393. /**
  70394. * Creates a new instance of the component for the given scene
  70395. * @param scene Defines the scene to register the component in
  70396. */
  70397. constructor(scene: Scene);
  70398. /**
  70399. * Registers the component in a given scene
  70400. */
  70401. register(): void;
  70402. /**
  70403. * Rebuilds the elements related to this component in case of
  70404. * context lost for instance.
  70405. */
  70406. rebuild(): void;
  70407. /**
  70408. * Disposes the component and the associated ressources
  70409. */
  70410. dispose(): void;
  70411. private _gatherRenderTargets;
  70412. }
  70413. }
  70414. declare module BABYLON {
  70415. /**
  70416. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70417. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70418. */
  70419. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70420. private _scene;
  70421. private _camerasToBeAttached;
  70422. /**
  70423. * ID of the sharpen post process,
  70424. */
  70425. private readonly SharpenPostProcessId;
  70426. /**
  70427. * @ignore
  70428. * ID of the image processing post process;
  70429. */
  70430. readonly ImageProcessingPostProcessId: string;
  70431. /**
  70432. * @ignore
  70433. * ID of the Fast Approximate Anti-Aliasing post process;
  70434. */
  70435. readonly FxaaPostProcessId: string;
  70436. /**
  70437. * ID of the chromatic aberration post process,
  70438. */
  70439. private readonly ChromaticAberrationPostProcessId;
  70440. /**
  70441. * ID of the grain post process
  70442. */
  70443. private readonly GrainPostProcessId;
  70444. /**
  70445. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70446. */
  70447. sharpen: SharpenPostProcess;
  70448. private _sharpenEffect;
  70449. private bloom;
  70450. /**
  70451. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70452. */
  70453. depthOfField: DepthOfFieldEffect;
  70454. /**
  70455. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70456. */
  70457. fxaa: FxaaPostProcess;
  70458. /**
  70459. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70460. */
  70461. imageProcessing: ImageProcessingPostProcess;
  70462. /**
  70463. * Chromatic aberration post process which will shift rgb colors in the image
  70464. */
  70465. chromaticAberration: ChromaticAberrationPostProcess;
  70466. private _chromaticAberrationEffect;
  70467. /**
  70468. * Grain post process which add noise to the image
  70469. */
  70470. grain: GrainPostProcess;
  70471. private _grainEffect;
  70472. /**
  70473. * Glow post process which adds a glow to emissive areas of the image
  70474. */
  70475. private _glowLayer;
  70476. /**
  70477. * Animations which can be used to tweak settings over a period of time
  70478. */
  70479. animations: Animation[];
  70480. private _imageProcessingConfigurationObserver;
  70481. private _sharpenEnabled;
  70482. private _bloomEnabled;
  70483. private _depthOfFieldEnabled;
  70484. private _depthOfFieldBlurLevel;
  70485. private _fxaaEnabled;
  70486. private _imageProcessingEnabled;
  70487. private _defaultPipelineTextureType;
  70488. private _bloomScale;
  70489. private _chromaticAberrationEnabled;
  70490. private _grainEnabled;
  70491. private _buildAllowed;
  70492. /**
  70493. * Gets active scene
  70494. */
  70495. get scene(): Scene;
  70496. /**
  70497. * Enable or disable the sharpen process from the pipeline
  70498. */
  70499. set sharpenEnabled(enabled: boolean);
  70500. get sharpenEnabled(): boolean;
  70501. private _resizeObserver;
  70502. private _hardwareScaleLevel;
  70503. private _bloomKernel;
  70504. /**
  70505. * Specifies the size of the bloom blur kernel, relative to the final output size
  70506. */
  70507. get bloomKernel(): number;
  70508. set bloomKernel(value: number);
  70509. /**
  70510. * Specifies the weight of the bloom in the final rendering
  70511. */
  70512. private _bloomWeight;
  70513. /**
  70514. * Specifies the luma threshold for the area that will be blurred by the bloom
  70515. */
  70516. private _bloomThreshold;
  70517. private _hdr;
  70518. /**
  70519. * The strength of the bloom.
  70520. */
  70521. set bloomWeight(value: number);
  70522. get bloomWeight(): number;
  70523. /**
  70524. * The strength of the bloom.
  70525. */
  70526. set bloomThreshold(value: number);
  70527. get bloomThreshold(): number;
  70528. /**
  70529. * The scale of the bloom, lower value will provide better performance.
  70530. */
  70531. set bloomScale(value: number);
  70532. get bloomScale(): number;
  70533. /**
  70534. * Enable or disable the bloom from the pipeline
  70535. */
  70536. set bloomEnabled(enabled: boolean);
  70537. get bloomEnabled(): boolean;
  70538. private _rebuildBloom;
  70539. /**
  70540. * If the depth of field is enabled.
  70541. */
  70542. get depthOfFieldEnabled(): boolean;
  70543. set depthOfFieldEnabled(enabled: boolean);
  70544. /**
  70545. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70546. */
  70547. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70548. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70549. /**
  70550. * If the anti aliasing is enabled.
  70551. */
  70552. set fxaaEnabled(enabled: boolean);
  70553. get fxaaEnabled(): boolean;
  70554. private _samples;
  70555. /**
  70556. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70557. */
  70558. set samples(sampleCount: number);
  70559. get samples(): number;
  70560. /**
  70561. * If image processing is enabled.
  70562. */
  70563. set imageProcessingEnabled(enabled: boolean);
  70564. get imageProcessingEnabled(): boolean;
  70565. /**
  70566. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70567. */
  70568. set glowLayerEnabled(enabled: boolean);
  70569. get glowLayerEnabled(): boolean;
  70570. /**
  70571. * Gets the glow layer (or null if not defined)
  70572. */
  70573. get glowLayer(): Nullable<GlowLayer>;
  70574. /**
  70575. * Enable or disable the chromaticAberration process from the pipeline
  70576. */
  70577. set chromaticAberrationEnabled(enabled: boolean);
  70578. get chromaticAberrationEnabled(): boolean;
  70579. /**
  70580. * Enable or disable the grain process from the pipeline
  70581. */
  70582. set grainEnabled(enabled: boolean);
  70583. get grainEnabled(): boolean;
  70584. /**
  70585. * @constructor
  70586. * @param name - The rendering pipeline name (default: "")
  70587. * @param hdr - If high dynamic range textures should be used (default: true)
  70588. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70589. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70590. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70591. */
  70592. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70593. /**
  70594. * Get the class name
  70595. * @returns "DefaultRenderingPipeline"
  70596. */
  70597. getClassName(): string;
  70598. /**
  70599. * Force the compilation of the entire pipeline.
  70600. */
  70601. prepare(): void;
  70602. private _hasCleared;
  70603. private _prevPostProcess;
  70604. private _prevPrevPostProcess;
  70605. private _setAutoClearAndTextureSharing;
  70606. private _depthOfFieldSceneObserver;
  70607. private _buildPipeline;
  70608. private _disposePostProcesses;
  70609. /**
  70610. * Adds a camera to the pipeline
  70611. * @param camera the camera to be added
  70612. */
  70613. addCamera(camera: Camera): void;
  70614. /**
  70615. * Removes a camera from the pipeline
  70616. * @param camera the camera to remove
  70617. */
  70618. removeCamera(camera: Camera): void;
  70619. /**
  70620. * Dispose of the pipeline and stop all post processes
  70621. */
  70622. dispose(): void;
  70623. /**
  70624. * Serialize the rendering pipeline (Used when exporting)
  70625. * @returns the serialized object
  70626. */
  70627. serialize(): any;
  70628. /**
  70629. * Parse the serialized pipeline
  70630. * @param source Source pipeline.
  70631. * @param scene The scene to load the pipeline to.
  70632. * @param rootUrl The URL of the serialized pipeline.
  70633. * @returns An instantiated pipeline from the serialized object.
  70634. */
  70635. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70636. }
  70637. }
  70638. declare module BABYLON {
  70639. /** @hidden */
  70640. export var lensHighlightsPixelShader: {
  70641. name: string;
  70642. shader: string;
  70643. };
  70644. }
  70645. declare module BABYLON {
  70646. /** @hidden */
  70647. export var depthOfFieldPixelShader: {
  70648. name: string;
  70649. shader: string;
  70650. };
  70651. }
  70652. declare module BABYLON {
  70653. /**
  70654. * BABYLON.JS Chromatic Aberration GLSL Shader
  70655. * Author: Olivier Guyot
  70656. * Separates very slightly R, G and B colors on the edges of the screen
  70657. * Inspired by Francois Tarlier & Martins Upitis
  70658. */
  70659. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70660. /**
  70661. * @ignore
  70662. * The chromatic aberration PostProcess id in the pipeline
  70663. */
  70664. LensChromaticAberrationEffect: string;
  70665. /**
  70666. * @ignore
  70667. * The highlights enhancing PostProcess id in the pipeline
  70668. */
  70669. HighlightsEnhancingEffect: string;
  70670. /**
  70671. * @ignore
  70672. * The depth-of-field PostProcess id in the pipeline
  70673. */
  70674. LensDepthOfFieldEffect: string;
  70675. private _scene;
  70676. private _depthTexture;
  70677. private _grainTexture;
  70678. private _chromaticAberrationPostProcess;
  70679. private _highlightsPostProcess;
  70680. private _depthOfFieldPostProcess;
  70681. private _edgeBlur;
  70682. private _grainAmount;
  70683. private _chromaticAberration;
  70684. private _distortion;
  70685. private _highlightsGain;
  70686. private _highlightsThreshold;
  70687. private _dofDistance;
  70688. private _dofAperture;
  70689. private _dofDarken;
  70690. private _dofPentagon;
  70691. private _blurNoise;
  70692. /**
  70693. * @constructor
  70694. *
  70695. * Effect parameters are as follow:
  70696. * {
  70697. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70698. * edge_blur: number; // from 0 to x (1 for realism)
  70699. * distortion: number; // from 0 to x (1 for realism)
  70700. * grain_amount: number; // from 0 to 1
  70701. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70702. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70703. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70704. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70705. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70706. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70707. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70708. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70709. * }
  70710. * Note: if an effect parameter is unset, effect is disabled
  70711. *
  70712. * @param name The rendering pipeline name
  70713. * @param parameters - An object containing all parameters (see above)
  70714. * @param scene The scene linked to this pipeline
  70715. * @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)
  70716. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70717. */
  70718. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70719. /**
  70720. * Get the class name
  70721. * @returns "LensRenderingPipeline"
  70722. */
  70723. getClassName(): string;
  70724. /**
  70725. * Gets associated scene
  70726. */
  70727. get scene(): Scene;
  70728. /**
  70729. * Gets or sets the edge blur
  70730. */
  70731. get edgeBlur(): number;
  70732. set edgeBlur(value: number);
  70733. /**
  70734. * Gets or sets the grain amount
  70735. */
  70736. get grainAmount(): number;
  70737. set grainAmount(value: number);
  70738. /**
  70739. * Gets or sets the chromatic aberration amount
  70740. */
  70741. get chromaticAberration(): number;
  70742. set chromaticAberration(value: number);
  70743. /**
  70744. * Gets or sets the depth of field aperture
  70745. */
  70746. get dofAperture(): number;
  70747. set dofAperture(value: number);
  70748. /**
  70749. * Gets or sets the edge distortion
  70750. */
  70751. get edgeDistortion(): number;
  70752. set edgeDistortion(value: number);
  70753. /**
  70754. * Gets or sets the depth of field distortion
  70755. */
  70756. get dofDistortion(): number;
  70757. set dofDistortion(value: number);
  70758. /**
  70759. * Gets or sets the darken out of focus amount
  70760. */
  70761. get darkenOutOfFocus(): number;
  70762. set darkenOutOfFocus(value: number);
  70763. /**
  70764. * Gets or sets a boolean indicating if blur noise is enabled
  70765. */
  70766. get blurNoise(): boolean;
  70767. set blurNoise(value: boolean);
  70768. /**
  70769. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70770. */
  70771. get pentagonBokeh(): boolean;
  70772. set pentagonBokeh(value: boolean);
  70773. /**
  70774. * Gets or sets the highlight grain amount
  70775. */
  70776. get highlightsGain(): number;
  70777. set highlightsGain(value: number);
  70778. /**
  70779. * Gets or sets the highlight threshold
  70780. */
  70781. get highlightsThreshold(): number;
  70782. set highlightsThreshold(value: number);
  70783. /**
  70784. * Sets the amount of blur at the edges
  70785. * @param amount blur amount
  70786. */
  70787. setEdgeBlur(amount: number): void;
  70788. /**
  70789. * Sets edge blur to 0
  70790. */
  70791. disableEdgeBlur(): void;
  70792. /**
  70793. * Sets the amout of grain
  70794. * @param amount Amount of grain
  70795. */
  70796. setGrainAmount(amount: number): void;
  70797. /**
  70798. * Set grain amount to 0
  70799. */
  70800. disableGrain(): void;
  70801. /**
  70802. * Sets the chromatic aberration amount
  70803. * @param amount amount of chromatic aberration
  70804. */
  70805. setChromaticAberration(amount: number): void;
  70806. /**
  70807. * Sets chromatic aberration amount to 0
  70808. */
  70809. disableChromaticAberration(): void;
  70810. /**
  70811. * Sets the EdgeDistortion amount
  70812. * @param amount amount of EdgeDistortion
  70813. */
  70814. setEdgeDistortion(amount: number): void;
  70815. /**
  70816. * Sets edge distortion to 0
  70817. */
  70818. disableEdgeDistortion(): void;
  70819. /**
  70820. * Sets the FocusDistance amount
  70821. * @param amount amount of FocusDistance
  70822. */
  70823. setFocusDistance(amount: number): void;
  70824. /**
  70825. * Disables depth of field
  70826. */
  70827. disableDepthOfField(): void;
  70828. /**
  70829. * Sets the Aperture amount
  70830. * @param amount amount of Aperture
  70831. */
  70832. setAperture(amount: number): void;
  70833. /**
  70834. * Sets the DarkenOutOfFocus amount
  70835. * @param amount amount of DarkenOutOfFocus
  70836. */
  70837. setDarkenOutOfFocus(amount: number): void;
  70838. private _pentagonBokehIsEnabled;
  70839. /**
  70840. * Creates a pentagon bokeh effect
  70841. */
  70842. enablePentagonBokeh(): void;
  70843. /**
  70844. * Disables the pentagon bokeh effect
  70845. */
  70846. disablePentagonBokeh(): void;
  70847. /**
  70848. * Enables noise blur
  70849. */
  70850. enableNoiseBlur(): void;
  70851. /**
  70852. * Disables noise blur
  70853. */
  70854. disableNoiseBlur(): void;
  70855. /**
  70856. * Sets the HighlightsGain amount
  70857. * @param amount amount of HighlightsGain
  70858. */
  70859. setHighlightsGain(amount: number): void;
  70860. /**
  70861. * Sets the HighlightsThreshold amount
  70862. * @param amount amount of HighlightsThreshold
  70863. */
  70864. setHighlightsThreshold(amount: number): void;
  70865. /**
  70866. * Disables highlights
  70867. */
  70868. disableHighlights(): void;
  70869. /**
  70870. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70871. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70872. */
  70873. dispose(disableDepthRender?: boolean): void;
  70874. private _createChromaticAberrationPostProcess;
  70875. private _createHighlightsPostProcess;
  70876. private _createDepthOfFieldPostProcess;
  70877. private _createGrainTexture;
  70878. }
  70879. }
  70880. declare module BABYLON {
  70881. /** @hidden */
  70882. export var ssao2PixelShader: {
  70883. name: string;
  70884. shader: string;
  70885. };
  70886. }
  70887. declare module BABYLON {
  70888. /** @hidden */
  70889. export var ssaoCombinePixelShader: {
  70890. name: string;
  70891. shader: string;
  70892. };
  70893. }
  70894. declare module BABYLON {
  70895. /**
  70896. * Render pipeline to produce ssao effect
  70897. */
  70898. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70899. /**
  70900. * @ignore
  70901. * The PassPostProcess id in the pipeline that contains the original scene color
  70902. */
  70903. SSAOOriginalSceneColorEffect: string;
  70904. /**
  70905. * @ignore
  70906. * The SSAO PostProcess id in the pipeline
  70907. */
  70908. SSAORenderEffect: string;
  70909. /**
  70910. * @ignore
  70911. * The horizontal blur PostProcess id in the pipeline
  70912. */
  70913. SSAOBlurHRenderEffect: string;
  70914. /**
  70915. * @ignore
  70916. * The vertical blur PostProcess id in the pipeline
  70917. */
  70918. SSAOBlurVRenderEffect: string;
  70919. /**
  70920. * @ignore
  70921. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70922. */
  70923. SSAOCombineRenderEffect: string;
  70924. /**
  70925. * The output strength of the SSAO post-process. Default value is 1.0.
  70926. */
  70927. totalStrength: number;
  70928. /**
  70929. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70930. */
  70931. maxZ: number;
  70932. /**
  70933. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70934. */
  70935. minZAspect: number;
  70936. private _samples;
  70937. /**
  70938. * Number of samples used for the SSAO calculations. Default value is 8
  70939. */
  70940. set samples(n: number);
  70941. get samples(): number;
  70942. private _textureSamples;
  70943. /**
  70944. * Number of samples to use for antialiasing
  70945. */
  70946. set textureSamples(n: number);
  70947. get textureSamples(): number;
  70948. /**
  70949. * Force rendering the geometry through geometry buffer
  70950. */
  70951. private _forceGeometryBuffer;
  70952. /**
  70953. * Ratio object used for SSAO ratio and blur ratio
  70954. */
  70955. private _ratio;
  70956. /**
  70957. * Dynamically generated sphere sampler.
  70958. */
  70959. private _sampleSphere;
  70960. /**
  70961. * Blur filter offsets
  70962. */
  70963. private _samplerOffsets;
  70964. private _expensiveBlur;
  70965. /**
  70966. * If bilateral blur should be used
  70967. */
  70968. set expensiveBlur(b: boolean);
  70969. get expensiveBlur(): boolean;
  70970. /**
  70971. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70972. */
  70973. radius: number;
  70974. /**
  70975. * The base color of the SSAO post-process
  70976. * The final result is "base + ssao" between [0, 1]
  70977. */
  70978. base: number;
  70979. /**
  70980. * Support test.
  70981. */
  70982. static get IsSupported(): boolean;
  70983. private _scene;
  70984. private _randomTexture;
  70985. private _originalColorPostProcess;
  70986. private _ssaoPostProcess;
  70987. private _blurHPostProcess;
  70988. private _blurVPostProcess;
  70989. private _ssaoCombinePostProcess;
  70990. private _prePassRenderer;
  70991. /**
  70992. * Gets active scene
  70993. */
  70994. get scene(): Scene;
  70995. /**
  70996. * @constructor
  70997. * @param name The rendering pipeline name
  70998. * @param scene The scene linked to this pipeline
  70999. * @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 }
  71000. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71001. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71002. */
  71003. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71004. /**
  71005. * Get the class name
  71006. * @returns "SSAO2RenderingPipeline"
  71007. */
  71008. getClassName(): string;
  71009. /**
  71010. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71011. */
  71012. dispose(disableGeometryBufferRenderer?: boolean): void;
  71013. private _createBlurPostProcess;
  71014. /** @hidden */
  71015. _rebuild(): void;
  71016. private _bits;
  71017. private _radicalInverse_VdC;
  71018. private _hammersley;
  71019. private _hemisphereSample_uniform;
  71020. private _generateHemisphere;
  71021. private _getDefinesForSSAO;
  71022. private _createSSAOPostProcess;
  71023. private _createSSAOCombinePostProcess;
  71024. private _createRandomTexture;
  71025. /**
  71026. * Serialize the rendering pipeline (Used when exporting)
  71027. * @returns the serialized object
  71028. */
  71029. serialize(): any;
  71030. /**
  71031. * Parse the serialized pipeline
  71032. * @param source Source pipeline.
  71033. * @param scene The scene to load the pipeline to.
  71034. * @param rootUrl The URL of the serialized pipeline.
  71035. * @returns An instantiated pipeline from the serialized object.
  71036. */
  71037. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71038. /**
  71039. * Sets the required values to the prepass renderer.
  71040. * @param prePassRenderer defines the prepass renderer to setup
  71041. * @returns true if the pre pass is needed.
  71042. */
  71043. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71044. }
  71045. }
  71046. declare module BABYLON {
  71047. /** @hidden */
  71048. export var ssaoPixelShader: {
  71049. name: string;
  71050. shader: string;
  71051. };
  71052. }
  71053. declare module BABYLON {
  71054. /**
  71055. * Render pipeline to produce ssao effect
  71056. */
  71057. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71058. /**
  71059. * @ignore
  71060. * The PassPostProcess id in the pipeline that contains the original scene color
  71061. */
  71062. SSAOOriginalSceneColorEffect: string;
  71063. /**
  71064. * @ignore
  71065. * The SSAO PostProcess id in the pipeline
  71066. */
  71067. SSAORenderEffect: string;
  71068. /**
  71069. * @ignore
  71070. * The horizontal blur PostProcess id in the pipeline
  71071. */
  71072. SSAOBlurHRenderEffect: string;
  71073. /**
  71074. * @ignore
  71075. * The vertical blur PostProcess id in the pipeline
  71076. */
  71077. SSAOBlurVRenderEffect: string;
  71078. /**
  71079. * @ignore
  71080. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71081. */
  71082. SSAOCombineRenderEffect: string;
  71083. /**
  71084. * The output strength of the SSAO post-process. Default value is 1.0.
  71085. */
  71086. totalStrength: number;
  71087. /**
  71088. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71089. */
  71090. radius: number;
  71091. /**
  71092. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71093. * Must not be equal to fallOff and superior to fallOff.
  71094. * Default value is 0.0075
  71095. */
  71096. area: number;
  71097. /**
  71098. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71099. * Must not be equal to area and inferior to area.
  71100. * Default value is 0.000001
  71101. */
  71102. fallOff: number;
  71103. /**
  71104. * The base color of the SSAO post-process
  71105. * The final result is "base + ssao" between [0, 1]
  71106. */
  71107. base: number;
  71108. private _scene;
  71109. private _depthTexture;
  71110. private _randomTexture;
  71111. private _originalColorPostProcess;
  71112. private _ssaoPostProcess;
  71113. private _blurHPostProcess;
  71114. private _blurVPostProcess;
  71115. private _ssaoCombinePostProcess;
  71116. private _firstUpdate;
  71117. /**
  71118. * Gets active scene
  71119. */
  71120. get scene(): Scene;
  71121. /**
  71122. * @constructor
  71123. * @param name - The rendering pipeline name
  71124. * @param scene - The scene linked to this pipeline
  71125. * @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 }
  71126. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71127. */
  71128. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71129. /**
  71130. * Get the class name
  71131. * @returns "SSAORenderingPipeline"
  71132. */
  71133. getClassName(): string;
  71134. /**
  71135. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71136. */
  71137. dispose(disableDepthRender?: boolean): void;
  71138. private _createBlurPostProcess;
  71139. /** @hidden */
  71140. _rebuild(): void;
  71141. private _createSSAOPostProcess;
  71142. private _createSSAOCombinePostProcess;
  71143. private _createRandomTexture;
  71144. }
  71145. }
  71146. declare module BABYLON {
  71147. /** @hidden */
  71148. export var screenSpaceReflectionPixelShader: {
  71149. name: string;
  71150. shader: string;
  71151. };
  71152. }
  71153. declare module BABYLON {
  71154. /**
  71155. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71156. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71157. */
  71158. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71159. /**
  71160. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71161. */
  71162. threshold: number;
  71163. /**
  71164. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71165. */
  71166. strength: number;
  71167. /**
  71168. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71169. */
  71170. reflectionSpecularFalloffExponent: number;
  71171. /**
  71172. * 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]
  71173. */
  71174. step: number;
  71175. /**
  71176. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71177. */
  71178. roughnessFactor: number;
  71179. private _geometryBufferRenderer;
  71180. private _enableSmoothReflections;
  71181. private _reflectionSamples;
  71182. private _smoothSteps;
  71183. /**
  71184. * Gets a string identifying the name of the class
  71185. * @returns "ScreenSpaceReflectionPostProcess" string
  71186. */
  71187. getClassName(): string;
  71188. /**
  71189. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71190. * @param name The name of the effect.
  71191. * @param scene The scene containing the objects to calculate reflections.
  71192. * @param options The required width/height ratio to downsize to before computing the render pass.
  71193. * @param camera The camera to apply the render pass to.
  71194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71195. * @param engine The engine which the post process will be applied. (default: current engine)
  71196. * @param reusable If the post process can be reused on the same frame. (default: false)
  71197. * @param textureType Type of textures used when performing the post process. (default: 0)
  71198. * @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)
  71199. */
  71200. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71201. /**
  71202. * Gets wether or not smoothing reflections is enabled.
  71203. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71204. */
  71205. get enableSmoothReflections(): boolean;
  71206. /**
  71207. * Sets wether or not smoothing reflections is enabled.
  71208. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71209. */
  71210. set enableSmoothReflections(enabled: boolean);
  71211. /**
  71212. * Gets the number of samples taken while computing reflections. More samples count is high,
  71213. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71214. */
  71215. get reflectionSamples(): number;
  71216. /**
  71217. * Sets the number of samples taken while computing reflections. More samples count is high,
  71218. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71219. */
  71220. set reflectionSamples(samples: number);
  71221. /**
  71222. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71223. * more the post-process will require GPU power and can generate a drop in FPS.
  71224. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71225. */
  71226. get smoothSteps(): number;
  71227. set smoothSteps(steps: number);
  71228. private _updateEffectDefines;
  71229. /** @hidden */
  71230. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71231. }
  71232. }
  71233. declare module BABYLON {
  71234. /** @hidden */
  71235. export var standardPixelShader: {
  71236. name: string;
  71237. shader: string;
  71238. };
  71239. }
  71240. declare module BABYLON {
  71241. /**
  71242. * Standard rendering pipeline
  71243. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71244. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71245. */
  71246. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71247. /**
  71248. * Public members
  71249. */
  71250. /**
  71251. * Post-process which contains the original scene color before the pipeline applies all the effects
  71252. */
  71253. originalPostProcess: Nullable<PostProcess>;
  71254. /**
  71255. * Post-process used to down scale an image x4
  71256. */
  71257. downSampleX4PostProcess: Nullable<PostProcess>;
  71258. /**
  71259. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71260. */
  71261. brightPassPostProcess: Nullable<PostProcess>;
  71262. /**
  71263. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71264. */
  71265. blurHPostProcesses: PostProcess[];
  71266. /**
  71267. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71268. */
  71269. blurVPostProcesses: PostProcess[];
  71270. /**
  71271. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71272. */
  71273. textureAdderPostProcess: Nullable<PostProcess>;
  71274. /**
  71275. * Post-process used to create volumetric lighting effect
  71276. */
  71277. volumetricLightPostProcess: Nullable<PostProcess>;
  71278. /**
  71279. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71280. */
  71281. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71282. /**
  71283. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71284. */
  71285. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71286. /**
  71287. * Post-process used to merge the volumetric light effect and the real scene color
  71288. */
  71289. volumetricLightMergePostProces: Nullable<PostProcess>;
  71290. /**
  71291. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71292. */
  71293. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71294. /**
  71295. * Base post-process used to calculate the average luminance of the final image for HDR
  71296. */
  71297. luminancePostProcess: Nullable<PostProcess>;
  71298. /**
  71299. * Post-processes used to create down sample post-processes in order to get
  71300. * the average luminance of the final image for HDR
  71301. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71302. */
  71303. luminanceDownSamplePostProcesses: PostProcess[];
  71304. /**
  71305. * Post-process used to create a HDR effect (light adaptation)
  71306. */
  71307. hdrPostProcess: Nullable<PostProcess>;
  71308. /**
  71309. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71310. */
  71311. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71312. /**
  71313. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71314. */
  71315. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71316. /**
  71317. * Post-process used to merge the final HDR post-process and the real scene color
  71318. */
  71319. hdrFinalPostProcess: Nullable<PostProcess>;
  71320. /**
  71321. * Post-process used to create a lens flare effect
  71322. */
  71323. lensFlarePostProcess: Nullable<PostProcess>;
  71324. /**
  71325. * Post-process that merges the result of the lens flare post-process and the real scene color
  71326. */
  71327. lensFlareComposePostProcess: Nullable<PostProcess>;
  71328. /**
  71329. * Post-process used to create a motion blur effect
  71330. */
  71331. motionBlurPostProcess: Nullable<PostProcess>;
  71332. /**
  71333. * Post-process used to create a depth of field effect
  71334. */
  71335. depthOfFieldPostProcess: Nullable<PostProcess>;
  71336. /**
  71337. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71338. */
  71339. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71340. /**
  71341. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71342. */
  71343. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71344. /**
  71345. * Represents the brightness threshold in order to configure the illuminated surfaces
  71346. */
  71347. brightThreshold: number;
  71348. /**
  71349. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71350. */
  71351. blurWidth: number;
  71352. /**
  71353. * Sets if the blur for highlighted surfaces must be only horizontal
  71354. */
  71355. horizontalBlur: boolean;
  71356. /**
  71357. * Gets the overall exposure used by the pipeline
  71358. */
  71359. get exposure(): number;
  71360. /**
  71361. * Sets the overall exposure used by the pipeline
  71362. */
  71363. set exposure(value: number);
  71364. /**
  71365. * Texture used typically to simulate "dirty" on camera lens
  71366. */
  71367. lensTexture: Nullable<Texture>;
  71368. /**
  71369. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71370. */
  71371. volumetricLightCoefficient: number;
  71372. /**
  71373. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71374. */
  71375. volumetricLightPower: number;
  71376. /**
  71377. * Used the set the blur intensity to smooth the volumetric lights
  71378. */
  71379. volumetricLightBlurScale: number;
  71380. /**
  71381. * Light (spot or directional) used to generate the volumetric lights rays
  71382. * The source light must have a shadow generate so the pipeline can get its
  71383. * depth map
  71384. */
  71385. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71386. /**
  71387. * For eye adaptation, represents the minimum luminance the eye can see
  71388. */
  71389. hdrMinimumLuminance: number;
  71390. /**
  71391. * For eye adaptation, represents the decrease luminance speed
  71392. */
  71393. hdrDecreaseRate: number;
  71394. /**
  71395. * For eye adaptation, represents the increase luminance speed
  71396. */
  71397. hdrIncreaseRate: number;
  71398. /**
  71399. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71400. */
  71401. get hdrAutoExposure(): boolean;
  71402. /**
  71403. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71404. */
  71405. set hdrAutoExposure(value: boolean);
  71406. /**
  71407. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71408. */
  71409. lensColorTexture: Nullable<Texture>;
  71410. /**
  71411. * The overall strengh for the lens flare effect
  71412. */
  71413. lensFlareStrength: number;
  71414. /**
  71415. * Dispersion coefficient for lens flare ghosts
  71416. */
  71417. lensFlareGhostDispersal: number;
  71418. /**
  71419. * Main lens flare halo width
  71420. */
  71421. lensFlareHaloWidth: number;
  71422. /**
  71423. * Based on the lens distortion effect, defines how much the lens flare result
  71424. * is distorted
  71425. */
  71426. lensFlareDistortionStrength: number;
  71427. /**
  71428. * Configures the blur intensity used for for lens flare (halo)
  71429. */
  71430. lensFlareBlurWidth: number;
  71431. /**
  71432. * Lens star texture must be used to simulate rays on the flares and is available
  71433. * in the documentation
  71434. */
  71435. lensStarTexture: Nullable<Texture>;
  71436. /**
  71437. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71438. * flare effect by taking account of the dirt texture
  71439. */
  71440. lensFlareDirtTexture: Nullable<Texture>;
  71441. /**
  71442. * Represents the focal length for the depth of field effect
  71443. */
  71444. depthOfFieldDistance: number;
  71445. /**
  71446. * Represents the blur intensity for the blurred part of the depth of field effect
  71447. */
  71448. depthOfFieldBlurWidth: number;
  71449. /**
  71450. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71451. */
  71452. get motionStrength(): number;
  71453. /**
  71454. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71455. */
  71456. set motionStrength(strength: number);
  71457. /**
  71458. * Gets wether or not the motion blur post-process is object based or screen based.
  71459. */
  71460. get objectBasedMotionBlur(): boolean;
  71461. /**
  71462. * Sets wether or not the motion blur post-process should be object based or screen based
  71463. */
  71464. set objectBasedMotionBlur(value: boolean);
  71465. /**
  71466. * List of animations for the pipeline (IAnimatable implementation)
  71467. */
  71468. animations: Animation[];
  71469. /**
  71470. * Private members
  71471. */
  71472. private _scene;
  71473. private _currentDepthOfFieldSource;
  71474. private _basePostProcess;
  71475. private _fixedExposure;
  71476. private _currentExposure;
  71477. private _hdrAutoExposure;
  71478. private _hdrCurrentLuminance;
  71479. private _motionStrength;
  71480. private _isObjectBasedMotionBlur;
  71481. private _floatTextureType;
  71482. private _camerasToBeAttached;
  71483. private _ratio;
  71484. private _bloomEnabled;
  71485. private _depthOfFieldEnabled;
  71486. private _vlsEnabled;
  71487. private _lensFlareEnabled;
  71488. private _hdrEnabled;
  71489. private _motionBlurEnabled;
  71490. private _fxaaEnabled;
  71491. private _screenSpaceReflectionsEnabled;
  71492. private _motionBlurSamples;
  71493. private _volumetricLightStepsCount;
  71494. private _samples;
  71495. /**
  71496. * @ignore
  71497. * Specifies if the bloom pipeline is enabled
  71498. */
  71499. get BloomEnabled(): boolean;
  71500. set BloomEnabled(enabled: boolean);
  71501. /**
  71502. * @ignore
  71503. * Specifies if the depth of field pipeline is enabed
  71504. */
  71505. get DepthOfFieldEnabled(): boolean;
  71506. set DepthOfFieldEnabled(enabled: boolean);
  71507. /**
  71508. * @ignore
  71509. * Specifies if the lens flare pipeline is enabed
  71510. */
  71511. get LensFlareEnabled(): boolean;
  71512. set LensFlareEnabled(enabled: boolean);
  71513. /**
  71514. * @ignore
  71515. * Specifies if the HDR pipeline is enabled
  71516. */
  71517. get HDREnabled(): boolean;
  71518. set HDREnabled(enabled: boolean);
  71519. /**
  71520. * @ignore
  71521. * Specifies if the volumetric lights scattering effect is enabled
  71522. */
  71523. get VLSEnabled(): boolean;
  71524. set VLSEnabled(enabled: boolean);
  71525. /**
  71526. * @ignore
  71527. * Specifies if the motion blur effect is enabled
  71528. */
  71529. get MotionBlurEnabled(): boolean;
  71530. set MotionBlurEnabled(enabled: boolean);
  71531. /**
  71532. * Specifies if anti-aliasing is enabled
  71533. */
  71534. get fxaaEnabled(): boolean;
  71535. set fxaaEnabled(enabled: boolean);
  71536. /**
  71537. * Specifies if screen space reflections are enabled.
  71538. */
  71539. get screenSpaceReflectionsEnabled(): boolean;
  71540. set screenSpaceReflectionsEnabled(enabled: boolean);
  71541. /**
  71542. * Specifies the number of steps used to calculate the volumetric lights
  71543. * Typically in interval [50, 200]
  71544. */
  71545. get volumetricLightStepsCount(): number;
  71546. set volumetricLightStepsCount(count: number);
  71547. /**
  71548. * Specifies the number of samples used for the motion blur effect
  71549. * Typically in interval [16, 64]
  71550. */
  71551. get motionBlurSamples(): number;
  71552. set motionBlurSamples(samples: number);
  71553. /**
  71554. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71555. */
  71556. get samples(): number;
  71557. set samples(sampleCount: number);
  71558. /**
  71559. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71560. * @constructor
  71561. * @param name The rendering pipeline name
  71562. * @param scene The scene linked to this pipeline
  71563. * @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)
  71564. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71565. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71566. */
  71567. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71568. private _buildPipeline;
  71569. private _createDownSampleX4PostProcess;
  71570. private _createBrightPassPostProcess;
  71571. private _createBlurPostProcesses;
  71572. private _createTextureAdderPostProcess;
  71573. private _createVolumetricLightPostProcess;
  71574. private _createLuminancePostProcesses;
  71575. private _createHdrPostProcess;
  71576. private _createLensFlarePostProcess;
  71577. private _createDepthOfFieldPostProcess;
  71578. private _createMotionBlurPostProcess;
  71579. private _getDepthTexture;
  71580. private _disposePostProcesses;
  71581. /**
  71582. * Dispose of the pipeline and stop all post processes
  71583. */
  71584. dispose(): void;
  71585. /**
  71586. * Serialize the rendering pipeline (Used when exporting)
  71587. * @returns the serialized object
  71588. */
  71589. serialize(): any;
  71590. /**
  71591. * Parse the serialized pipeline
  71592. * @param source Source pipeline.
  71593. * @param scene The scene to load the pipeline to.
  71594. * @param rootUrl The URL of the serialized pipeline.
  71595. * @returns An instantiated pipeline from the serialized object.
  71596. */
  71597. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71598. /**
  71599. * Luminance steps
  71600. */
  71601. static LuminanceSteps: number;
  71602. }
  71603. }
  71604. declare module BABYLON {
  71605. /** @hidden */
  71606. export var stereoscopicInterlacePixelShader: {
  71607. name: string;
  71608. shader: string;
  71609. };
  71610. }
  71611. declare module BABYLON {
  71612. /**
  71613. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71614. */
  71615. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71616. private _stepSize;
  71617. private _passedProcess;
  71618. /**
  71619. * Gets a string identifying the name of the class
  71620. * @returns "StereoscopicInterlacePostProcessI" string
  71621. */
  71622. getClassName(): string;
  71623. /**
  71624. * Initializes a StereoscopicInterlacePostProcessI
  71625. * @param name The name of the effect.
  71626. * @param rigCameras The rig cameras to be appled to the post process
  71627. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71628. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71629. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71630. * @param engine The engine which the post process will be applied. (default: current engine)
  71631. * @param reusable If the post process can be reused on the same frame. (default: false)
  71632. */
  71633. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71634. }
  71635. /**
  71636. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71637. */
  71638. export class StereoscopicInterlacePostProcess extends PostProcess {
  71639. private _stepSize;
  71640. private _passedProcess;
  71641. /**
  71642. * Gets a string identifying the name of the class
  71643. * @returns "StereoscopicInterlacePostProcess" string
  71644. */
  71645. getClassName(): string;
  71646. /**
  71647. * Initializes a StereoscopicInterlacePostProcess
  71648. * @param name The name of the effect.
  71649. * @param rigCameras The rig cameras to be appled to the post process
  71650. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71652. * @param engine The engine which the post process will be applied. (default: current engine)
  71653. * @param reusable If the post process can be reused on the same frame. (default: false)
  71654. */
  71655. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71656. }
  71657. }
  71658. declare module BABYLON {
  71659. /** @hidden */
  71660. export var tonemapPixelShader: {
  71661. name: string;
  71662. shader: string;
  71663. };
  71664. }
  71665. declare module BABYLON {
  71666. /** Defines operator used for tonemapping */
  71667. export enum TonemappingOperator {
  71668. /** Hable */
  71669. Hable = 0,
  71670. /** Reinhard */
  71671. Reinhard = 1,
  71672. /** HejiDawson */
  71673. HejiDawson = 2,
  71674. /** Photographic */
  71675. Photographic = 3
  71676. }
  71677. /**
  71678. * Defines a post process to apply tone mapping
  71679. */
  71680. export class TonemapPostProcess extends PostProcess {
  71681. private _operator;
  71682. /** Defines the required exposure adjustement */
  71683. exposureAdjustment: number;
  71684. /**
  71685. * Gets a string identifying the name of the class
  71686. * @returns "TonemapPostProcess" string
  71687. */
  71688. getClassName(): string;
  71689. /**
  71690. * Creates a new TonemapPostProcess
  71691. * @param name defines the name of the postprocess
  71692. * @param _operator defines the operator to use
  71693. * @param exposureAdjustment defines the required exposure adjustement
  71694. * @param camera defines the camera to use (can be null)
  71695. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71696. * @param engine defines the hosting engine (can be ignore if camera is set)
  71697. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71698. */
  71699. constructor(name: string, _operator: TonemappingOperator,
  71700. /** Defines the required exposure adjustement */
  71701. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71702. }
  71703. }
  71704. declare module BABYLON {
  71705. /** @hidden */
  71706. export var volumetricLightScatteringPixelShader: {
  71707. name: string;
  71708. shader: string;
  71709. };
  71710. }
  71711. declare module BABYLON {
  71712. /** @hidden */
  71713. export var volumetricLightScatteringPassVertexShader: {
  71714. name: string;
  71715. shader: string;
  71716. };
  71717. }
  71718. declare module BABYLON {
  71719. /** @hidden */
  71720. export var volumetricLightScatteringPassPixelShader: {
  71721. name: string;
  71722. shader: string;
  71723. };
  71724. }
  71725. declare module BABYLON {
  71726. /**
  71727. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71728. */
  71729. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71730. private _volumetricLightScatteringPass;
  71731. private _volumetricLightScatteringRTT;
  71732. private _viewPort;
  71733. private _screenCoordinates;
  71734. private _cachedDefines;
  71735. /**
  71736. * If not undefined, the mesh position is computed from the attached node position
  71737. */
  71738. attachedNode: {
  71739. position: Vector3;
  71740. };
  71741. /**
  71742. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71743. */
  71744. customMeshPosition: Vector3;
  71745. /**
  71746. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71747. */
  71748. useCustomMeshPosition: boolean;
  71749. /**
  71750. * If the post-process should inverse the light scattering direction
  71751. */
  71752. invert: boolean;
  71753. /**
  71754. * The internal mesh used by the post-process
  71755. */
  71756. mesh: Mesh;
  71757. /**
  71758. * @hidden
  71759. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71760. */
  71761. get useDiffuseColor(): boolean;
  71762. set useDiffuseColor(useDiffuseColor: boolean);
  71763. /**
  71764. * Array containing the excluded meshes not rendered in the internal pass
  71765. */
  71766. excludedMeshes: AbstractMesh[];
  71767. /**
  71768. * Controls the overall intensity of the post-process
  71769. */
  71770. exposure: number;
  71771. /**
  71772. * Dissipates each sample's contribution in range [0, 1]
  71773. */
  71774. decay: number;
  71775. /**
  71776. * Controls the overall intensity of each sample
  71777. */
  71778. weight: number;
  71779. /**
  71780. * Controls the density of each sample
  71781. */
  71782. density: number;
  71783. /**
  71784. * @constructor
  71785. * @param name The post-process name
  71786. * @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)
  71787. * @param camera The camera that the post-process will be attached to
  71788. * @param mesh The mesh used to create the light scattering
  71789. * @param samples The post-process quality, default 100
  71790. * @param samplingModeThe post-process filtering mode
  71791. * @param engine The babylon engine
  71792. * @param reusable If the post-process is reusable
  71793. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71794. */
  71795. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71796. /**
  71797. * Returns the string "VolumetricLightScatteringPostProcess"
  71798. * @returns "VolumetricLightScatteringPostProcess"
  71799. */
  71800. getClassName(): string;
  71801. private _isReady;
  71802. /**
  71803. * Sets the new light position for light scattering effect
  71804. * @param position The new custom light position
  71805. */
  71806. setCustomMeshPosition(position: Vector3): void;
  71807. /**
  71808. * Returns the light position for light scattering effect
  71809. * @return Vector3 The custom light position
  71810. */
  71811. getCustomMeshPosition(): Vector3;
  71812. /**
  71813. * Disposes the internal assets and detaches the post-process from the camera
  71814. */
  71815. dispose(camera: Camera): void;
  71816. /**
  71817. * Returns the render target texture used by the post-process
  71818. * @return the render target texture used by the post-process
  71819. */
  71820. getPass(): RenderTargetTexture;
  71821. private _meshExcluded;
  71822. private _createPass;
  71823. private _updateMeshScreenCoordinates;
  71824. /**
  71825. * Creates a default mesh for the Volumeric Light Scattering post-process
  71826. * @param name The mesh name
  71827. * @param scene The scene where to create the mesh
  71828. * @return the default mesh
  71829. */
  71830. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71831. }
  71832. }
  71833. declare module BABYLON {
  71834. /** @hidden */
  71835. export var screenSpaceCurvaturePixelShader: {
  71836. name: string;
  71837. shader: string;
  71838. };
  71839. }
  71840. declare module BABYLON {
  71841. /**
  71842. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71843. */
  71844. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71845. /**
  71846. * Defines how much ridge the curvature effect displays.
  71847. */
  71848. ridge: number;
  71849. /**
  71850. * Defines how much valley the curvature effect displays.
  71851. */
  71852. valley: number;
  71853. private _geometryBufferRenderer;
  71854. /**
  71855. * Gets a string identifying the name of the class
  71856. * @returns "ScreenSpaceCurvaturePostProcess" string
  71857. */
  71858. getClassName(): string;
  71859. /**
  71860. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71861. * @param name The name of the effect.
  71862. * @param scene The scene containing the objects to blur according to their velocity.
  71863. * @param options The required width/height ratio to downsize to before computing the render pass.
  71864. * @param camera The camera to apply the render pass to.
  71865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71866. * @param engine The engine which the post process will be applied. (default: current engine)
  71867. * @param reusable If the post process can be reused on the same frame. (default: false)
  71868. * @param textureType Type of textures used when performing the post process. (default: 0)
  71869. * @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)
  71870. */
  71871. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71872. /**
  71873. * Support test.
  71874. */
  71875. static get IsSupported(): boolean;
  71876. /** @hidden */
  71877. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71878. }
  71879. }
  71880. declare module BABYLON {
  71881. interface Scene {
  71882. /** @hidden (Backing field) */
  71883. _boundingBoxRenderer: BoundingBoxRenderer;
  71884. /** @hidden (Backing field) */
  71885. _forceShowBoundingBoxes: boolean;
  71886. /**
  71887. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71888. */
  71889. forceShowBoundingBoxes: boolean;
  71890. /**
  71891. * Gets the bounding box renderer associated with the scene
  71892. * @returns a BoundingBoxRenderer
  71893. */
  71894. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71895. }
  71896. interface AbstractMesh {
  71897. /** @hidden (Backing field) */
  71898. _showBoundingBox: boolean;
  71899. /**
  71900. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71901. */
  71902. showBoundingBox: boolean;
  71903. }
  71904. /**
  71905. * Component responsible of rendering the bounding box of the meshes in a scene.
  71906. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71907. */
  71908. export class BoundingBoxRenderer implements ISceneComponent {
  71909. /**
  71910. * The component name helpfull to identify the component in the list of scene components.
  71911. */
  71912. readonly name: string;
  71913. /**
  71914. * The scene the component belongs to.
  71915. */
  71916. scene: Scene;
  71917. /**
  71918. * Color of the bounding box lines placed in front of an object
  71919. */
  71920. frontColor: Color3;
  71921. /**
  71922. * Color of the bounding box lines placed behind an object
  71923. */
  71924. backColor: Color3;
  71925. /**
  71926. * Defines if the renderer should show the back lines or not
  71927. */
  71928. showBackLines: boolean;
  71929. /**
  71930. * Observable raised before rendering a bounding box
  71931. */
  71932. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71933. /**
  71934. * Observable raised after rendering a bounding box
  71935. */
  71936. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71937. /**
  71938. * @hidden
  71939. */
  71940. renderList: SmartArray<BoundingBox>;
  71941. private _colorShader;
  71942. private _vertexBuffers;
  71943. private _indexBuffer;
  71944. private _fillIndexBuffer;
  71945. private _fillIndexData;
  71946. /**
  71947. * Instantiates a new bounding box renderer in a scene.
  71948. * @param scene the scene the renderer renders in
  71949. */
  71950. constructor(scene: Scene);
  71951. /**
  71952. * Registers the component in a given scene
  71953. */
  71954. register(): void;
  71955. private _evaluateSubMesh;
  71956. private _activeMesh;
  71957. private _prepareRessources;
  71958. private _createIndexBuffer;
  71959. /**
  71960. * Rebuilds the elements related to this component in case of
  71961. * context lost for instance.
  71962. */
  71963. rebuild(): void;
  71964. /**
  71965. * @hidden
  71966. */
  71967. reset(): void;
  71968. /**
  71969. * Render the bounding boxes of a specific rendering group
  71970. * @param renderingGroupId defines the rendering group to render
  71971. */
  71972. render(renderingGroupId: number): void;
  71973. /**
  71974. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71975. * @param mesh Define the mesh to render the occlusion bounding box for
  71976. */
  71977. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71978. /**
  71979. * Dispose and release the resources attached to this renderer.
  71980. */
  71981. dispose(): void;
  71982. }
  71983. }
  71984. declare module BABYLON {
  71985. interface Scene {
  71986. /** @hidden (Backing field) */
  71987. _depthRenderer: {
  71988. [id: string]: DepthRenderer;
  71989. };
  71990. /**
  71991. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71992. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71993. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71994. * @returns the created depth renderer
  71995. */
  71996. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71997. /**
  71998. * Disables a depth renderer for a given camera
  71999. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72000. */
  72001. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72002. }
  72003. /**
  72004. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72005. * in several rendering techniques.
  72006. */
  72007. export class DepthRendererSceneComponent implements ISceneComponent {
  72008. /**
  72009. * The component name helpfull to identify the component in the list of scene components.
  72010. */
  72011. readonly name: string;
  72012. /**
  72013. * The scene the component belongs to.
  72014. */
  72015. scene: Scene;
  72016. /**
  72017. * Creates a new instance of the component for the given scene
  72018. * @param scene Defines the scene to register the component in
  72019. */
  72020. constructor(scene: Scene);
  72021. /**
  72022. * Registers the component in a given scene
  72023. */
  72024. register(): void;
  72025. /**
  72026. * Rebuilds the elements related to this component in case of
  72027. * context lost for instance.
  72028. */
  72029. rebuild(): void;
  72030. /**
  72031. * Disposes the component and the associated ressources
  72032. */
  72033. dispose(): void;
  72034. private _gatherRenderTargets;
  72035. private _gatherActiveCameraRenderTargets;
  72036. }
  72037. }
  72038. declare module BABYLON {
  72039. interface AbstractScene {
  72040. /** @hidden (Backing field) */
  72041. _prePassRenderer: Nullable<PrePassRenderer>;
  72042. /**
  72043. * Gets or Sets the current prepass renderer associated to the scene.
  72044. */
  72045. prePassRenderer: Nullable<PrePassRenderer>;
  72046. /**
  72047. * Enables the prepass and associates it with the scene
  72048. * @returns the PrePassRenderer
  72049. */
  72050. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72051. /**
  72052. * Disables the prepass associated with the scene
  72053. */
  72054. disablePrePassRenderer(): void;
  72055. }
  72056. /**
  72057. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72058. * in several rendering techniques.
  72059. */
  72060. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  72061. /**
  72062. * The component name helpful to identify the component in the list of scene components.
  72063. */
  72064. readonly name: string;
  72065. /**
  72066. * The scene the component belongs to.
  72067. */
  72068. scene: Scene;
  72069. /**
  72070. * Creates a new instance of the component for the given scene
  72071. * @param scene Defines the scene to register the component in
  72072. */
  72073. constructor(scene: Scene);
  72074. /**
  72075. * Registers the component in a given scene
  72076. */
  72077. register(): void;
  72078. private _beforeCameraDraw;
  72079. private _afterCameraDraw;
  72080. private _beforeClearStage;
  72081. /**
  72082. * Serializes the component data to the specified json object
  72083. * @param serializationObject The object to serialize to
  72084. */
  72085. serialize(serializationObject: any): void;
  72086. /**
  72087. * Adds all the elements from the container to the scene
  72088. * @param container the container holding the elements
  72089. */
  72090. addFromContainer(container: AbstractScene): void;
  72091. /**
  72092. * Removes all the elements in the container from the scene
  72093. * @param container contains the elements to remove
  72094. * @param dispose if the removed element should be disposed (default: false)
  72095. */
  72096. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72097. /**
  72098. * Rebuilds the elements related to this component in case of
  72099. * context lost for instance.
  72100. */
  72101. rebuild(): void;
  72102. /**
  72103. * Disposes the component and the associated ressources
  72104. */
  72105. dispose(): void;
  72106. }
  72107. }
  72108. declare module BABYLON {
  72109. /** @hidden */
  72110. export var outlinePixelShader: {
  72111. name: string;
  72112. shader: string;
  72113. };
  72114. }
  72115. declare module BABYLON {
  72116. /** @hidden */
  72117. export var outlineVertexShader: {
  72118. name: string;
  72119. shader: string;
  72120. };
  72121. }
  72122. declare module BABYLON {
  72123. interface Scene {
  72124. /** @hidden */
  72125. _outlineRenderer: OutlineRenderer;
  72126. /**
  72127. * Gets the outline renderer associated with the scene
  72128. * @returns a OutlineRenderer
  72129. */
  72130. getOutlineRenderer(): OutlineRenderer;
  72131. }
  72132. interface AbstractMesh {
  72133. /** @hidden (Backing field) */
  72134. _renderOutline: boolean;
  72135. /**
  72136. * Gets or sets a boolean indicating if the outline must be rendered as well
  72137. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72138. */
  72139. renderOutline: boolean;
  72140. /** @hidden (Backing field) */
  72141. _renderOverlay: boolean;
  72142. /**
  72143. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72144. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72145. */
  72146. renderOverlay: boolean;
  72147. }
  72148. /**
  72149. * This class is responsible to draw bothe outline/overlay of meshes.
  72150. * It should not be used directly but through the available method on mesh.
  72151. */
  72152. export class OutlineRenderer implements ISceneComponent {
  72153. /**
  72154. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72155. */
  72156. private static _StencilReference;
  72157. /**
  72158. * The name of the component. Each component must have a unique name.
  72159. */
  72160. name: string;
  72161. /**
  72162. * The scene the component belongs to.
  72163. */
  72164. scene: Scene;
  72165. /**
  72166. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72167. */
  72168. zOffset: number;
  72169. private _engine;
  72170. private _effect;
  72171. private _cachedDefines;
  72172. private _savedDepthWrite;
  72173. /**
  72174. * Instantiates a new outline renderer. (There could be only one per scene).
  72175. * @param scene Defines the scene it belongs to
  72176. */
  72177. constructor(scene: Scene);
  72178. /**
  72179. * Register the component to one instance of a scene.
  72180. */
  72181. register(): void;
  72182. /**
  72183. * Rebuilds the elements related to this component in case of
  72184. * context lost for instance.
  72185. */
  72186. rebuild(): void;
  72187. /**
  72188. * Disposes the component and the associated ressources.
  72189. */
  72190. dispose(): void;
  72191. /**
  72192. * Renders the outline in the canvas.
  72193. * @param subMesh Defines the sumesh to render
  72194. * @param batch Defines the batch of meshes in case of instances
  72195. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72196. */
  72197. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72198. /**
  72199. * Returns whether or not the outline renderer is ready for a given submesh.
  72200. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72201. * @param subMesh Defines the submesh to check readyness for
  72202. * @param useInstances Defines wheter wee are trying to render instances or not
  72203. * @returns true if ready otherwise false
  72204. */
  72205. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72206. private _beforeRenderingMesh;
  72207. private _afterRenderingMesh;
  72208. }
  72209. }
  72210. declare module BABYLON {
  72211. /**
  72212. * Defines the basic options interface of a Sprite Frame Source Size.
  72213. */
  72214. export interface ISpriteJSONSpriteSourceSize {
  72215. /**
  72216. * number of the original width of the Frame
  72217. */
  72218. w: number;
  72219. /**
  72220. * number of the original height of the Frame
  72221. */
  72222. h: number;
  72223. }
  72224. /**
  72225. * Defines the basic options interface of a Sprite Frame Data.
  72226. */
  72227. export interface ISpriteJSONSpriteFrameData {
  72228. /**
  72229. * number of the x offset of the Frame
  72230. */
  72231. x: number;
  72232. /**
  72233. * number of the y offset of the Frame
  72234. */
  72235. y: number;
  72236. /**
  72237. * number of the width of the Frame
  72238. */
  72239. w: number;
  72240. /**
  72241. * number of the height of the Frame
  72242. */
  72243. h: number;
  72244. }
  72245. /**
  72246. * Defines the basic options interface of a JSON Sprite.
  72247. */
  72248. export interface ISpriteJSONSprite {
  72249. /**
  72250. * string name of the Frame
  72251. */
  72252. filename: string;
  72253. /**
  72254. * ISpriteJSONSpriteFrame basic object of the frame data
  72255. */
  72256. frame: ISpriteJSONSpriteFrameData;
  72257. /**
  72258. * boolean to flag is the frame was rotated.
  72259. */
  72260. rotated: boolean;
  72261. /**
  72262. * boolean to flag is the frame was trimmed.
  72263. */
  72264. trimmed: boolean;
  72265. /**
  72266. * ISpriteJSONSpriteFrame basic object of the source data
  72267. */
  72268. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72269. /**
  72270. * ISpriteJSONSpriteFrame basic object of the source data
  72271. */
  72272. sourceSize: ISpriteJSONSpriteSourceSize;
  72273. }
  72274. /**
  72275. * Defines the basic options interface of a JSON atlas.
  72276. */
  72277. export interface ISpriteJSONAtlas {
  72278. /**
  72279. * Array of objects that contain the frame data.
  72280. */
  72281. frames: Array<ISpriteJSONSprite>;
  72282. /**
  72283. * object basic object containing the sprite meta data.
  72284. */
  72285. meta?: object;
  72286. }
  72287. }
  72288. declare module BABYLON {
  72289. /** @hidden */
  72290. export var spriteMapPixelShader: {
  72291. name: string;
  72292. shader: string;
  72293. };
  72294. }
  72295. declare module BABYLON {
  72296. /** @hidden */
  72297. export var spriteMapVertexShader: {
  72298. name: string;
  72299. shader: string;
  72300. };
  72301. }
  72302. declare module BABYLON {
  72303. /**
  72304. * Defines the basic options interface of a SpriteMap
  72305. */
  72306. export interface ISpriteMapOptions {
  72307. /**
  72308. * Vector2 of the number of cells in the grid.
  72309. */
  72310. stageSize?: Vector2;
  72311. /**
  72312. * Vector2 of the size of the output plane in World Units.
  72313. */
  72314. outputSize?: Vector2;
  72315. /**
  72316. * Vector3 of the position of the output plane in World Units.
  72317. */
  72318. outputPosition?: Vector3;
  72319. /**
  72320. * Vector3 of the rotation of the output plane.
  72321. */
  72322. outputRotation?: Vector3;
  72323. /**
  72324. * number of layers that the system will reserve in resources.
  72325. */
  72326. layerCount?: number;
  72327. /**
  72328. * number of max animation frames a single cell will reserve in resources.
  72329. */
  72330. maxAnimationFrames?: number;
  72331. /**
  72332. * number cell index of the base tile when the system compiles.
  72333. */
  72334. baseTile?: number;
  72335. /**
  72336. * boolean flip the sprite after its been repositioned by the framing data.
  72337. */
  72338. flipU?: boolean;
  72339. /**
  72340. * Vector3 scalar of the global RGB values of the SpriteMap.
  72341. */
  72342. colorMultiply?: Vector3;
  72343. }
  72344. /**
  72345. * Defines the IDisposable interface in order to be cleanable from resources.
  72346. */
  72347. export interface ISpriteMap extends IDisposable {
  72348. /**
  72349. * String name of the SpriteMap.
  72350. */
  72351. name: string;
  72352. /**
  72353. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72354. */
  72355. atlasJSON: ISpriteJSONAtlas;
  72356. /**
  72357. * Texture of the SpriteMap.
  72358. */
  72359. spriteSheet: Texture;
  72360. /**
  72361. * The parameters to initialize the SpriteMap with.
  72362. */
  72363. options: ISpriteMapOptions;
  72364. }
  72365. /**
  72366. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72367. */
  72368. export class SpriteMap implements ISpriteMap {
  72369. /** The Name of the spriteMap */
  72370. name: string;
  72371. /** The JSON file with the frame and meta data */
  72372. atlasJSON: ISpriteJSONAtlas;
  72373. /** The systems Sprite Sheet Texture */
  72374. spriteSheet: Texture;
  72375. /** Arguments passed with the Constructor */
  72376. options: ISpriteMapOptions;
  72377. /** Public Sprite Storage array, parsed from atlasJSON */
  72378. sprites: Array<ISpriteJSONSprite>;
  72379. /** Returns the Number of Sprites in the System */
  72380. get spriteCount(): number;
  72381. /** Returns the Position of Output Plane*/
  72382. get position(): Vector3;
  72383. /** Returns the Position of Output Plane*/
  72384. set position(v: Vector3);
  72385. /** Returns the Rotation of Output Plane*/
  72386. get rotation(): Vector3;
  72387. /** Returns the Rotation of Output Plane*/
  72388. set rotation(v: Vector3);
  72389. /** Sets the AnimationMap*/
  72390. get animationMap(): RawTexture;
  72391. /** Sets the AnimationMap*/
  72392. set animationMap(v: RawTexture);
  72393. /** Scene that the SpriteMap was created in */
  72394. private _scene;
  72395. /** Texture Buffer of Float32 that holds tile frame data*/
  72396. private _frameMap;
  72397. /** Texture Buffers of Float32 that holds tileMap data*/
  72398. private _tileMaps;
  72399. /** Texture Buffer of Float32 that holds Animation Data*/
  72400. private _animationMap;
  72401. /** Custom ShaderMaterial Central to the System*/
  72402. private _material;
  72403. /** Custom ShaderMaterial Central to the System*/
  72404. private _output;
  72405. /** Systems Time Ticker*/
  72406. private _time;
  72407. /**
  72408. * Creates a new SpriteMap
  72409. * @param name defines the SpriteMaps Name
  72410. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72411. * @param spriteSheet is the Texture that the Sprites are on.
  72412. * @param options a basic deployment configuration
  72413. * @param scene The Scene that the map is deployed on
  72414. */
  72415. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72416. /**
  72417. * Returns tileID location
  72418. * @returns Vector2 the cell position ID
  72419. */
  72420. getTileID(): Vector2;
  72421. /**
  72422. * Gets the UV location of the mouse over the SpriteMap.
  72423. * @returns Vector2 the UV position of the mouse interaction
  72424. */
  72425. getMousePosition(): Vector2;
  72426. /**
  72427. * Creates the "frame" texture Buffer
  72428. * -------------------------------------
  72429. * Structure of frames
  72430. * "filename": "Falling-Water-2.png",
  72431. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72432. * "rotated": true,
  72433. * "trimmed": true,
  72434. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72435. * "sourceSize": {"w":32,"h":32}
  72436. * @returns RawTexture of the frameMap
  72437. */
  72438. private _createFrameBuffer;
  72439. /**
  72440. * Creates the tileMap texture Buffer
  72441. * @param buffer normally and array of numbers, or a false to generate from scratch
  72442. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72443. * @returns RawTexture of the tileMap
  72444. */
  72445. private _createTileBuffer;
  72446. /**
  72447. * Modifies the data of the tileMaps
  72448. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72449. * @param pos is the iVector2 Coordinates of the Tile
  72450. * @param tile The SpriteIndex of the new Tile
  72451. */
  72452. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72453. /**
  72454. * Creates the animationMap texture Buffer
  72455. * @param buffer normally and array of numbers, or a false to generate from scratch
  72456. * @returns RawTexture of the animationMap
  72457. */
  72458. private _createTileAnimationBuffer;
  72459. /**
  72460. * Modifies the data of the animationMap
  72461. * @param cellID is the Index of the Sprite
  72462. * @param _frame is the target Animation frame
  72463. * @param toCell is the Target Index of the next frame of the animation
  72464. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72465. * @param speed is a global scalar of the time variable on the map.
  72466. */
  72467. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72468. /**
  72469. * Exports the .tilemaps file
  72470. */
  72471. saveTileMaps(): void;
  72472. /**
  72473. * Imports the .tilemaps file
  72474. * @param url of the .tilemaps file
  72475. */
  72476. loadTileMaps(url: string): void;
  72477. /**
  72478. * Release associated resources
  72479. */
  72480. dispose(): void;
  72481. }
  72482. }
  72483. declare module BABYLON {
  72484. /**
  72485. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72486. * @see https://doc.babylonjs.com/babylon101/sprites
  72487. */
  72488. export class SpritePackedManager extends SpriteManager {
  72489. /** defines the packed manager's name */
  72490. name: string;
  72491. /**
  72492. * Creates a new sprite manager from a packed sprite sheet
  72493. * @param name defines the manager's name
  72494. * @param imgUrl defines the sprite sheet url
  72495. * @param capacity defines the maximum allowed number of sprites
  72496. * @param scene defines the hosting scene
  72497. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72498. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72499. * @param samplingMode defines the smapling mode to use with spritesheet
  72500. * @param fromPacked set to true; do not alter
  72501. */
  72502. constructor(
  72503. /** defines the packed manager's name */
  72504. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72505. }
  72506. }
  72507. declare module BABYLON {
  72508. /**
  72509. * Defines the list of states available for a task inside a AssetsManager
  72510. */
  72511. export enum AssetTaskState {
  72512. /**
  72513. * Initialization
  72514. */
  72515. INIT = 0,
  72516. /**
  72517. * Running
  72518. */
  72519. RUNNING = 1,
  72520. /**
  72521. * Done
  72522. */
  72523. DONE = 2,
  72524. /**
  72525. * Error
  72526. */
  72527. ERROR = 3
  72528. }
  72529. /**
  72530. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72531. */
  72532. export abstract class AbstractAssetTask {
  72533. /**
  72534. * Task name
  72535. */ name: string;
  72536. /**
  72537. * Callback called when the task is successful
  72538. */
  72539. onSuccess: (task: any) => void;
  72540. /**
  72541. * Callback called when the task is not successful
  72542. */
  72543. onError: (task: any, message?: string, exception?: any) => void;
  72544. /**
  72545. * Creates a new AssetsManager
  72546. * @param name defines the name of the task
  72547. */
  72548. constructor(
  72549. /**
  72550. * Task name
  72551. */ name: string);
  72552. private _isCompleted;
  72553. private _taskState;
  72554. private _errorObject;
  72555. /**
  72556. * Get if the task is completed
  72557. */
  72558. get isCompleted(): boolean;
  72559. /**
  72560. * Gets the current state of the task
  72561. */
  72562. get taskState(): AssetTaskState;
  72563. /**
  72564. * Gets the current error object (if task is in error)
  72565. */
  72566. get errorObject(): {
  72567. message?: string;
  72568. exception?: any;
  72569. };
  72570. /**
  72571. * Internal only
  72572. * @hidden
  72573. */
  72574. _setErrorObject(message?: string, exception?: any): void;
  72575. /**
  72576. * Execute the current task
  72577. * @param scene defines the scene where you want your assets to be loaded
  72578. * @param onSuccess is a callback called when the task is successfully executed
  72579. * @param onError is a callback called if an error occurs
  72580. */
  72581. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72582. /**
  72583. * Execute the current task
  72584. * @param scene defines the scene where you want your assets to be loaded
  72585. * @param onSuccess is a callback called when the task is successfully executed
  72586. * @param onError is a callback called if an error occurs
  72587. */
  72588. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72589. /**
  72590. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72591. * This can be used with failed tasks that have the reason for failure fixed.
  72592. */
  72593. reset(): void;
  72594. private onErrorCallback;
  72595. private onDoneCallback;
  72596. }
  72597. /**
  72598. * Define the interface used by progress events raised during assets loading
  72599. */
  72600. export interface IAssetsProgressEvent {
  72601. /**
  72602. * Defines the number of remaining tasks to process
  72603. */
  72604. remainingCount: number;
  72605. /**
  72606. * Defines the total number of tasks
  72607. */
  72608. totalCount: number;
  72609. /**
  72610. * Defines the task that was just processed
  72611. */
  72612. task: AbstractAssetTask;
  72613. }
  72614. /**
  72615. * Class used to share progress information about assets loading
  72616. */
  72617. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72618. /**
  72619. * Defines the number of remaining tasks to process
  72620. */
  72621. remainingCount: number;
  72622. /**
  72623. * Defines the total number of tasks
  72624. */
  72625. totalCount: number;
  72626. /**
  72627. * Defines the task that was just processed
  72628. */
  72629. task: AbstractAssetTask;
  72630. /**
  72631. * Creates a AssetsProgressEvent
  72632. * @param remainingCount defines the number of remaining tasks to process
  72633. * @param totalCount defines the total number of tasks
  72634. * @param task defines the task that was just processed
  72635. */
  72636. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72637. }
  72638. /**
  72639. * Define a task used by AssetsManager to load assets into a container
  72640. */
  72641. export class ContainerAssetTask extends AbstractAssetTask {
  72642. /**
  72643. * Defines the name of the task
  72644. */
  72645. name: string;
  72646. /**
  72647. * Defines the list of mesh's names you want to load
  72648. */
  72649. meshesNames: any;
  72650. /**
  72651. * Defines the root url to use as a base to load your meshes and associated resources
  72652. */
  72653. rootUrl: string;
  72654. /**
  72655. * Defines the filename or File of the scene to load from
  72656. */
  72657. sceneFilename: string | File;
  72658. /**
  72659. * Get the loaded asset container
  72660. */
  72661. loadedContainer: AssetContainer;
  72662. /**
  72663. * Gets the list of loaded meshes
  72664. */
  72665. loadedMeshes: Array<AbstractMesh>;
  72666. /**
  72667. * Gets the list of loaded particle systems
  72668. */
  72669. loadedParticleSystems: Array<IParticleSystem>;
  72670. /**
  72671. * Gets the list of loaded skeletons
  72672. */
  72673. loadedSkeletons: Array<Skeleton>;
  72674. /**
  72675. * Gets the list of loaded animation groups
  72676. */
  72677. loadedAnimationGroups: Array<AnimationGroup>;
  72678. /**
  72679. * Callback called when the task is successful
  72680. */
  72681. onSuccess: (task: ContainerAssetTask) => void;
  72682. /**
  72683. * Callback called when the task is successful
  72684. */
  72685. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72686. /**
  72687. * Creates a new ContainerAssetTask
  72688. * @param name defines the name of the task
  72689. * @param meshesNames defines the list of mesh's names you want to load
  72690. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72691. * @param sceneFilename defines the filename or File of the scene to load from
  72692. */
  72693. constructor(
  72694. /**
  72695. * Defines the name of the task
  72696. */
  72697. name: string,
  72698. /**
  72699. * Defines the list of mesh's names you want to load
  72700. */
  72701. meshesNames: any,
  72702. /**
  72703. * Defines the root url to use as a base to load your meshes and associated resources
  72704. */
  72705. rootUrl: string,
  72706. /**
  72707. * Defines the filename or File of the scene to load from
  72708. */
  72709. sceneFilename: string | File);
  72710. /**
  72711. * Execute the current task
  72712. * @param scene defines the scene where you want your assets to be loaded
  72713. * @param onSuccess is a callback called when the task is successfully executed
  72714. * @param onError is a callback called if an error occurs
  72715. */
  72716. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72717. }
  72718. /**
  72719. * Define a task used by AssetsManager to load meshes
  72720. */
  72721. export class MeshAssetTask extends AbstractAssetTask {
  72722. /**
  72723. * Defines the name of the task
  72724. */
  72725. name: string;
  72726. /**
  72727. * Defines the list of mesh's names you want to load
  72728. */
  72729. meshesNames: any;
  72730. /**
  72731. * Defines the root url to use as a base to load your meshes and associated resources
  72732. */
  72733. rootUrl: string;
  72734. /**
  72735. * Defines the filename or File of the scene to load from
  72736. */
  72737. sceneFilename: string | File;
  72738. /**
  72739. * Gets the list of loaded meshes
  72740. */
  72741. loadedMeshes: Array<AbstractMesh>;
  72742. /**
  72743. * Gets the list of loaded particle systems
  72744. */
  72745. loadedParticleSystems: Array<IParticleSystem>;
  72746. /**
  72747. * Gets the list of loaded skeletons
  72748. */
  72749. loadedSkeletons: Array<Skeleton>;
  72750. /**
  72751. * Gets the list of loaded animation groups
  72752. */
  72753. loadedAnimationGroups: Array<AnimationGroup>;
  72754. /**
  72755. * Callback called when the task is successful
  72756. */
  72757. onSuccess: (task: MeshAssetTask) => void;
  72758. /**
  72759. * Callback called when the task is successful
  72760. */
  72761. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72762. /**
  72763. * Creates a new MeshAssetTask
  72764. * @param name defines the name of the task
  72765. * @param meshesNames defines the list of mesh's names you want to load
  72766. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72767. * @param sceneFilename defines the filename or File of the scene to load from
  72768. */
  72769. constructor(
  72770. /**
  72771. * Defines the name of the task
  72772. */
  72773. name: string,
  72774. /**
  72775. * Defines the list of mesh's names you want to load
  72776. */
  72777. meshesNames: any,
  72778. /**
  72779. * Defines the root url to use as a base to load your meshes and associated resources
  72780. */
  72781. rootUrl: string,
  72782. /**
  72783. * Defines the filename or File of the scene to load from
  72784. */
  72785. sceneFilename: string | File);
  72786. /**
  72787. * Execute the current task
  72788. * @param scene defines the scene where you want your assets to be loaded
  72789. * @param onSuccess is a callback called when the task is successfully executed
  72790. * @param onError is a callback called if an error occurs
  72791. */
  72792. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72793. }
  72794. /**
  72795. * Define a task used by AssetsManager to load text content
  72796. */
  72797. export class TextFileAssetTask extends AbstractAssetTask {
  72798. /**
  72799. * Defines the name of the task
  72800. */
  72801. name: string;
  72802. /**
  72803. * Defines the location of the file to load
  72804. */
  72805. url: string;
  72806. /**
  72807. * Gets the loaded text string
  72808. */
  72809. text: string;
  72810. /**
  72811. * Callback called when the task is successful
  72812. */
  72813. onSuccess: (task: TextFileAssetTask) => void;
  72814. /**
  72815. * Callback called when the task is successful
  72816. */
  72817. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72818. /**
  72819. * Creates a new TextFileAssetTask object
  72820. * @param name defines the name of the task
  72821. * @param url defines the location of the file to load
  72822. */
  72823. constructor(
  72824. /**
  72825. * Defines the name of the task
  72826. */
  72827. name: string,
  72828. /**
  72829. * Defines the location of the file to load
  72830. */
  72831. url: string);
  72832. /**
  72833. * Execute the current task
  72834. * @param scene defines the scene where you want your assets to be loaded
  72835. * @param onSuccess is a callback called when the task is successfully executed
  72836. * @param onError is a callback called if an error occurs
  72837. */
  72838. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72839. }
  72840. /**
  72841. * Define a task used by AssetsManager to load binary data
  72842. */
  72843. export class BinaryFileAssetTask extends AbstractAssetTask {
  72844. /**
  72845. * Defines the name of the task
  72846. */
  72847. name: string;
  72848. /**
  72849. * Defines the location of the file to load
  72850. */
  72851. url: string;
  72852. /**
  72853. * Gets the lodaded data (as an array buffer)
  72854. */
  72855. data: ArrayBuffer;
  72856. /**
  72857. * Callback called when the task is successful
  72858. */
  72859. onSuccess: (task: BinaryFileAssetTask) => void;
  72860. /**
  72861. * Callback called when the task is successful
  72862. */
  72863. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72864. /**
  72865. * Creates a new BinaryFileAssetTask object
  72866. * @param name defines the name of the new task
  72867. * @param url defines the location of the file to load
  72868. */
  72869. constructor(
  72870. /**
  72871. * Defines the name of the task
  72872. */
  72873. name: string,
  72874. /**
  72875. * Defines the location of the file to load
  72876. */
  72877. url: string);
  72878. /**
  72879. * Execute the current task
  72880. * @param scene defines the scene where you want your assets to be loaded
  72881. * @param onSuccess is a callback called when the task is successfully executed
  72882. * @param onError is a callback called if an error occurs
  72883. */
  72884. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72885. }
  72886. /**
  72887. * Define a task used by AssetsManager to load images
  72888. */
  72889. export class ImageAssetTask extends AbstractAssetTask {
  72890. /**
  72891. * Defines the name of the task
  72892. */
  72893. name: string;
  72894. /**
  72895. * Defines the location of the image to load
  72896. */
  72897. url: string;
  72898. /**
  72899. * Gets the loaded images
  72900. */
  72901. image: HTMLImageElement;
  72902. /**
  72903. * Callback called when the task is successful
  72904. */
  72905. onSuccess: (task: ImageAssetTask) => void;
  72906. /**
  72907. * Callback called when the task is successful
  72908. */
  72909. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72910. /**
  72911. * Creates a new ImageAssetTask
  72912. * @param name defines the name of the task
  72913. * @param url defines the location of the image to load
  72914. */
  72915. constructor(
  72916. /**
  72917. * Defines the name of the task
  72918. */
  72919. name: string,
  72920. /**
  72921. * Defines the location of the image to load
  72922. */
  72923. url: string);
  72924. /**
  72925. * Execute the current task
  72926. * @param scene defines the scene where you want your assets to be loaded
  72927. * @param onSuccess is a callback called when the task is successfully executed
  72928. * @param onError is a callback called if an error occurs
  72929. */
  72930. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72931. }
  72932. /**
  72933. * Defines the interface used by texture loading tasks
  72934. */
  72935. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72936. /**
  72937. * Gets the loaded texture
  72938. */
  72939. texture: TEX;
  72940. }
  72941. /**
  72942. * Define a task used by AssetsManager to load 2D textures
  72943. */
  72944. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72945. /**
  72946. * Defines the name of the task
  72947. */
  72948. name: string;
  72949. /**
  72950. * Defines the location of the file to load
  72951. */
  72952. url: string;
  72953. /**
  72954. * Defines if mipmap should not be generated (default is false)
  72955. */
  72956. noMipmap?: boolean | undefined;
  72957. /**
  72958. * Defines if texture must be inverted on Y axis (default is true)
  72959. */
  72960. invertY: boolean;
  72961. /**
  72962. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72963. */
  72964. samplingMode: number;
  72965. /**
  72966. * Gets the loaded texture
  72967. */
  72968. texture: Texture;
  72969. /**
  72970. * Callback called when the task is successful
  72971. */
  72972. onSuccess: (task: TextureAssetTask) => void;
  72973. /**
  72974. * Callback called when the task is successful
  72975. */
  72976. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72977. /**
  72978. * Creates a new TextureAssetTask object
  72979. * @param name defines the name of the task
  72980. * @param url defines the location of the file to load
  72981. * @param noMipmap defines if mipmap should not be generated (default is false)
  72982. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72983. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72984. */
  72985. constructor(
  72986. /**
  72987. * Defines the name of the task
  72988. */
  72989. name: string,
  72990. /**
  72991. * Defines the location of the file to load
  72992. */
  72993. url: string,
  72994. /**
  72995. * Defines if mipmap should not be generated (default is false)
  72996. */
  72997. noMipmap?: boolean | undefined,
  72998. /**
  72999. * Defines if texture must be inverted on Y axis (default is true)
  73000. */
  73001. invertY?: boolean,
  73002. /**
  73003. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73004. */
  73005. samplingMode?: number);
  73006. /**
  73007. * Execute the current task
  73008. * @param scene defines the scene where you want your assets to be loaded
  73009. * @param onSuccess is a callback called when the task is successfully executed
  73010. * @param onError is a callback called if an error occurs
  73011. */
  73012. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73013. }
  73014. /**
  73015. * Define a task used by AssetsManager to load cube textures
  73016. */
  73017. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73018. /**
  73019. * Defines the name of the task
  73020. */
  73021. name: string;
  73022. /**
  73023. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73024. */
  73025. url: string;
  73026. /**
  73027. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73028. */
  73029. extensions?: string[] | undefined;
  73030. /**
  73031. * Defines if mipmaps should not be generated (default is false)
  73032. */
  73033. noMipmap?: boolean | undefined;
  73034. /**
  73035. * Defines the explicit list of files (undefined by default)
  73036. */
  73037. files?: string[] | undefined;
  73038. /**
  73039. * Gets the loaded texture
  73040. */
  73041. texture: CubeTexture;
  73042. /**
  73043. * Callback called when the task is successful
  73044. */
  73045. onSuccess: (task: CubeTextureAssetTask) => void;
  73046. /**
  73047. * Callback called when the task is successful
  73048. */
  73049. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73050. /**
  73051. * Creates a new CubeTextureAssetTask
  73052. * @param name defines the name of the task
  73053. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73054. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73055. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73056. * @param files defines the explicit list of files (undefined by default)
  73057. */
  73058. constructor(
  73059. /**
  73060. * Defines the name of the task
  73061. */
  73062. name: string,
  73063. /**
  73064. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73065. */
  73066. url: string,
  73067. /**
  73068. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73069. */
  73070. extensions?: string[] | undefined,
  73071. /**
  73072. * Defines if mipmaps should not be generated (default is false)
  73073. */
  73074. noMipmap?: boolean | undefined,
  73075. /**
  73076. * Defines the explicit list of files (undefined by default)
  73077. */
  73078. files?: string[] | undefined);
  73079. /**
  73080. * Execute the current task
  73081. * @param scene defines the scene where you want your assets to be loaded
  73082. * @param onSuccess is a callback called when the task is successfully executed
  73083. * @param onError is a callback called if an error occurs
  73084. */
  73085. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73086. }
  73087. /**
  73088. * Define a task used by AssetsManager to load HDR cube textures
  73089. */
  73090. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73091. /**
  73092. * Defines the name of the task
  73093. */
  73094. name: string;
  73095. /**
  73096. * Defines the location of the file to load
  73097. */
  73098. url: string;
  73099. /**
  73100. * Defines the desired size (the more it increases the longer the generation will be)
  73101. */
  73102. size: number;
  73103. /**
  73104. * Defines if mipmaps should not be generated (default is false)
  73105. */
  73106. noMipmap: boolean;
  73107. /**
  73108. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73109. */
  73110. generateHarmonics: boolean;
  73111. /**
  73112. * 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)
  73113. */
  73114. gammaSpace: boolean;
  73115. /**
  73116. * Internal Use Only
  73117. */
  73118. reserved: boolean;
  73119. /**
  73120. * Gets the loaded texture
  73121. */
  73122. texture: HDRCubeTexture;
  73123. /**
  73124. * Callback called when the task is successful
  73125. */
  73126. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73127. /**
  73128. * Callback called when the task is successful
  73129. */
  73130. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73131. /**
  73132. * Creates a new HDRCubeTextureAssetTask object
  73133. * @param name defines the name of the task
  73134. * @param url defines the location of the file to load
  73135. * @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.
  73136. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73137. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73138. * @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)
  73139. * @param reserved Internal use only
  73140. */
  73141. constructor(
  73142. /**
  73143. * Defines the name of the task
  73144. */
  73145. name: string,
  73146. /**
  73147. * Defines the location of the file to load
  73148. */
  73149. url: string,
  73150. /**
  73151. * Defines the desired size (the more it increases the longer the generation will be)
  73152. */
  73153. size: number,
  73154. /**
  73155. * Defines if mipmaps should not be generated (default is false)
  73156. */
  73157. noMipmap?: boolean,
  73158. /**
  73159. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73160. */
  73161. generateHarmonics?: boolean,
  73162. /**
  73163. * 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)
  73164. */
  73165. gammaSpace?: boolean,
  73166. /**
  73167. * Internal Use Only
  73168. */
  73169. reserved?: boolean);
  73170. /**
  73171. * Execute the current task
  73172. * @param scene defines the scene where you want your assets to be loaded
  73173. * @param onSuccess is a callback called when the task is successfully executed
  73174. * @param onError is a callback called if an error occurs
  73175. */
  73176. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73177. }
  73178. /**
  73179. * Define a task used by AssetsManager to load Equirectangular cube textures
  73180. */
  73181. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73182. /**
  73183. * Defines the name of the task
  73184. */
  73185. name: string;
  73186. /**
  73187. * Defines the location of the file to load
  73188. */
  73189. url: string;
  73190. /**
  73191. * Defines the desired size (the more it increases the longer the generation will be)
  73192. */
  73193. size: number;
  73194. /**
  73195. * Defines if mipmaps should not be generated (default is false)
  73196. */
  73197. noMipmap: boolean;
  73198. /**
  73199. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73200. * but the standard material would require them in Gamma space) (default is true)
  73201. */
  73202. gammaSpace: boolean;
  73203. /**
  73204. * Gets the loaded texture
  73205. */
  73206. texture: EquiRectangularCubeTexture;
  73207. /**
  73208. * Callback called when the task is successful
  73209. */
  73210. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73211. /**
  73212. * Callback called when the task is successful
  73213. */
  73214. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73215. /**
  73216. * Creates a new EquiRectangularCubeTextureAssetTask object
  73217. * @param name defines the name of the task
  73218. * @param url defines the location of the file to load
  73219. * @param size defines the desired size (the more it increases the longer the generation will be)
  73220. * If the size is omitted this implies you are using a preprocessed cubemap.
  73221. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73222. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73223. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73224. * (default is true)
  73225. */
  73226. constructor(
  73227. /**
  73228. * Defines the name of the task
  73229. */
  73230. name: string,
  73231. /**
  73232. * Defines the location of the file to load
  73233. */
  73234. url: string,
  73235. /**
  73236. * Defines the desired size (the more it increases the longer the generation will be)
  73237. */
  73238. size: number,
  73239. /**
  73240. * Defines if mipmaps should not be generated (default is false)
  73241. */
  73242. noMipmap?: boolean,
  73243. /**
  73244. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73245. * but the standard material would require them in Gamma space) (default is true)
  73246. */
  73247. gammaSpace?: boolean);
  73248. /**
  73249. * Execute the current task
  73250. * @param scene defines the scene where you want your assets to be loaded
  73251. * @param onSuccess is a callback called when the task is successfully executed
  73252. * @param onError is a callback called if an error occurs
  73253. */
  73254. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73255. }
  73256. /**
  73257. * This class can be used to easily import assets into a scene
  73258. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73259. */
  73260. export class AssetsManager {
  73261. private _scene;
  73262. private _isLoading;
  73263. protected _tasks: AbstractAssetTask[];
  73264. protected _waitingTasksCount: number;
  73265. protected _totalTasksCount: number;
  73266. /**
  73267. * Callback called when all tasks are processed
  73268. */
  73269. onFinish: (tasks: AbstractAssetTask[]) => void;
  73270. /**
  73271. * Callback called when a task is successful
  73272. */
  73273. onTaskSuccess: (task: AbstractAssetTask) => void;
  73274. /**
  73275. * Callback called when a task had an error
  73276. */
  73277. onTaskError: (task: AbstractAssetTask) => void;
  73278. /**
  73279. * Callback called when a task is done (whatever the result is)
  73280. */
  73281. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73282. /**
  73283. * Observable called when all tasks are processed
  73284. */
  73285. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73286. /**
  73287. * Observable called when a task had an error
  73288. */
  73289. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73290. /**
  73291. * Observable called when all tasks were executed
  73292. */
  73293. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73294. /**
  73295. * Observable called when a task is done (whatever the result is)
  73296. */
  73297. onProgressObservable: Observable<IAssetsProgressEvent>;
  73298. /**
  73299. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73300. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73301. */
  73302. useDefaultLoadingScreen: boolean;
  73303. /**
  73304. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73305. * when all assets have been downloaded.
  73306. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73307. */
  73308. autoHideLoadingUI: boolean;
  73309. /**
  73310. * Creates a new AssetsManager
  73311. * @param scene defines the scene to work on
  73312. */
  73313. constructor(scene: Scene);
  73314. /**
  73315. * Add a ContainerAssetTask to the list of active tasks
  73316. * @param taskName defines the name of the new task
  73317. * @param meshesNames defines the name of meshes to load
  73318. * @param rootUrl defines the root url to use to locate files
  73319. * @param sceneFilename defines the filename of the scene file
  73320. * @returns a new ContainerAssetTask object
  73321. */
  73322. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73323. /**
  73324. * Add a MeshAssetTask to the list of active tasks
  73325. * @param taskName defines the name of the new task
  73326. * @param meshesNames defines the name of meshes to load
  73327. * @param rootUrl defines the root url to use to locate files
  73328. * @param sceneFilename defines the filename of the scene file
  73329. * @returns a new MeshAssetTask object
  73330. */
  73331. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73332. /**
  73333. * Add a TextFileAssetTask to the list of active tasks
  73334. * @param taskName defines the name of the new task
  73335. * @param url defines the url of the file to load
  73336. * @returns a new TextFileAssetTask object
  73337. */
  73338. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73339. /**
  73340. * Add a BinaryFileAssetTask to the list of active tasks
  73341. * @param taskName defines the name of the new task
  73342. * @param url defines the url of the file to load
  73343. * @returns a new BinaryFileAssetTask object
  73344. */
  73345. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73346. /**
  73347. * Add a ImageAssetTask to the list of active tasks
  73348. * @param taskName defines the name of the new task
  73349. * @param url defines the url of the file to load
  73350. * @returns a new ImageAssetTask object
  73351. */
  73352. addImageTask(taskName: string, url: string): ImageAssetTask;
  73353. /**
  73354. * Add a TextureAssetTask to the list of active tasks
  73355. * @param taskName defines the name of the new task
  73356. * @param url defines the url of the file to load
  73357. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73358. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73359. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73360. * @returns a new TextureAssetTask object
  73361. */
  73362. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73363. /**
  73364. * Add a CubeTextureAssetTask to the list of active tasks
  73365. * @param taskName defines the name of the new task
  73366. * @param url defines the url of the file to load
  73367. * @param extensions defines the extension to use to load the cube map (can be null)
  73368. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73369. * @param files defines the list of files to load (can be null)
  73370. * @returns a new CubeTextureAssetTask object
  73371. */
  73372. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73373. /**
  73374. *
  73375. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73376. * @param taskName defines the name of the new task
  73377. * @param url defines the url of the file to load
  73378. * @param size defines the size you want for the cubemap (can be null)
  73379. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73380. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73381. * @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)
  73382. * @param reserved Internal use only
  73383. * @returns a new HDRCubeTextureAssetTask object
  73384. */
  73385. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73386. /**
  73387. *
  73388. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73389. * @param taskName defines the name of the new task
  73390. * @param url defines the url of the file to load
  73391. * @param size defines the size you want for the cubemap (can be null)
  73392. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73393. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73394. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73395. * @returns a new EquiRectangularCubeTextureAssetTask object
  73396. */
  73397. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73398. /**
  73399. * Remove a task from the assets manager.
  73400. * @param task the task to remove
  73401. */
  73402. removeTask(task: AbstractAssetTask): void;
  73403. private _decreaseWaitingTasksCount;
  73404. private _runTask;
  73405. /**
  73406. * Reset the AssetsManager and remove all tasks
  73407. * @return the current instance of the AssetsManager
  73408. */
  73409. reset(): AssetsManager;
  73410. /**
  73411. * Start the loading process
  73412. * @return the current instance of the AssetsManager
  73413. */
  73414. load(): AssetsManager;
  73415. /**
  73416. * Start the loading process as an async operation
  73417. * @return a promise returning the list of failed tasks
  73418. */
  73419. loadAsync(): Promise<void>;
  73420. }
  73421. }
  73422. declare module BABYLON {
  73423. /**
  73424. * Wrapper class for promise with external resolve and reject.
  73425. */
  73426. export class Deferred<T> {
  73427. /**
  73428. * The promise associated with this deferred object.
  73429. */
  73430. readonly promise: Promise<T>;
  73431. private _resolve;
  73432. private _reject;
  73433. /**
  73434. * The resolve method of the promise associated with this deferred object.
  73435. */
  73436. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73437. /**
  73438. * The reject method of the promise associated with this deferred object.
  73439. */
  73440. get reject(): (reason?: any) => void;
  73441. /**
  73442. * Constructor for this deferred object.
  73443. */
  73444. constructor();
  73445. }
  73446. }
  73447. declare module BABYLON {
  73448. /**
  73449. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73450. */
  73451. export class MeshExploder {
  73452. private _centerMesh;
  73453. private _meshes;
  73454. private _meshesOrigins;
  73455. private _toCenterVectors;
  73456. private _scaledDirection;
  73457. private _newPosition;
  73458. private _centerPosition;
  73459. /**
  73460. * Explodes meshes from a center mesh.
  73461. * @param meshes The meshes to explode.
  73462. * @param centerMesh The mesh to be center of explosion.
  73463. */
  73464. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73465. private _setCenterMesh;
  73466. /**
  73467. * Get class name
  73468. * @returns "MeshExploder"
  73469. */
  73470. getClassName(): string;
  73471. /**
  73472. * "Exploded meshes"
  73473. * @returns Array of meshes with the centerMesh at index 0.
  73474. */
  73475. getMeshes(): Array<Mesh>;
  73476. /**
  73477. * Explodes meshes giving a specific direction
  73478. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73479. */
  73480. explode(direction?: number): void;
  73481. }
  73482. }
  73483. declare module BABYLON {
  73484. /**
  73485. * Class used to help managing file picking and drag'n'drop
  73486. */
  73487. export class FilesInput {
  73488. /**
  73489. * List of files ready to be loaded
  73490. */
  73491. static get FilesToLoad(): {
  73492. [key: string]: File;
  73493. };
  73494. /**
  73495. * Callback called when a file is processed
  73496. */
  73497. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73498. private _engine;
  73499. private _currentScene;
  73500. private _sceneLoadedCallback;
  73501. private _progressCallback;
  73502. private _additionalRenderLoopLogicCallback;
  73503. private _textureLoadingCallback;
  73504. private _startingProcessingFilesCallback;
  73505. private _onReloadCallback;
  73506. private _errorCallback;
  73507. private _elementToMonitor;
  73508. private _sceneFileToLoad;
  73509. private _filesToLoad;
  73510. /**
  73511. * Creates a new FilesInput
  73512. * @param engine defines the rendering engine
  73513. * @param scene defines the hosting scene
  73514. * @param sceneLoadedCallback callback called when scene is loaded
  73515. * @param progressCallback callback called to track progress
  73516. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73517. * @param textureLoadingCallback callback called when a texture is loading
  73518. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73519. * @param onReloadCallback callback called when a reload is requested
  73520. * @param errorCallback callback call if an error occurs
  73521. */
  73522. 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>);
  73523. private _dragEnterHandler;
  73524. private _dragOverHandler;
  73525. private _dropHandler;
  73526. /**
  73527. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73528. * @param elementToMonitor defines the DOM element to track
  73529. */
  73530. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73531. /** Gets the current list of files to load */
  73532. get filesToLoad(): File[];
  73533. /**
  73534. * Release all associated resources
  73535. */
  73536. dispose(): void;
  73537. private renderFunction;
  73538. private drag;
  73539. private drop;
  73540. private _traverseFolder;
  73541. private _processFiles;
  73542. /**
  73543. * Load files from a drop event
  73544. * @param event defines the drop event to use as source
  73545. */
  73546. loadFiles(event: any): void;
  73547. private _processReload;
  73548. /**
  73549. * Reload the current scene from the loaded files
  73550. */
  73551. reload(): void;
  73552. }
  73553. }
  73554. declare module BABYLON {
  73555. /**
  73556. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73557. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73558. */
  73559. export class SceneOptimization {
  73560. /**
  73561. * Defines the priority of this optimization (0 by default which means first in the list)
  73562. */
  73563. priority: number;
  73564. /**
  73565. * Gets a string describing the action executed by the current optimization
  73566. * @returns description string
  73567. */
  73568. getDescription(): string;
  73569. /**
  73570. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73571. * @param scene defines the current scene where to apply this optimization
  73572. * @param optimizer defines the current optimizer
  73573. * @returns true if everything that can be done was applied
  73574. */
  73575. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73576. /**
  73577. * Creates the SceneOptimization object
  73578. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73579. * @param desc defines the description associated with the optimization
  73580. */
  73581. constructor(
  73582. /**
  73583. * Defines the priority of this optimization (0 by default which means first in the list)
  73584. */
  73585. priority?: number);
  73586. }
  73587. /**
  73588. * Defines an optimization used to reduce the size of render target textures
  73589. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73590. */
  73591. export class TextureOptimization extends SceneOptimization {
  73592. /**
  73593. * Defines the priority of this optimization (0 by default which means first in the list)
  73594. */
  73595. priority: number;
  73596. /**
  73597. * 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
  73598. */
  73599. maximumSize: number;
  73600. /**
  73601. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73602. */
  73603. step: number;
  73604. /**
  73605. * Gets a string describing the action executed by the current optimization
  73606. * @returns description string
  73607. */
  73608. getDescription(): string;
  73609. /**
  73610. * Creates the TextureOptimization object
  73611. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73612. * @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
  73613. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73614. */
  73615. constructor(
  73616. /**
  73617. * Defines the priority of this optimization (0 by default which means first in the list)
  73618. */
  73619. priority?: number,
  73620. /**
  73621. * 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
  73622. */
  73623. maximumSize?: number,
  73624. /**
  73625. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73626. */
  73627. step?: number);
  73628. /**
  73629. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73630. * @param scene defines the current scene where to apply this optimization
  73631. * @param optimizer defines the current optimizer
  73632. * @returns true if everything that can be done was applied
  73633. */
  73634. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73635. }
  73636. /**
  73637. * Defines an optimization used to increase or decrease the rendering resolution
  73638. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73639. */
  73640. export class HardwareScalingOptimization extends SceneOptimization {
  73641. /**
  73642. * Defines the priority of this optimization (0 by default which means first in the list)
  73643. */
  73644. priority: number;
  73645. /**
  73646. * Defines the maximum scale to use (2 by default)
  73647. */
  73648. maximumScale: number;
  73649. /**
  73650. * Defines the step to use between two passes (0.5 by default)
  73651. */
  73652. step: number;
  73653. private _currentScale;
  73654. private _directionOffset;
  73655. /**
  73656. * Gets a string describing the action executed by the current optimization
  73657. * @return description string
  73658. */
  73659. getDescription(): string;
  73660. /**
  73661. * Creates the HardwareScalingOptimization object
  73662. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73663. * @param maximumScale defines the maximum scale to use (2 by default)
  73664. * @param step defines the step to use between two passes (0.5 by default)
  73665. */
  73666. constructor(
  73667. /**
  73668. * Defines the priority of this optimization (0 by default which means first in the list)
  73669. */
  73670. priority?: number,
  73671. /**
  73672. * Defines the maximum scale to use (2 by default)
  73673. */
  73674. maximumScale?: number,
  73675. /**
  73676. * Defines the step to use between two passes (0.5 by default)
  73677. */
  73678. step?: number);
  73679. /**
  73680. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73681. * @param scene defines the current scene where to apply this optimization
  73682. * @param optimizer defines the current optimizer
  73683. * @returns true if everything that can be done was applied
  73684. */
  73685. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73686. }
  73687. /**
  73688. * Defines an optimization used to remove shadows
  73689. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73690. */
  73691. export class ShadowsOptimization extends SceneOptimization {
  73692. /**
  73693. * Gets a string describing the action executed by the current optimization
  73694. * @return description string
  73695. */
  73696. getDescription(): string;
  73697. /**
  73698. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73699. * @param scene defines the current scene where to apply this optimization
  73700. * @param optimizer defines the current optimizer
  73701. * @returns true if everything that can be done was applied
  73702. */
  73703. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73704. }
  73705. /**
  73706. * Defines an optimization used to turn post-processes off
  73707. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73708. */
  73709. export class PostProcessesOptimization extends SceneOptimization {
  73710. /**
  73711. * Gets a string describing the action executed by the current optimization
  73712. * @return description string
  73713. */
  73714. getDescription(): string;
  73715. /**
  73716. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73717. * @param scene defines the current scene where to apply this optimization
  73718. * @param optimizer defines the current optimizer
  73719. * @returns true if everything that can be done was applied
  73720. */
  73721. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73722. }
  73723. /**
  73724. * Defines an optimization used to turn lens flares off
  73725. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73726. */
  73727. export class LensFlaresOptimization extends SceneOptimization {
  73728. /**
  73729. * Gets a string describing the action executed by the current optimization
  73730. * @return description string
  73731. */
  73732. getDescription(): string;
  73733. /**
  73734. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73735. * @param scene defines the current scene where to apply this optimization
  73736. * @param optimizer defines the current optimizer
  73737. * @returns true if everything that can be done was applied
  73738. */
  73739. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73740. }
  73741. /**
  73742. * Defines an optimization based on user defined callback.
  73743. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73744. */
  73745. export class CustomOptimization extends SceneOptimization {
  73746. /**
  73747. * Callback called to apply the custom optimization.
  73748. */
  73749. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73750. /**
  73751. * Callback called to get custom description
  73752. */
  73753. onGetDescription: () => string;
  73754. /**
  73755. * Gets a string describing the action executed by the current optimization
  73756. * @returns description string
  73757. */
  73758. getDescription(): string;
  73759. /**
  73760. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73761. * @param scene defines the current scene where to apply this optimization
  73762. * @param optimizer defines the current optimizer
  73763. * @returns true if everything that can be done was applied
  73764. */
  73765. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73766. }
  73767. /**
  73768. * Defines an optimization used to turn particles off
  73769. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73770. */
  73771. export class ParticlesOptimization extends SceneOptimization {
  73772. /**
  73773. * Gets a string describing the action executed by the current optimization
  73774. * @return description string
  73775. */
  73776. getDescription(): string;
  73777. /**
  73778. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73779. * @param scene defines the current scene where to apply this optimization
  73780. * @param optimizer defines the current optimizer
  73781. * @returns true if everything that can be done was applied
  73782. */
  73783. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73784. }
  73785. /**
  73786. * Defines an optimization used to turn render targets off
  73787. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73788. */
  73789. export class RenderTargetsOptimization extends SceneOptimization {
  73790. /**
  73791. * Gets a string describing the action executed by the current optimization
  73792. * @return description string
  73793. */
  73794. getDescription(): string;
  73795. /**
  73796. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73797. * @param scene defines the current scene where to apply this optimization
  73798. * @param optimizer defines the current optimizer
  73799. * @returns true if everything that can be done was applied
  73800. */
  73801. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73802. }
  73803. /**
  73804. * Defines an optimization used to merge meshes with compatible materials
  73805. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73806. */
  73807. export class MergeMeshesOptimization extends SceneOptimization {
  73808. private static _UpdateSelectionTree;
  73809. /**
  73810. * Gets or sets a boolean which defines if optimization octree has to be updated
  73811. */
  73812. static get UpdateSelectionTree(): boolean;
  73813. /**
  73814. * Gets or sets a boolean which defines if optimization octree has to be updated
  73815. */
  73816. static set UpdateSelectionTree(value: boolean);
  73817. /**
  73818. * Gets a string describing the action executed by the current optimization
  73819. * @return description string
  73820. */
  73821. getDescription(): string;
  73822. private _canBeMerged;
  73823. /**
  73824. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73825. * @param scene defines the current scene where to apply this optimization
  73826. * @param optimizer defines the current optimizer
  73827. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73828. * @returns true if everything that can be done was applied
  73829. */
  73830. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73831. }
  73832. /**
  73833. * Defines a list of options used by SceneOptimizer
  73834. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73835. */
  73836. export class SceneOptimizerOptions {
  73837. /**
  73838. * Defines the target frame rate to reach (60 by default)
  73839. */
  73840. targetFrameRate: number;
  73841. /**
  73842. * Defines the interval between two checkes (2000ms by default)
  73843. */
  73844. trackerDuration: number;
  73845. /**
  73846. * Gets the list of optimizations to apply
  73847. */
  73848. optimizations: SceneOptimization[];
  73849. /**
  73850. * Creates a new list of options used by SceneOptimizer
  73851. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73852. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73853. */
  73854. constructor(
  73855. /**
  73856. * Defines the target frame rate to reach (60 by default)
  73857. */
  73858. targetFrameRate?: number,
  73859. /**
  73860. * Defines the interval between two checkes (2000ms by default)
  73861. */
  73862. trackerDuration?: number);
  73863. /**
  73864. * Add a new optimization
  73865. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73866. * @returns the current SceneOptimizerOptions
  73867. */
  73868. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73869. /**
  73870. * Add a new custom optimization
  73871. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73872. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73873. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73874. * @returns the current SceneOptimizerOptions
  73875. */
  73876. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73877. /**
  73878. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73879. * @param targetFrameRate defines the target frame rate (60 by default)
  73880. * @returns a SceneOptimizerOptions object
  73881. */
  73882. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73883. /**
  73884. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73885. * @param targetFrameRate defines the target frame rate (60 by default)
  73886. * @returns a SceneOptimizerOptions object
  73887. */
  73888. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73889. /**
  73890. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73891. * @param targetFrameRate defines the target frame rate (60 by default)
  73892. * @returns a SceneOptimizerOptions object
  73893. */
  73894. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73895. }
  73896. /**
  73897. * Class used to run optimizations in order to reach a target frame rate
  73898. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73899. */
  73900. export class SceneOptimizer implements IDisposable {
  73901. private _isRunning;
  73902. private _options;
  73903. private _scene;
  73904. private _currentPriorityLevel;
  73905. private _targetFrameRate;
  73906. private _trackerDuration;
  73907. private _currentFrameRate;
  73908. private _sceneDisposeObserver;
  73909. private _improvementMode;
  73910. /**
  73911. * Defines an observable called when the optimizer reaches the target frame rate
  73912. */
  73913. onSuccessObservable: Observable<SceneOptimizer>;
  73914. /**
  73915. * Defines an observable called when the optimizer enables an optimization
  73916. */
  73917. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73918. /**
  73919. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73920. */
  73921. onFailureObservable: Observable<SceneOptimizer>;
  73922. /**
  73923. * Gets a boolean indicating if the optimizer is in improvement mode
  73924. */
  73925. get isInImprovementMode(): boolean;
  73926. /**
  73927. * Gets the current priority level (0 at start)
  73928. */
  73929. get currentPriorityLevel(): number;
  73930. /**
  73931. * Gets the current frame rate checked by the SceneOptimizer
  73932. */
  73933. get currentFrameRate(): number;
  73934. /**
  73935. * Gets or sets the current target frame rate (60 by default)
  73936. */
  73937. get targetFrameRate(): number;
  73938. /**
  73939. * Gets or sets the current target frame rate (60 by default)
  73940. */
  73941. set targetFrameRate(value: number);
  73942. /**
  73943. * Gets or sets the current interval between two checks (every 2000ms by default)
  73944. */
  73945. get trackerDuration(): number;
  73946. /**
  73947. * Gets or sets the current interval between two checks (every 2000ms by default)
  73948. */
  73949. set trackerDuration(value: number);
  73950. /**
  73951. * Gets the list of active optimizations
  73952. */
  73953. get optimizations(): SceneOptimization[];
  73954. /**
  73955. * Creates a new SceneOptimizer
  73956. * @param scene defines the scene to work on
  73957. * @param options defines the options to use with the SceneOptimizer
  73958. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73959. * @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)
  73960. */
  73961. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73962. /**
  73963. * Stops the current optimizer
  73964. */
  73965. stop(): void;
  73966. /**
  73967. * Reset the optimizer to initial step (current priority level = 0)
  73968. */
  73969. reset(): void;
  73970. /**
  73971. * Start the optimizer. By default it will try to reach a specific framerate
  73972. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73973. */
  73974. start(): void;
  73975. private _checkCurrentState;
  73976. /**
  73977. * Release all resources
  73978. */
  73979. dispose(): void;
  73980. /**
  73981. * Helper function to create a SceneOptimizer with one single line of code
  73982. * @param scene defines the scene to work on
  73983. * @param options defines the options to use with the SceneOptimizer
  73984. * @param onSuccess defines a callback to call on success
  73985. * @param onFailure defines a callback to call on failure
  73986. * @returns the new SceneOptimizer object
  73987. */
  73988. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73989. }
  73990. }
  73991. declare module BABYLON {
  73992. /**
  73993. * Class used to serialize a scene into a string
  73994. */
  73995. export class SceneSerializer {
  73996. /**
  73997. * Clear cache used by a previous serialization
  73998. */
  73999. static ClearCache(): void;
  74000. /**
  74001. * Serialize a scene into a JSON compatible object
  74002. * @param scene defines the scene to serialize
  74003. * @returns a JSON compatible object
  74004. */
  74005. static Serialize(scene: Scene): any;
  74006. /**
  74007. * Serialize a mesh into a JSON compatible object
  74008. * @param toSerialize defines the mesh to serialize
  74009. * @param withParents defines if parents must be serialized as well
  74010. * @param withChildren defines if children must be serialized as well
  74011. * @returns a JSON compatible object
  74012. */
  74013. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74014. }
  74015. }
  74016. declare module BABYLON {
  74017. /**
  74018. * Class used to host texture specific utilities
  74019. */
  74020. export class TextureTools {
  74021. /**
  74022. * Uses the GPU to create a copy texture rescaled at a given size
  74023. * @param texture Texture to copy from
  74024. * @param width defines the desired width
  74025. * @param height defines the desired height
  74026. * @param useBilinearMode defines if bilinear mode has to be used
  74027. * @return the generated texture
  74028. */
  74029. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74030. }
  74031. }
  74032. declare module BABYLON {
  74033. /**
  74034. * This represents the different options available for the video capture.
  74035. */
  74036. export interface VideoRecorderOptions {
  74037. /** Defines the mime type of the video. */
  74038. mimeType: string;
  74039. /** Defines the FPS the video should be recorded at. */
  74040. fps: number;
  74041. /** Defines the chunk size for the recording data. */
  74042. recordChunckSize: number;
  74043. /** The audio tracks to attach to the recording. */
  74044. audioTracks?: MediaStreamTrack[];
  74045. }
  74046. /**
  74047. * This can help with recording videos from BabylonJS.
  74048. * This is based on the available WebRTC functionalities of the browser.
  74049. *
  74050. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74051. */
  74052. export class VideoRecorder {
  74053. private static readonly _defaultOptions;
  74054. /**
  74055. * Returns whether or not the VideoRecorder is available in your browser.
  74056. * @param engine Defines the Babylon Engine.
  74057. * @returns true if supported otherwise false.
  74058. */
  74059. static IsSupported(engine: Engine): boolean;
  74060. private readonly _options;
  74061. private _canvas;
  74062. private _mediaRecorder;
  74063. private _recordedChunks;
  74064. private _fileName;
  74065. private _resolve;
  74066. private _reject;
  74067. /**
  74068. * True when a recording is already in progress.
  74069. */
  74070. get isRecording(): boolean;
  74071. /**
  74072. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74073. * @param engine Defines the BabylonJS Engine you wish to record.
  74074. * @param options Defines options that can be used to customize the capture.
  74075. */
  74076. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74077. /**
  74078. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74079. */
  74080. stopRecording(): void;
  74081. /**
  74082. * Starts recording the canvas for a max duration specified in parameters.
  74083. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74084. * If null no automatic download will start and you can rely on the promise to get the data back.
  74085. * @param maxDuration Defines the maximum recording time in seconds.
  74086. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74087. * @return A promise callback at the end of the recording with the video data in Blob.
  74088. */
  74089. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74090. /**
  74091. * Releases internal resources used during the recording.
  74092. */
  74093. dispose(): void;
  74094. private _handleDataAvailable;
  74095. private _handleError;
  74096. private _handleStop;
  74097. }
  74098. }
  74099. declare module BABYLON {
  74100. /**
  74101. * Class containing a set of static utilities functions for screenshots
  74102. */
  74103. export class ScreenshotTools {
  74104. /**
  74105. * Captures a screenshot of the current rendering
  74106. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74107. * @param engine defines the rendering engine
  74108. * @param camera defines the source camera
  74109. * @param size This parameter can be set to a single number or to an object with the
  74110. * following (optional) properties: precision, width, height. If a single number is passed,
  74111. * it will be used for both width and height. If an object is passed, the screenshot size
  74112. * will be derived from the parameters. The precision property is a multiplier allowing
  74113. * rendering at a higher or lower resolution
  74114. * @param successCallback defines the callback receives a single parameter which contains the
  74115. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74116. * src parameter of an <img> to display it
  74117. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74118. * Check your browser for supported MIME types
  74119. */
  74120. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74121. /**
  74122. * Captures a screenshot of the current rendering
  74123. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74124. * @param engine defines the rendering engine
  74125. * @param camera defines the source camera
  74126. * @param size This parameter can be set to a single number or to an object with the
  74127. * following (optional) properties: precision, width, height. If a single number is passed,
  74128. * it will be used for both width and height. If an object is passed, the screenshot size
  74129. * will be derived from the parameters. The precision property is a multiplier allowing
  74130. * rendering at a higher or lower resolution
  74131. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74132. * Check your browser for supported MIME types
  74133. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74134. * to the src parameter of an <img> to display it
  74135. */
  74136. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74137. /**
  74138. * Generates an image screenshot from the specified camera.
  74139. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74140. * @param engine The engine to use for rendering
  74141. * @param camera The camera to use for rendering
  74142. * @param size This parameter can be set to a single number or to an object with the
  74143. * following (optional) properties: precision, width, height. If a single number is passed,
  74144. * it will be used for both width and height. If an object is passed, the screenshot size
  74145. * will be derived from the parameters. The precision property is a multiplier allowing
  74146. * rendering at a higher or lower resolution
  74147. * @param successCallback The callback receives a single parameter which contains the
  74148. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74149. * src parameter of an <img> to display it
  74150. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74151. * Check your browser for supported MIME types
  74152. * @param samples Texture samples (default: 1)
  74153. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74154. * @param fileName A name for for the downloaded file.
  74155. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74156. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74157. */
  74158. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  74159. /**
  74160. * Generates an image screenshot from the specified camera.
  74161. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74162. * @param engine The engine to use for rendering
  74163. * @param camera The camera to use for rendering
  74164. * @param size This parameter can be set to a single number or to an object with the
  74165. * following (optional) properties: precision, width, height. If a single number is passed,
  74166. * it will be used for both width and height. If an object is passed, the screenshot size
  74167. * will be derived from the parameters. The precision property is a multiplier allowing
  74168. * rendering at a higher or lower resolution
  74169. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74170. * Check your browser for supported MIME types
  74171. * @param samples Texture samples (default: 1)
  74172. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74173. * @param fileName A name for for the downloaded file.
  74174. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74175. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74176. * to the src parameter of an <img> to display it
  74177. */
  74178. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74179. /**
  74180. * Gets height and width for screenshot size
  74181. * @private
  74182. */
  74183. private static _getScreenshotSize;
  74184. }
  74185. }
  74186. declare module BABYLON {
  74187. /**
  74188. * Interface for a data buffer
  74189. */
  74190. export interface IDataBuffer {
  74191. /**
  74192. * Reads bytes from the data buffer.
  74193. * @param byteOffset The byte offset to read
  74194. * @param byteLength The byte length to read
  74195. * @returns A promise that resolves when the bytes are read
  74196. */
  74197. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74198. /**
  74199. * The byte length of the buffer.
  74200. */
  74201. readonly byteLength: number;
  74202. }
  74203. /**
  74204. * Utility class for reading from a data buffer
  74205. */
  74206. export class DataReader {
  74207. /**
  74208. * The data buffer associated with this data reader.
  74209. */
  74210. readonly buffer: IDataBuffer;
  74211. /**
  74212. * The current byte offset from the beginning of the data buffer.
  74213. */
  74214. byteOffset: number;
  74215. private _dataView;
  74216. private _dataByteOffset;
  74217. /**
  74218. * Constructor
  74219. * @param buffer The buffer to read
  74220. */
  74221. constructor(buffer: IDataBuffer);
  74222. /**
  74223. * Loads the given byte length.
  74224. * @param byteLength The byte length to load
  74225. * @returns A promise that resolves when the load is complete
  74226. */
  74227. loadAsync(byteLength: number): Promise<void>;
  74228. /**
  74229. * Read a unsigned 32-bit integer from the currently loaded data range.
  74230. * @returns The 32-bit integer read
  74231. */
  74232. readUint32(): number;
  74233. /**
  74234. * Read a byte array from the currently loaded data range.
  74235. * @param byteLength The byte length to read
  74236. * @returns The byte array read
  74237. */
  74238. readUint8Array(byteLength: number): Uint8Array;
  74239. /**
  74240. * Read a string from the currently loaded data range.
  74241. * @param byteLength The byte length to read
  74242. * @returns The string read
  74243. */
  74244. readString(byteLength: number): string;
  74245. /**
  74246. * Skips the given byte length the currently loaded data range.
  74247. * @param byteLength The byte length to skip
  74248. */
  74249. skipBytes(byteLength: number): void;
  74250. }
  74251. }
  74252. declare module BABYLON {
  74253. /**
  74254. * Class for storing data to local storage if available or in-memory storage otherwise
  74255. */
  74256. export class DataStorage {
  74257. private static _Storage;
  74258. private static _GetStorage;
  74259. /**
  74260. * Reads a string from the data storage
  74261. * @param key The key to read
  74262. * @param defaultValue The value if the key doesn't exist
  74263. * @returns The string value
  74264. */
  74265. static ReadString(key: string, defaultValue: string): string;
  74266. /**
  74267. * Writes a string to the data storage
  74268. * @param key The key to write
  74269. * @param value The value to write
  74270. */
  74271. static WriteString(key: string, value: string): void;
  74272. /**
  74273. * Reads a boolean from the data storage
  74274. * @param key The key to read
  74275. * @param defaultValue The value if the key doesn't exist
  74276. * @returns The boolean value
  74277. */
  74278. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74279. /**
  74280. * Writes a boolean to the data storage
  74281. * @param key The key to write
  74282. * @param value The value to write
  74283. */
  74284. static WriteBoolean(key: string, value: boolean): void;
  74285. /**
  74286. * Reads a number from the data storage
  74287. * @param key The key to read
  74288. * @param defaultValue The value if the key doesn't exist
  74289. * @returns The number value
  74290. */
  74291. static ReadNumber(key: string, defaultValue: number): number;
  74292. /**
  74293. * Writes a number to the data storage
  74294. * @param key The key to write
  74295. * @param value The value to write
  74296. */
  74297. static WriteNumber(key: string, value: number): void;
  74298. }
  74299. }
  74300. declare module BABYLON {
  74301. /**
  74302. * Class used to record delta files between 2 scene states
  74303. */
  74304. export class SceneRecorder {
  74305. private _trackedScene;
  74306. private _savedJSON;
  74307. /**
  74308. * Track a given scene. This means the current scene state will be considered the original state
  74309. * @param scene defines the scene to track
  74310. */
  74311. track(scene: Scene): void;
  74312. /**
  74313. * Get the delta between current state and original state
  74314. * @returns a string containing the delta
  74315. */
  74316. getDelta(): any;
  74317. private _compareArray;
  74318. private _compareObjects;
  74319. private _compareCollections;
  74320. private static GetShadowGeneratorById;
  74321. /**
  74322. * Apply a given delta to a given scene
  74323. * @param deltaJSON defines the JSON containing the delta
  74324. * @param scene defines the scene to apply the delta to
  74325. */
  74326. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74327. private static _ApplyPropertiesToEntity;
  74328. private static _ApplyDeltaForEntity;
  74329. }
  74330. }
  74331. declare module BABYLON {
  74332. /**
  74333. * An interface for all Hit test features
  74334. */
  74335. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74336. /**
  74337. * Triggered when new babylon (transformed) hit test results are available
  74338. */
  74339. onHitTestResultObservable: Observable<T[]>;
  74340. }
  74341. /**
  74342. * Options used for hit testing
  74343. */
  74344. export interface IWebXRLegacyHitTestOptions {
  74345. /**
  74346. * Only test when user interacted with the scene. Default - hit test every frame
  74347. */
  74348. testOnPointerDownOnly?: boolean;
  74349. /**
  74350. * The node to use to transform the local results to world coordinates
  74351. */
  74352. worldParentNode?: TransformNode;
  74353. }
  74354. /**
  74355. * Interface defining the babylon result of raycasting/hit-test
  74356. */
  74357. export interface IWebXRLegacyHitResult {
  74358. /**
  74359. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74360. */
  74361. transformationMatrix: Matrix;
  74362. /**
  74363. * The native hit test result
  74364. */
  74365. xrHitResult: XRHitResult | XRHitTestResult;
  74366. }
  74367. /**
  74368. * The currently-working hit-test module.
  74369. * Hit test (or Ray-casting) is used to interact with the real world.
  74370. * For further information read here - https://github.com/immersive-web/hit-test
  74371. */
  74372. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74373. /**
  74374. * options to use when constructing this feature
  74375. */
  74376. readonly options: IWebXRLegacyHitTestOptions;
  74377. private _direction;
  74378. private _mat;
  74379. private _onSelectEnabled;
  74380. private _origin;
  74381. /**
  74382. * The module's name
  74383. */
  74384. static readonly Name: string;
  74385. /**
  74386. * The (Babylon) version of this module.
  74387. * This is an integer representing the implementation version.
  74388. * This number does not correspond to the WebXR specs version
  74389. */
  74390. static readonly Version: number;
  74391. /**
  74392. * Populated with the last native XR Hit Results
  74393. */
  74394. lastNativeXRHitResults: XRHitResult[];
  74395. /**
  74396. * Triggered when new babylon (transformed) hit test results are available
  74397. */
  74398. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74399. /**
  74400. * Creates a new instance of the (legacy version) hit test feature
  74401. * @param _xrSessionManager an instance of WebXRSessionManager
  74402. * @param options options to use when constructing this feature
  74403. */
  74404. constructor(_xrSessionManager: WebXRSessionManager,
  74405. /**
  74406. * options to use when constructing this feature
  74407. */
  74408. options?: IWebXRLegacyHitTestOptions);
  74409. /**
  74410. * execute a hit test with an XR Ray
  74411. *
  74412. * @param xrSession a native xrSession that will execute this hit test
  74413. * @param xrRay the ray (position and direction) to use for ray-casting
  74414. * @param referenceSpace native XR reference space to use for the hit-test
  74415. * @param filter filter function that will filter the results
  74416. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74417. */
  74418. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74419. /**
  74420. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74421. * @param event the (select) event to use to select with
  74422. * @param referenceSpace the reference space to use for this hit test
  74423. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74424. */
  74425. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74426. /**
  74427. * attach this feature
  74428. * Will usually be called by the features manager
  74429. *
  74430. * @returns true if successful.
  74431. */
  74432. attach(): boolean;
  74433. /**
  74434. * detach this feature.
  74435. * Will usually be called by the features manager
  74436. *
  74437. * @returns true if successful.
  74438. */
  74439. detach(): boolean;
  74440. /**
  74441. * Dispose this feature and all of the resources attached
  74442. */
  74443. dispose(): void;
  74444. protected _onXRFrame(frame: XRFrame): void;
  74445. private _onHitTestResults;
  74446. private _onSelect;
  74447. }
  74448. }
  74449. declare module BABYLON {
  74450. /**
  74451. * Options used for hit testing (version 2)
  74452. */
  74453. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74454. /**
  74455. * Do not create a permanent hit test. Will usually be used when only
  74456. * transient inputs are needed.
  74457. */
  74458. disablePermanentHitTest?: boolean;
  74459. /**
  74460. * Enable transient (for example touch-based) hit test inspections
  74461. */
  74462. enableTransientHitTest?: boolean;
  74463. /**
  74464. * Offset ray for the permanent hit test
  74465. */
  74466. offsetRay?: Vector3;
  74467. /**
  74468. * Offset ray for the transient hit test
  74469. */
  74470. transientOffsetRay?: Vector3;
  74471. /**
  74472. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74473. */
  74474. useReferenceSpace?: boolean;
  74475. /**
  74476. * Override the default entity type(s) of the hit-test result
  74477. */
  74478. entityTypes?: XRHitTestTrackableType[];
  74479. }
  74480. /**
  74481. * Interface defining the babylon result of hit-test
  74482. */
  74483. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74484. /**
  74485. * The input source that generated this hit test (if transient)
  74486. */
  74487. inputSource?: XRInputSource;
  74488. /**
  74489. * Is this a transient hit test
  74490. */
  74491. isTransient?: boolean;
  74492. /**
  74493. * Position of the hit test result
  74494. */
  74495. position: Vector3;
  74496. /**
  74497. * Rotation of the hit test result
  74498. */
  74499. rotationQuaternion: Quaternion;
  74500. /**
  74501. * The native hit test result
  74502. */
  74503. xrHitResult: XRHitTestResult;
  74504. }
  74505. /**
  74506. * The currently-working hit-test module.
  74507. * Hit test (or Ray-casting) is used to interact with the real world.
  74508. * For further information read here - https://github.com/immersive-web/hit-test
  74509. *
  74510. * Tested on chrome (mobile) 80.
  74511. */
  74512. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74513. /**
  74514. * options to use when constructing this feature
  74515. */
  74516. readonly options: IWebXRHitTestOptions;
  74517. private _tmpMat;
  74518. private _tmpPos;
  74519. private _tmpQuat;
  74520. private _transientXrHitTestSource;
  74521. private _xrHitTestSource;
  74522. private initHitTestSource;
  74523. /**
  74524. * The module's name
  74525. */
  74526. static readonly Name: string;
  74527. /**
  74528. * The (Babylon) version of this module.
  74529. * This is an integer representing the implementation version.
  74530. * This number does not correspond to the WebXR specs version
  74531. */
  74532. static readonly Version: number;
  74533. /**
  74534. * When set to true, each hit test will have its own position/rotation objects
  74535. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74536. * the developers will clone them or copy them as they see fit.
  74537. */
  74538. autoCloneTransformation: boolean;
  74539. /**
  74540. * Triggered when new babylon (transformed) hit test results are available
  74541. * Note - this will be called when results come back from the device. It can be an empty array!!
  74542. */
  74543. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74544. /**
  74545. * Use this to temporarily pause hit test checks.
  74546. */
  74547. paused: boolean;
  74548. /**
  74549. * Creates a new instance of the hit test feature
  74550. * @param _xrSessionManager an instance of WebXRSessionManager
  74551. * @param options options to use when constructing this feature
  74552. */
  74553. constructor(_xrSessionManager: WebXRSessionManager,
  74554. /**
  74555. * options to use when constructing this feature
  74556. */
  74557. options?: IWebXRHitTestOptions);
  74558. /**
  74559. * attach this feature
  74560. * Will usually be called by the features manager
  74561. *
  74562. * @returns true if successful.
  74563. */
  74564. attach(): boolean;
  74565. /**
  74566. * detach this feature.
  74567. * Will usually be called by the features manager
  74568. *
  74569. * @returns true if successful.
  74570. */
  74571. detach(): boolean;
  74572. /**
  74573. * Dispose this feature and all of the resources attached
  74574. */
  74575. dispose(): void;
  74576. protected _onXRFrame(frame: XRFrame): void;
  74577. private _processWebXRHitTestResult;
  74578. }
  74579. }
  74580. declare module BABYLON {
  74581. /**
  74582. * Configuration options of the anchor system
  74583. */
  74584. export interface IWebXRAnchorSystemOptions {
  74585. /**
  74586. * a node that will be used to convert local to world coordinates
  74587. */
  74588. worldParentNode?: TransformNode;
  74589. /**
  74590. * If set to true a reference of the created anchors will be kept until the next session starts
  74591. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74592. */
  74593. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74594. }
  74595. /**
  74596. * A babylon container for an XR Anchor
  74597. */
  74598. export interface IWebXRAnchor {
  74599. /**
  74600. * A babylon-assigned ID for this anchor
  74601. */
  74602. id: number;
  74603. /**
  74604. * Transformation matrix to apply to an object attached to this anchor
  74605. */
  74606. transformationMatrix: Matrix;
  74607. /**
  74608. * The native anchor object
  74609. */
  74610. xrAnchor: XRAnchor;
  74611. /**
  74612. * if defined, this object will be constantly updated by the anchor's position and rotation
  74613. */
  74614. attachedNode?: TransformNode;
  74615. }
  74616. /**
  74617. * An implementation of the anchor system for WebXR.
  74618. * For further information see https://github.com/immersive-web/anchors/
  74619. */
  74620. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74621. private _options;
  74622. private _lastFrameDetected;
  74623. private _trackedAnchors;
  74624. private _referenceSpaceForFrameAnchors;
  74625. private _futureAnchors;
  74626. /**
  74627. * The module's name
  74628. */
  74629. static readonly Name: string;
  74630. /**
  74631. * The (Babylon) version of this module.
  74632. * This is an integer representing the implementation version.
  74633. * This number does not correspond to the WebXR specs version
  74634. */
  74635. static readonly Version: number;
  74636. /**
  74637. * Observers registered here will be executed when a new anchor was added to the session
  74638. */
  74639. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74640. /**
  74641. * Observers registered here will be executed when an anchor was removed from the session
  74642. */
  74643. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74644. /**
  74645. * Observers registered here will be executed when an existing anchor updates
  74646. * This can execute N times every frame
  74647. */
  74648. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74649. /**
  74650. * Set the reference space to use for anchor creation, when not using a hit test.
  74651. * Will default to the session's reference space if not defined
  74652. */
  74653. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74654. /**
  74655. * constructs a new anchor system
  74656. * @param _xrSessionManager an instance of WebXRSessionManager
  74657. * @param _options configuration object for this feature
  74658. */
  74659. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74660. private _tmpVector;
  74661. private _tmpQuaternion;
  74662. private _populateTmpTransformation;
  74663. /**
  74664. * Create a new anchor point using a hit test result at a specific point in the scene
  74665. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74666. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74667. *
  74668. * @param hitTestResult The hit test result to use for this anchor creation
  74669. * @param position an optional position offset for this anchor
  74670. * @param rotationQuaternion an optional rotation offset for this anchor
  74671. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74672. */
  74673. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74674. /**
  74675. * Add a new anchor at a specific position and rotation
  74676. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74677. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74678. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74679. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74680. *
  74681. * @param position the position in which to add an anchor
  74682. * @param rotationQuaternion an optional rotation for the anchor transformation
  74683. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74684. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74685. */
  74686. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74687. /**
  74688. * detach this feature.
  74689. * Will usually be called by the features manager
  74690. *
  74691. * @returns true if successful.
  74692. */
  74693. detach(): boolean;
  74694. /**
  74695. * Dispose this feature and all of the resources attached
  74696. */
  74697. dispose(): void;
  74698. protected _onXRFrame(frame: XRFrame): void;
  74699. /**
  74700. * avoiding using Array.find for global support.
  74701. * @param xrAnchor the plane to find in the array
  74702. */
  74703. private _findIndexInAnchorArray;
  74704. private _updateAnchorWithXRFrame;
  74705. private _createAnchorAtTransformation;
  74706. }
  74707. }
  74708. declare module BABYLON {
  74709. /**
  74710. * Options used in the plane detector module
  74711. */
  74712. export interface IWebXRPlaneDetectorOptions {
  74713. /**
  74714. * The node to use to transform the local results to world coordinates
  74715. */
  74716. worldParentNode?: TransformNode;
  74717. /**
  74718. * If set to true a reference of the created planes will be kept until the next session starts
  74719. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74720. */
  74721. doNotRemovePlanesOnSessionEnded?: boolean;
  74722. }
  74723. /**
  74724. * A babylon interface for a WebXR plane.
  74725. * A Plane is actually a polygon, built from N points in space
  74726. *
  74727. * Supported in chrome 79, not supported in canary 81 ATM
  74728. */
  74729. export interface IWebXRPlane {
  74730. /**
  74731. * a babylon-assigned ID for this polygon
  74732. */
  74733. id: number;
  74734. /**
  74735. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74736. */
  74737. polygonDefinition: Array<Vector3>;
  74738. /**
  74739. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74740. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74741. */
  74742. transformationMatrix: Matrix;
  74743. /**
  74744. * the native xr-plane object
  74745. */
  74746. xrPlane: XRPlane;
  74747. }
  74748. /**
  74749. * The plane detector is used to detect planes in the real world when in AR
  74750. * For more information see https://github.com/immersive-web/real-world-geometry/
  74751. */
  74752. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74753. private _options;
  74754. private _detectedPlanes;
  74755. private _enabled;
  74756. private _lastFrameDetected;
  74757. /**
  74758. * The module's name
  74759. */
  74760. static readonly Name: string;
  74761. /**
  74762. * The (Babylon) version of this module.
  74763. * This is an integer representing the implementation version.
  74764. * This number does not correspond to the WebXR specs version
  74765. */
  74766. static readonly Version: number;
  74767. /**
  74768. * Observers registered here will be executed when a new plane was added to the session
  74769. */
  74770. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74771. /**
  74772. * Observers registered here will be executed when a plane is no longer detected in the session
  74773. */
  74774. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74775. /**
  74776. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74777. * This can execute N times every frame
  74778. */
  74779. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74780. /**
  74781. * construct a new Plane Detector
  74782. * @param _xrSessionManager an instance of xr Session manager
  74783. * @param _options configuration to use when constructing this feature
  74784. */
  74785. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74786. /**
  74787. * detach this feature.
  74788. * Will usually be called by the features manager
  74789. *
  74790. * @returns true if successful.
  74791. */
  74792. detach(): boolean;
  74793. /**
  74794. * Dispose this feature and all of the resources attached
  74795. */
  74796. dispose(): void;
  74797. protected _onXRFrame(frame: XRFrame): void;
  74798. private _init;
  74799. private _updatePlaneWithXRPlane;
  74800. /**
  74801. * avoiding using Array.find for global support.
  74802. * @param xrPlane the plane to find in the array
  74803. */
  74804. private findIndexInPlaneArray;
  74805. }
  74806. }
  74807. declare module BABYLON {
  74808. /**
  74809. * Options interface for the background remover plugin
  74810. */
  74811. export interface IWebXRBackgroundRemoverOptions {
  74812. /**
  74813. * Further background meshes to disable when entering AR
  74814. */
  74815. backgroundMeshes?: AbstractMesh[];
  74816. /**
  74817. * flags to configure the removal of the environment helper.
  74818. * If not set, the entire background will be removed. If set, flags should be set as well.
  74819. */
  74820. environmentHelperRemovalFlags?: {
  74821. /**
  74822. * Should the skybox be removed (default false)
  74823. */
  74824. skyBox?: boolean;
  74825. /**
  74826. * Should the ground be removed (default false)
  74827. */
  74828. ground?: boolean;
  74829. };
  74830. /**
  74831. * don't disable the environment helper
  74832. */
  74833. ignoreEnvironmentHelper?: boolean;
  74834. }
  74835. /**
  74836. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74837. */
  74838. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74839. /**
  74840. * read-only options to be used in this module
  74841. */
  74842. readonly options: IWebXRBackgroundRemoverOptions;
  74843. /**
  74844. * The module's name
  74845. */
  74846. static readonly Name: string;
  74847. /**
  74848. * The (Babylon) version of this module.
  74849. * This is an integer representing the implementation version.
  74850. * This number does not correspond to the WebXR specs version
  74851. */
  74852. static readonly Version: number;
  74853. /**
  74854. * registered observers will be triggered when the background state changes
  74855. */
  74856. onBackgroundStateChangedObservable: Observable<boolean>;
  74857. /**
  74858. * constructs a new background remover module
  74859. * @param _xrSessionManager the session manager for this module
  74860. * @param options read-only options to be used in this module
  74861. */
  74862. constructor(_xrSessionManager: WebXRSessionManager,
  74863. /**
  74864. * read-only options to be used in this module
  74865. */
  74866. options?: IWebXRBackgroundRemoverOptions);
  74867. /**
  74868. * attach this feature
  74869. * Will usually be called by the features manager
  74870. *
  74871. * @returns true if successful.
  74872. */
  74873. attach(): boolean;
  74874. /**
  74875. * detach this feature.
  74876. * Will usually be called by the features manager
  74877. *
  74878. * @returns true if successful.
  74879. */
  74880. detach(): boolean;
  74881. /**
  74882. * Dispose this feature and all of the resources attached
  74883. */
  74884. dispose(): void;
  74885. protected _onXRFrame(_xrFrame: XRFrame): void;
  74886. private _setBackgroundState;
  74887. }
  74888. }
  74889. declare module BABYLON {
  74890. /**
  74891. * Options for the controller physics feature
  74892. */
  74893. export class IWebXRControllerPhysicsOptions {
  74894. /**
  74895. * Should the headset get its own impostor
  74896. */
  74897. enableHeadsetImpostor?: boolean;
  74898. /**
  74899. * Optional parameters for the headset impostor
  74900. */
  74901. headsetImpostorParams?: {
  74902. /**
  74903. * The type of impostor to create. Default is sphere
  74904. */
  74905. impostorType: number;
  74906. /**
  74907. * the size of the impostor. Defaults to 10cm
  74908. */
  74909. impostorSize?: number | {
  74910. width: number;
  74911. height: number;
  74912. depth: number;
  74913. };
  74914. /**
  74915. * Friction definitions
  74916. */
  74917. friction?: number;
  74918. /**
  74919. * Restitution
  74920. */
  74921. restitution?: number;
  74922. };
  74923. /**
  74924. * The physics properties of the future impostors
  74925. */
  74926. physicsProperties?: {
  74927. /**
  74928. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74929. * Note that this requires a physics engine that supports mesh impostors!
  74930. */
  74931. useControllerMesh?: boolean;
  74932. /**
  74933. * The type of impostor to create. Default is sphere
  74934. */
  74935. impostorType?: number;
  74936. /**
  74937. * the size of the impostor. Defaults to 10cm
  74938. */
  74939. impostorSize?: number | {
  74940. width: number;
  74941. height: number;
  74942. depth: number;
  74943. };
  74944. /**
  74945. * Friction definitions
  74946. */
  74947. friction?: number;
  74948. /**
  74949. * Restitution
  74950. */
  74951. restitution?: number;
  74952. };
  74953. /**
  74954. * the xr input to use with this pointer selection
  74955. */
  74956. xrInput: WebXRInput;
  74957. }
  74958. /**
  74959. * Add physics impostor to your webxr controllers,
  74960. * including naive calculation of their linear and angular velocity
  74961. */
  74962. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74963. private readonly _options;
  74964. private _attachController;
  74965. private _controllers;
  74966. private _debugMode;
  74967. private _delta;
  74968. private _headsetImpostor?;
  74969. private _headsetMesh?;
  74970. private _lastTimestamp;
  74971. private _tmpQuaternion;
  74972. private _tmpVector;
  74973. /**
  74974. * The module's name
  74975. */
  74976. static readonly Name: string;
  74977. /**
  74978. * The (Babylon) version of this module.
  74979. * This is an integer representing the implementation version.
  74980. * This number does not correspond to the webxr specs version
  74981. */
  74982. static readonly Version: number;
  74983. /**
  74984. * Construct a new Controller Physics Feature
  74985. * @param _xrSessionManager the corresponding xr session manager
  74986. * @param _options options to create this feature with
  74987. */
  74988. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74989. /**
  74990. * @hidden
  74991. * enable debugging - will show console outputs and the impostor mesh
  74992. */
  74993. _enablePhysicsDebug(): void;
  74994. /**
  74995. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74996. * @param xrController the controller to add
  74997. */
  74998. addController(xrController: WebXRInputSource): void;
  74999. /**
  75000. * attach this feature
  75001. * Will usually be called by the features manager
  75002. *
  75003. * @returns true if successful.
  75004. */
  75005. attach(): boolean;
  75006. /**
  75007. * detach this feature.
  75008. * Will usually be called by the features manager
  75009. *
  75010. * @returns true if successful.
  75011. */
  75012. detach(): boolean;
  75013. /**
  75014. * Get the headset impostor, if enabled
  75015. * @returns the impostor
  75016. */
  75017. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75018. /**
  75019. * Get the physics impostor of a specific controller.
  75020. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75021. * @param controller the controller or the controller id of which to get the impostor
  75022. * @returns the impostor or null
  75023. */
  75024. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75025. /**
  75026. * Update the physics properties provided in the constructor
  75027. * @param newProperties the new properties object
  75028. */
  75029. setPhysicsProperties(newProperties: {
  75030. impostorType?: number;
  75031. impostorSize?: number | {
  75032. width: number;
  75033. height: number;
  75034. depth: number;
  75035. };
  75036. friction?: number;
  75037. restitution?: number;
  75038. }): void;
  75039. protected _onXRFrame(_xrFrame: any): void;
  75040. private _detachController;
  75041. }
  75042. }
  75043. declare module BABYLON {
  75044. /**
  75045. * A babylon interface for a "WebXR" feature point.
  75046. * Represents the position and confidence value of a given feature point.
  75047. */
  75048. export interface IWebXRFeaturePoint {
  75049. /**
  75050. * Represents the position of the feature point in world space.
  75051. */
  75052. position: Vector3;
  75053. /**
  75054. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75055. */
  75056. confidenceValue: number;
  75057. }
  75058. /**
  75059. * The feature point system is used to detect feature points from real world geometry.
  75060. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75061. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75062. */
  75063. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75064. private _enabled;
  75065. private _featurePointCloud;
  75066. /**
  75067. * The module's name
  75068. */
  75069. static readonly Name: string;
  75070. /**
  75071. * The (Babylon) version of this module.
  75072. * This is an integer representing the implementation version.
  75073. * This number does not correspond to the WebXR specs version
  75074. */
  75075. static readonly Version: number;
  75076. /**
  75077. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75078. * Will notify the observers about which feature points have been added.
  75079. */
  75080. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75081. /**
  75082. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75083. * Will notify the observers about which feature points have been updated.
  75084. */
  75085. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75086. /**
  75087. * The current feature point cloud maintained across frames.
  75088. */
  75089. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75090. /**
  75091. * construct the feature point system
  75092. * @param _xrSessionManager an instance of xr Session manager
  75093. */
  75094. constructor(_xrSessionManager: WebXRSessionManager);
  75095. /**
  75096. * Detach this feature.
  75097. * Will usually be called by the features manager
  75098. *
  75099. * @returns true if successful.
  75100. */
  75101. detach(): boolean;
  75102. /**
  75103. * Dispose this feature and all of the resources attached
  75104. */
  75105. dispose(): void;
  75106. /**
  75107. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75108. */
  75109. protected _onXRFrame(frame: XRFrame): void;
  75110. /**
  75111. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75112. */
  75113. private _init;
  75114. }
  75115. }
  75116. declare module BABYLON {
  75117. /**
  75118. * Configuration interface for the hand tracking feature
  75119. */
  75120. export interface IWebXRHandTrackingOptions {
  75121. /**
  75122. * The xrInput that will be used as source for new hands
  75123. */
  75124. xrInput: WebXRInput;
  75125. /**
  75126. * Configuration object for the joint meshes
  75127. */
  75128. jointMeshes?: {
  75129. /**
  75130. * Should the meshes created be invisible (defaults to false)
  75131. */
  75132. invisible?: boolean;
  75133. /**
  75134. * A source mesh to be used to create instances. Defaults to a sphere.
  75135. * This mesh will be the source for all other (25) meshes.
  75136. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75137. */
  75138. sourceMesh?: Mesh;
  75139. /**
  75140. * Should the source mesh stay visible. Defaults to false
  75141. */
  75142. keepOriginalVisible?: boolean;
  75143. /**
  75144. * Scale factor for all instances (defaults to 2)
  75145. */
  75146. scaleFactor?: number;
  75147. /**
  75148. * Should each instance have its own physics impostor
  75149. */
  75150. enablePhysics?: boolean;
  75151. /**
  75152. * If enabled, override default physics properties
  75153. */
  75154. physicsProps?: {
  75155. friction?: number;
  75156. restitution?: number;
  75157. impostorType?: number;
  75158. };
  75159. /**
  75160. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75161. */
  75162. handMesh?: AbstractMesh;
  75163. };
  75164. }
  75165. /**
  75166. * Parts of the hands divided to writs and finger names
  75167. */
  75168. export const enum HandPart {
  75169. /**
  75170. * HandPart - Wrist
  75171. */
  75172. WRIST = "wrist",
  75173. /**
  75174. * HandPart - The THumb
  75175. */
  75176. THUMB = "thumb",
  75177. /**
  75178. * HandPart - Index finger
  75179. */
  75180. INDEX = "index",
  75181. /**
  75182. * HandPart - Middle finger
  75183. */
  75184. MIDDLE = "middle",
  75185. /**
  75186. * HandPart - Ring finger
  75187. */
  75188. RING = "ring",
  75189. /**
  75190. * HandPart - Little finger
  75191. */
  75192. LITTLE = "little"
  75193. }
  75194. /**
  75195. * Representing a single hand (with its corresponding native XRHand object)
  75196. */
  75197. export class WebXRHand implements IDisposable {
  75198. /** the controller to which the hand correlates */
  75199. readonly xrController: WebXRInputSource;
  75200. /** the meshes to be used to track the hand joints */
  75201. readonly trackedMeshes: AbstractMesh[];
  75202. /**
  75203. * Hand-parts definition (key is HandPart)
  75204. */
  75205. handPartsDefinition: {
  75206. [key: string]: number[];
  75207. };
  75208. /**
  75209. * Populate the HandPartsDefinition object.
  75210. * This is called as a side effect since certain browsers don't have XRHand defined.
  75211. */
  75212. private generateHandPartsDefinition;
  75213. /**
  75214. * Construct a new hand object
  75215. * @param xrController the controller to which the hand correlates
  75216. * @param trackedMeshes the meshes to be used to track the hand joints
  75217. */
  75218. constructor(
  75219. /** the controller to which the hand correlates */
  75220. xrController: WebXRInputSource,
  75221. /** the meshes to be used to track the hand joints */
  75222. trackedMeshes: AbstractMesh[]);
  75223. /**
  75224. * Update this hand from the latest xr frame
  75225. * @param xrFrame xrFrame to update from
  75226. * @param referenceSpace The current viewer reference space
  75227. * @param scaleFactor optional scale factor for the meshes
  75228. */
  75229. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75230. /**
  75231. * Get meshes of part of the hand
  75232. * @param part the part of hand to get
  75233. * @returns An array of meshes that correlate to the hand part requested
  75234. */
  75235. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75236. /**
  75237. * Dispose this Hand object
  75238. */
  75239. dispose(): void;
  75240. }
  75241. /**
  75242. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75243. */
  75244. export class WebXRHandTracking extends WebXRAbstractFeature {
  75245. /**
  75246. * options to use when constructing this feature
  75247. */
  75248. readonly options: IWebXRHandTrackingOptions;
  75249. private static _idCounter;
  75250. /**
  75251. * The module's name
  75252. */
  75253. static readonly Name: string;
  75254. /**
  75255. * The (Babylon) version of this module.
  75256. * This is an integer representing the implementation version.
  75257. * This number does not correspond to the WebXR specs version
  75258. */
  75259. static readonly Version: number;
  75260. /**
  75261. * This observable will notify registered observers when a new hand object was added and initialized
  75262. */
  75263. onHandAddedObservable: Observable<WebXRHand>;
  75264. /**
  75265. * This observable will notify its observers right before the hand object is disposed
  75266. */
  75267. onHandRemovedObservable: Observable<WebXRHand>;
  75268. private _hands;
  75269. /**
  75270. * Creates a new instance of the hit test feature
  75271. * @param _xrSessionManager an instance of WebXRSessionManager
  75272. * @param options options to use when constructing this feature
  75273. */
  75274. constructor(_xrSessionManager: WebXRSessionManager,
  75275. /**
  75276. * options to use when constructing this feature
  75277. */
  75278. options: IWebXRHandTrackingOptions);
  75279. /**
  75280. * Check if the needed objects are defined.
  75281. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75282. */
  75283. isCompatible(): boolean;
  75284. /**
  75285. * attach this feature
  75286. * Will usually be called by the features manager
  75287. *
  75288. * @returns true if successful.
  75289. */
  75290. attach(): boolean;
  75291. /**
  75292. * detach this feature.
  75293. * Will usually be called by the features manager
  75294. *
  75295. * @returns true if successful.
  75296. */
  75297. detach(): boolean;
  75298. /**
  75299. * Dispose this feature and all of the resources attached
  75300. */
  75301. dispose(): void;
  75302. /**
  75303. * Get the hand object according to the controller id
  75304. * @param controllerId the controller id to which we want to get the hand
  75305. * @returns null if not found or the WebXRHand object if found
  75306. */
  75307. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75308. /**
  75309. * Get a hand object according to the requested handedness
  75310. * @param handedness the handedness to request
  75311. * @returns null if not found or the WebXRHand object if found
  75312. */
  75313. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75314. protected _onXRFrame(_xrFrame: XRFrame): void;
  75315. private _attachHand;
  75316. private _detachHand;
  75317. }
  75318. }
  75319. declare module BABYLON {
  75320. /**
  75321. * The motion controller class for all microsoft mixed reality controllers
  75322. */
  75323. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75324. protected readonly _mapping: {
  75325. defaultButton: {
  75326. valueNodeName: string;
  75327. unpressedNodeName: string;
  75328. pressedNodeName: string;
  75329. };
  75330. defaultAxis: {
  75331. valueNodeName: string;
  75332. minNodeName: string;
  75333. maxNodeName: string;
  75334. };
  75335. buttons: {
  75336. "xr-standard-trigger": {
  75337. rootNodeName: string;
  75338. componentProperty: string;
  75339. states: string[];
  75340. };
  75341. "xr-standard-squeeze": {
  75342. rootNodeName: string;
  75343. componentProperty: string;
  75344. states: string[];
  75345. };
  75346. "xr-standard-touchpad": {
  75347. rootNodeName: string;
  75348. labelAnchorNodeName: string;
  75349. touchPointNodeName: string;
  75350. };
  75351. "xr-standard-thumbstick": {
  75352. rootNodeName: string;
  75353. componentProperty: string;
  75354. states: string[];
  75355. };
  75356. };
  75357. axes: {
  75358. "xr-standard-touchpad": {
  75359. "x-axis": {
  75360. rootNodeName: string;
  75361. };
  75362. "y-axis": {
  75363. rootNodeName: string;
  75364. };
  75365. };
  75366. "xr-standard-thumbstick": {
  75367. "x-axis": {
  75368. rootNodeName: string;
  75369. };
  75370. "y-axis": {
  75371. rootNodeName: string;
  75372. };
  75373. };
  75374. };
  75375. };
  75376. /**
  75377. * The base url used to load the left and right controller models
  75378. */
  75379. static MODEL_BASE_URL: string;
  75380. /**
  75381. * The name of the left controller model file
  75382. */
  75383. static MODEL_LEFT_FILENAME: string;
  75384. /**
  75385. * The name of the right controller model file
  75386. */
  75387. static MODEL_RIGHT_FILENAME: string;
  75388. profileId: string;
  75389. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75390. protected _getFilenameAndPath(): {
  75391. filename: string;
  75392. path: string;
  75393. };
  75394. protected _getModelLoadingConstraints(): boolean;
  75395. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75396. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75397. protected _updateModel(): void;
  75398. }
  75399. }
  75400. declare module BABYLON {
  75401. /**
  75402. * The motion controller class for oculus touch (quest, rift).
  75403. * This class supports legacy mapping as well the standard xr mapping
  75404. */
  75405. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75406. private _forceLegacyControllers;
  75407. private _modelRootNode;
  75408. /**
  75409. * The base url used to load the left and right controller models
  75410. */
  75411. static MODEL_BASE_URL: string;
  75412. /**
  75413. * The name of the left controller model file
  75414. */
  75415. static MODEL_LEFT_FILENAME: string;
  75416. /**
  75417. * The name of the right controller model file
  75418. */
  75419. static MODEL_RIGHT_FILENAME: string;
  75420. /**
  75421. * Base Url for the Quest controller model.
  75422. */
  75423. static QUEST_MODEL_BASE_URL: string;
  75424. profileId: string;
  75425. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75426. protected _getFilenameAndPath(): {
  75427. filename: string;
  75428. path: string;
  75429. };
  75430. protected _getModelLoadingConstraints(): boolean;
  75431. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75432. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75433. protected _updateModel(): void;
  75434. /**
  75435. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75436. * between the touch and touch 2.
  75437. */
  75438. private _isQuest;
  75439. }
  75440. }
  75441. declare module BABYLON {
  75442. /**
  75443. * The motion controller class for the standard HTC-Vive controllers
  75444. */
  75445. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75446. private _modelRootNode;
  75447. /**
  75448. * The base url used to load the left and right controller models
  75449. */
  75450. static MODEL_BASE_URL: string;
  75451. /**
  75452. * File name for the controller model.
  75453. */
  75454. static MODEL_FILENAME: string;
  75455. profileId: string;
  75456. /**
  75457. * Create a new Vive motion controller object
  75458. * @param scene the scene to use to create this controller
  75459. * @param gamepadObject the corresponding gamepad object
  75460. * @param handedness the handedness of the controller
  75461. */
  75462. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75463. protected _getFilenameAndPath(): {
  75464. filename: string;
  75465. path: string;
  75466. };
  75467. protected _getModelLoadingConstraints(): boolean;
  75468. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75469. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75470. protected _updateModel(): void;
  75471. }
  75472. }
  75473. declare module BABYLON {
  75474. /**
  75475. * A cursor which tracks a point on a path
  75476. */
  75477. export class PathCursor {
  75478. private path;
  75479. /**
  75480. * Stores path cursor callbacks for when an onchange event is triggered
  75481. */
  75482. private _onchange;
  75483. /**
  75484. * The value of the path cursor
  75485. */
  75486. value: number;
  75487. /**
  75488. * The animation array of the path cursor
  75489. */
  75490. animations: Animation[];
  75491. /**
  75492. * Initializes the path cursor
  75493. * @param path The path to track
  75494. */
  75495. constructor(path: Path2);
  75496. /**
  75497. * Gets the cursor point on the path
  75498. * @returns A point on the path cursor at the cursor location
  75499. */
  75500. getPoint(): Vector3;
  75501. /**
  75502. * Moves the cursor ahead by the step amount
  75503. * @param step The amount to move the cursor forward
  75504. * @returns This path cursor
  75505. */
  75506. moveAhead(step?: number): PathCursor;
  75507. /**
  75508. * Moves the cursor behind by the step amount
  75509. * @param step The amount to move the cursor back
  75510. * @returns This path cursor
  75511. */
  75512. moveBack(step?: number): PathCursor;
  75513. /**
  75514. * Moves the cursor by the step amount
  75515. * If the step amount is greater than one, an exception is thrown
  75516. * @param step The amount to move the cursor
  75517. * @returns This path cursor
  75518. */
  75519. move(step: number): PathCursor;
  75520. /**
  75521. * Ensures that the value is limited between zero and one
  75522. * @returns This path cursor
  75523. */
  75524. private ensureLimits;
  75525. /**
  75526. * Runs onchange callbacks on change (used by the animation engine)
  75527. * @returns This path cursor
  75528. */
  75529. private raiseOnChange;
  75530. /**
  75531. * Executes a function on change
  75532. * @param f A path cursor onchange callback
  75533. * @returns This path cursor
  75534. */
  75535. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75536. }
  75537. }
  75538. declare module BABYLON {
  75539. /** @hidden */
  75540. export var blurPixelShader: {
  75541. name: string;
  75542. shader: string;
  75543. };
  75544. }
  75545. declare module BABYLON {
  75546. /** @hidden */
  75547. export var pointCloudVertexDeclaration: {
  75548. name: string;
  75549. shader: string;
  75550. };
  75551. }
  75552. // Mixins
  75553. interface Window {
  75554. mozIndexedDB: IDBFactory;
  75555. webkitIndexedDB: IDBFactory;
  75556. msIndexedDB: IDBFactory;
  75557. webkitURL: typeof URL;
  75558. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75559. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75560. WebGLRenderingContext: WebGLRenderingContext;
  75561. MSGesture: MSGesture;
  75562. CANNON: any;
  75563. AudioContext: AudioContext;
  75564. webkitAudioContext: AudioContext;
  75565. PointerEvent: any;
  75566. Math: Math;
  75567. Uint8Array: Uint8ArrayConstructor;
  75568. Float32Array: Float32ArrayConstructor;
  75569. mozURL: typeof URL;
  75570. msURL: typeof URL;
  75571. VRFrameData: any; // WebVR, from specs 1.1
  75572. DracoDecoderModule: any;
  75573. setImmediate(handler: (...args: any[]) => void): number;
  75574. }
  75575. interface HTMLCanvasElement {
  75576. requestPointerLock(): void;
  75577. msRequestPointerLock?(): void;
  75578. mozRequestPointerLock?(): void;
  75579. webkitRequestPointerLock?(): void;
  75580. /** Track wether a record is in progress */
  75581. isRecording: boolean;
  75582. /** Capture Stream method defined by some browsers */
  75583. captureStream(fps?: number): MediaStream;
  75584. }
  75585. interface CanvasRenderingContext2D {
  75586. msImageSmoothingEnabled: boolean;
  75587. }
  75588. interface MouseEvent {
  75589. mozMovementX: number;
  75590. mozMovementY: number;
  75591. webkitMovementX: number;
  75592. webkitMovementY: number;
  75593. msMovementX: number;
  75594. msMovementY: number;
  75595. }
  75596. interface Navigator {
  75597. mozGetVRDevices: (any: any) => any;
  75598. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75599. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75600. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75601. webkitGetGamepads(): Gamepad[];
  75602. msGetGamepads(): Gamepad[];
  75603. webkitGamepads(): Gamepad[];
  75604. }
  75605. interface HTMLVideoElement {
  75606. mozSrcObject: any;
  75607. }
  75608. interface Math {
  75609. fround(x: number): number;
  75610. imul(a: number, b: number): number;
  75611. }
  75612. interface WebGLRenderingContext {
  75613. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75614. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75615. vertexAttribDivisor(index: number, divisor: number): void;
  75616. createVertexArray(): any;
  75617. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75618. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75619. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75620. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75621. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75622. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75623. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75624. // Queries
  75625. createQuery(): WebGLQuery;
  75626. deleteQuery(query: WebGLQuery): void;
  75627. beginQuery(target: number, query: WebGLQuery): void;
  75628. endQuery(target: number): void;
  75629. getQueryParameter(query: WebGLQuery, pname: number): any;
  75630. getQuery(target: number, pname: number): any;
  75631. MAX_SAMPLES: number;
  75632. RGBA8: number;
  75633. READ_FRAMEBUFFER: number;
  75634. DRAW_FRAMEBUFFER: number;
  75635. UNIFORM_BUFFER: number;
  75636. HALF_FLOAT_OES: number;
  75637. RGBA16F: number;
  75638. RGBA32F: number;
  75639. R32F: number;
  75640. RG32F: number;
  75641. RGB32F: number;
  75642. R16F: number;
  75643. RG16F: number;
  75644. RGB16F: number;
  75645. RED: number;
  75646. RG: number;
  75647. R8: number;
  75648. RG8: number;
  75649. UNSIGNED_INT_24_8: number;
  75650. DEPTH24_STENCIL8: number;
  75651. MIN: number;
  75652. MAX: number;
  75653. /* Multiple Render Targets */
  75654. drawBuffers(buffers: number[]): void;
  75655. readBuffer(src: number): void;
  75656. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75657. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75658. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75659. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75660. // Occlusion Query
  75661. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75662. ANY_SAMPLES_PASSED: number;
  75663. QUERY_RESULT_AVAILABLE: number;
  75664. QUERY_RESULT: number;
  75665. }
  75666. interface WebGLProgram {
  75667. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75668. }
  75669. interface EXT_disjoint_timer_query {
  75670. QUERY_COUNTER_BITS_EXT: number;
  75671. TIME_ELAPSED_EXT: number;
  75672. TIMESTAMP_EXT: number;
  75673. GPU_DISJOINT_EXT: number;
  75674. QUERY_RESULT_EXT: number;
  75675. QUERY_RESULT_AVAILABLE_EXT: number;
  75676. queryCounterEXT(query: WebGLQuery, target: number): void;
  75677. createQueryEXT(): WebGLQuery;
  75678. beginQueryEXT(target: number, query: WebGLQuery): void;
  75679. endQueryEXT(target: number): void;
  75680. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75681. deleteQueryEXT(query: WebGLQuery): void;
  75682. }
  75683. interface WebGLUniformLocation {
  75684. _currentState: any;
  75685. }
  75686. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75687. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75688. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75689. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75690. interface WebGLRenderingContext {
  75691. readonly RASTERIZER_DISCARD: number;
  75692. readonly DEPTH_COMPONENT24: number;
  75693. readonly TEXTURE_3D: number;
  75694. readonly TEXTURE_2D_ARRAY: number;
  75695. readonly TEXTURE_COMPARE_FUNC: number;
  75696. readonly TEXTURE_COMPARE_MODE: number;
  75697. readonly COMPARE_REF_TO_TEXTURE: number;
  75698. readonly TEXTURE_WRAP_R: number;
  75699. readonly HALF_FLOAT: number;
  75700. readonly RGB8: number;
  75701. readonly RED_INTEGER: number;
  75702. readonly RG_INTEGER: number;
  75703. readonly RGB_INTEGER: number;
  75704. readonly RGBA_INTEGER: number;
  75705. readonly R8_SNORM: number;
  75706. readonly RG8_SNORM: number;
  75707. readonly RGB8_SNORM: number;
  75708. readonly RGBA8_SNORM: number;
  75709. readonly R8I: number;
  75710. readonly RG8I: number;
  75711. readonly RGB8I: number;
  75712. readonly RGBA8I: number;
  75713. readonly R8UI: number;
  75714. readonly RG8UI: number;
  75715. readonly RGB8UI: number;
  75716. readonly RGBA8UI: number;
  75717. readonly R16I: number;
  75718. readonly RG16I: number;
  75719. readonly RGB16I: number;
  75720. readonly RGBA16I: number;
  75721. readonly R16UI: number;
  75722. readonly RG16UI: number;
  75723. readonly RGB16UI: number;
  75724. readonly RGBA16UI: number;
  75725. readonly R32I: number;
  75726. readonly RG32I: number;
  75727. readonly RGB32I: number;
  75728. readonly RGBA32I: number;
  75729. readonly R32UI: number;
  75730. readonly RG32UI: number;
  75731. readonly RGB32UI: number;
  75732. readonly RGBA32UI: number;
  75733. readonly RGB10_A2UI: number;
  75734. readonly R11F_G11F_B10F: number;
  75735. readonly RGB9_E5: number;
  75736. readonly RGB10_A2: number;
  75737. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75738. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75739. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75740. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75741. readonly DEPTH_COMPONENT32F: number;
  75742. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75743. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75744. 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;
  75745. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75746. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75747. readonly TRANSFORM_FEEDBACK: number;
  75748. readonly INTERLEAVED_ATTRIBS: number;
  75749. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75750. createTransformFeedback(): WebGLTransformFeedback;
  75751. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75752. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75753. beginTransformFeedback(primitiveMode: number): void;
  75754. endTransformFeedback(): void;
  75755. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75756. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75757. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75758. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75759. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75760. }
  75761. interface ImageBitmap {
  75762. readonly width: number;
  75763. readonly height: number;
  75764. close(): void;
  75765. }
  75766. interface WebGLQuery extends WebGLObject {
  75767. }
  75768. declare var WebGLQuery: {
  75769. prototype: WebGLQuery;
  75770. new(): WebGLQuery;
  75771. };
  75772. interface WebGLSampler extends WebGLObject {
  75773. }
  75774. declare var WebGLSampler: {
  75775. prototype: WebGLSampler;
  75776. new(): WebGLSampler;
  75777. };
  75778. interface WebGLSync extends WebGLObject {
  75779. }
  75780. declare var WebGLSync: {
  75781. prototype: WebGLSync;
  75782. new(): WebGLSync;
  75783. };
  75784. interface WebGLTransformFeedback extends WebGLObject {
  75785. }
  75786. declare var WebGLTransformFeedback: {
  75787. prototype: WebGLTransformFeedback;
  75788. new(): WebGLTransformFeedback;
  75789. };
  75790. interface WebGLVertexArrayObject extends WebGLObject {
  75791. }
  75792. declare var WebGLVertexArrayObject: {
  75793. prototype: WebGLVertexArrayObject;
  75794. new(): WebGLVertexArrayObject;
  75795. };
  75796. // Type definitions for WebVR API
  75797. // Project: https://w3c.github.io/webvr/
  75798. // Definitions by: six a <https://github.com/lostfictions>
  75799. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75800. interface VRDisplay extends EventTarget {
  75801. /**
  75802. * Dictionary of capabilities describing the VRDisplay.
  75803. */
  75804. readonly capabilities: VRDisplayCapabilities;
  75805. /**
  75806. * z-depth defining the far plane of the eye view frustum
  75807. * enables mapping of values in the render target depth
  75808. * attachment to scene coordinates. Initially set to 10000.0.
  75809. */
  75810. depthFar: number;
  75811. /**
  75812. * z-depth defining the near plane of the eye view frustum
  75813. * enables mapping of values in the render target depth
  75814. * attachment to scene coordinates. Initially set to 0.01.
  75815. */
  75816. depthNear: number;
  75817. /**
  75818. * An identifier for this distinct VRDisplay. Used as an
  75819. * association point in the Gamepad API.
  75820. */
  75821. readonly displayId: number;
  75822. /**
  75823. * A display name, a user-readable name identifying it.
  75824. */
  75825. readonly displayName: string;
  75826. readonly isConnected: boolean;
  75827. readonly isPresenting: boolean;
  75828. /**
  75829. * If this VRDisplay supports room-scale experiences, the optional
  75830. * stage attribute contains details on the room-scale parameters.
  75831. */
  75832. readonly stageParameters: VRStageParameters | null;
  75833. /**
  75834. * Passing the value returned by `requestAnimationFrame` to
  75835. * `cancelAnimationFrame` will unregister the callback.
  75836. * @param handle Define the hanle of the request to cancel
  75837. */
  75838. cancelAnimationFrame(handle: number): void;
  75839. /**
  75840. * Stops presenting to the VRDisplay.
  75841. * @returns a promise to know when it stopped
  75842. */
  75843. exitPresent(): Promise<void>;
  75844. /**
  75845. * Return the current VREyeParameters for the given eye.
  75846. * @param whichEye Define the eye we want the parameter for
  75847. * @returns the eye parameters
  75848. */
  75849. getEyeParameters(whichEye: string): VREyeParameters;
  75850. /**
  75851. * Populates the passed VRFrameData with the information required to render
  75852. * the current frame.
  75853. * @param frameData Define the data structure to populate
  75854. * @returns true if ok otherwise false
  75855. */
  75856. getFrameData(frameData: VRFrameData): boolean;
  75857. /**
  75858. * Get the layers currently being presented.
  75859. * @returns the list of VR layers
  75860. */
  75861. getLayers(): VRLayer[];
  75862. /**
  75863. * Return a VRPose containing the future predicted pose of the VRDisplay
  75864. * when the current frame will be presented. The value returned will not
  75865. * change until JavaScript has returned control to the browser.
  75866. *
  75867. * The VRPose will contain the position, orientation, velocity,
  75868. * and acceleration of each of these properties.
  75869. * @returns the pose object
  75870. */
  75871. getPose(): VRPose;
  75872. /**
  75873. * Return the current instantaneous pose of the VRDisplay, with no
  75874. * prediction applied.
  75875. * @returns the current instantaneous pose
  75876. */
  75877. getImmediatePose(): VRPose;
  75878. /**
  75879. * The callback passed to `requestAnimationFrame` will be called
  75880. * any time a new frame should be rendered. When the VRDisplay is
  75881. * presenting the callback will be called at the native refresh
  75882. * rate of the HMD. When not presenting this function acts
  75883. * identically to how window.requestAnimationFrame acts. Content should
  75884. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75885. * asynchronously from other displays and at differing refresh rates.
  75886. * @param callback Define the eaction to run next frame
  75887. * @returns the request handle it
  75888. */
  75889. requestAnimationFrame(callback: FrameRequestCallback): number;
  75890. /**
  75891. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75892. * Repeat calls while already presenting will update the VRLayers being displayed.
  75893. * @param layers Define the list of layer to present
  75894. * @returns a promise to know when the request has been fulfilled
  75895. */
  75896. requestPresent(layers: VRLayer[]): Promise<void>;
  75897. /**
  75898. * Reset the pose for this display, treating its current position and
  75899. * orientation as the "origin/zero" values. VRPose.position,
  75900. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75901. * updated when calling resetPose(). This should be called in only
  75902. * sitting-space experiences.
  75903. */
  75904. resetPose(): void;
  75905. /**
  75906. * The VRLayer provided to the VRDisplay will be captured and presented
  75907. * in the HMD. Calling this function has the same effect on the source
  75908. * canvas as any other operation that uses its source image, and canvases
  75909. * created without preserveDrawingBuffer set to true will be cleared.
  75910. * @param pose Define the pose to submit
  75911. */
  75912. submitFrame(pose?: VRPose): void;
  75913. }
  75914. declare var VRDisplay: {
  75915. prototype: VRDisplay;
  75916. new(): VRDisplay;
  75917. };
  75918. interface VRLayer {
  75919. leftBounds?: number[] | Float32Array | null;
  75920. rightBounds?: number[] | Float32Array | null;
  75921. source?: HTMLCanvasElement | null;
  75922. }
  75923. interface VRDisplayCapabilities {
  75924. readonly canPresent: boolean;
  75925. readonly hasExternalDisplay: boolean;
  75926. readonly hasOrientation: boolean;
  75927. readonly hasPosition: boolean;
  75928. readonly maxLayers: number;
  75929. }
  75930. interface VREyeParameters {
  75931. /** @deprecated */
  75932. readonly fieldOfView: VRFieldOfView;
  75933. readonly offset: Float32Array;
  75934. readonly renderHeight: number;
  75935. readonly renderWidth: number;
  75936. }
  75937. interface VRFieldOfView {
  75938. readonly downDegrees: number;
  75939. readonly leftDegrees: number;
  75940. readonly rightDegrees: number;
  75941. readonly upDegrees: number;
  75942. }
  75943. interface VRFrameData {
  75944. readonly leftProjectionMatrix: Float32Array;
  75945. readonly leftViewMatrix: Float32Array;
  75946. readonly pose: VRPose;
  75947. readonly rightProjectionMatrix: Float32Array;
  75948. readonly rightViewMatrix: Float32Array;
  75949. readonly timestamp: number;
  75950. }
  75951. interface VRPose {
  75952. readonly angularAcceleration: Float32Array | null;
  75953. readonly angularVelocity: Float32Array | null;
  75954. readonly linearAcceleration: Float32Array | null;
  75955. readonly linearVelocity: Float32Array | null;
  75956. readonly orientation: Float32Array | null;
  75957. readonly position: Float32Array | null;
  75958. readonly timestamp: number;
  75959. }
  75960. interface VRStageParameters {
  75961. sittingToStandingTransform?: Float32Array;
  75962. sizeX?: number;
  75963. sizeY?: number;
  75964. }
  75965. interface Navigator {
  75966. getVRDisplays(): Promise<VRDisplay[]>;
  75967. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75968. }
  75969. interface Window {
  75970. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75971. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75972. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75973. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75974. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75975. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75976. }
  75977. interface Gamepad {
  75978. readonly displayId: number;
  75979. }
  75980. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  75981. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  75982. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  75983. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  75984. type XRHandedness = "none" | "left" | "right";
  75985. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  75986. type XREye = "none" | "left" | "right";
  75987. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  75988. interface XRSpace extends EventTarget {}
  75989. interface XRRenderState {
  75990. depthNear?: number;
  75991. depthFar?: number;
  75992. inlineVerticalFieldOfView?: number;
  75993. baseLayer?: XRWebGLLayer;
  75994. }
  75995. interface XRInputSource {
  75996. handedness: XRHandedness;
  75997. targetRayMode: XRTargetRayMode;
  75998. targetRaySpace: XRSpace;
  75999. gripSpace: XRSpace | undefined;
  76000. gamepad: Gamepad | undefined;
  76001. profiles: Array<string>;
  76002. hand: XRHand | undefined;
  76003. }
  76004. interface XRSessionInit {
  76005. optionalFeatures?: string[];
  76006. requiredFeatures?: string[];
  76007. }
  76008. interface XRSession {
  76009. addEventListener: Function;
  76010. removeEventListener: Function;
  76011. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76012. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76013. requestAnimationFrame: Function;
  76014. end(): Promise<void>;
  76015. renderState: XRRenderState;
  76016. inputSources: Array<XRInputSource>;
  76017. // hit test
  76018. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76019. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76020. // legacy AR hit test
  76021. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76022. // legacy plane detection
  76023. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76024. }
  76025. interface XRReferenceSpace extends XRSpace {
  76026. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76027. onreset: any;
  76028. }
  76029. type XRPlaneSet = Set<XRPlane>;
  76030. type XRAnchorSet = Set<XRAnchor>;
  76031. interface XRFrame {
  76032. session: XRSession;
  76033. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76034. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76035. // AR
  76036. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76037. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76038. // Anchors
  76039. trackedAnchors?: XRAnchorSet;
  76040. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76041. // Planes
  76042. worldInformation: {
  76043. detectedPlanes?: XRPlaneSet;
  76044. };
  76045. // Hand tracking
  76046. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76047. }
  76048. interface XRViewerPose extends XRPose {
  76049. views: Array<XRView>;
  76050. }
  76051. interface XRPose {
  76052. transform: XRRigidTransform;
  76053. emulatedPosition: boolean;
  76054. }
  76055. interface XRWebGLLayerOptions {
  76056. antialias?: boolean;
  76057. depth?: boolean;
  76058. stencil?: boolean;
  76059. alpha?: boolean;
  76060. multiview?: boolean;
  76061. framebufferScaleFactor?: number;
  76062. }
  76063. declare var XRWebGLLayer: {
  76064. prototype: XRWebGLLayer;
  76065. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76066. };
  76067. interface XRWebGLLayer {
  76068. framebuffer: WebGLFramebuffer;
  76069. framebufferWidth: number;
  76070. framebufferHeight: number;
  76071. getViewport: Function;
  76072. }
  76073. declare class XRRigidTransform {
  76074. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76075. position: DOMPointReadOnly;
  76076. orientation: DOMPointReadOnly;
  76077. matrix: Float32Array;
  76078. inverse: XRRigidTransform;
  76079. }
  76080. interface XRView {
  76081. eye: XREye;
  76082. projectionMatrix: Float32Array;
  76083. transform: XRRigidTransform;
  76084. }
  76085. interface XRInputSourceChangeEvent {
  76086. session: XRSession;
  76087. removed: Array<XRInputSource>;
  76088. added: Array<XRInputSource>;
  76089. }
  76090. interface XRInputSourceEvent extends Event {
  76091. readonly frame: XRFrame;
  76092. readonly inputSource: XRInputSource;
  76093. }
  76094. // Experimental(er) features
  76095. declare class XRRay {
  76096. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76097. origin: DOMPointReadOnly;
  76098. direction: DOMPointReadOnly;
  76099. matrix: Float32Array;
  76100. }
  76101. declare enum XRHitTestTrackableType {
  76102. "point",
  76103. "plane",
  76104. "mesh",
  76105. }
  76106. interface XRHitResult {
  76107. hitMatrix: Float32Array;
  76108. }
  76109. interface XRTransientInputHitTestResult {
  76110. readonly inputSource: XRInputSource;
  76111. readonly results: Array<XRHitTestResult>;
  76112. }
  76113. interface XRHitTestResult {
  76114. getPose(baseSpace: XRSpace): XRPose | undefined;
  76115. // When anchor system is enabled
  76116. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76117. }
  76118. interface XRHitTestSource {
  76119. cancel(): void;
  76120. }
  76121. interface XRTransientInputHitTestSource {
  76122. cancel(): void;
  76123. }
  76124. interface XRHitTestOptionsInit {
  76125. space: XRSpace;
  76126. entityTypes?: Array<XRHitTestTrackableType>;
  76127. offsetRay?: XRRay;
  76128. }
  76129. interface XRTransientInputHitTestOptionsInit {
  76130. profile: string;
  76131. entityTypes?: Array<XRHitTestTrackableType>;
  76132. offsetRay?: XRRay;
  76133. }
  76134. interface XRAnchor {
  76135. anchorSpace: XRSpace;
  76136. delete(): void;
  76137. }
  76138. interface XRPlane {
  76139. orientation: "Horizontal" | "Vertical";
  76140. planeSpace: XRSpace;
  76141. polygon: Array<DOMPointReadOnly>;
  76142. lastChangedTime: number;
  76143. }
  76144. interface XRJointSpace extends XRSpace {}
  76145. interface XRJointPose extends XRPose {
  76146. radius: number | undefined;
  76147. }
  76148. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76149. readonly length: number;
  76150. [index: number]: XRJointSpace;
  76151. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76152. readonly WRIST: number;
  76153. readonly THUMB_METACARPAL: number;
  76154. readonly THUMB_PHALANX_PROXIMAL: number;
  76155. readonly THUMB_PHALANX_DISTAL: number;
  76156. readonly THUMB_PHALANX_TIP: number;
  76157. readonly INDEX_METACARPAL: number;
  76158. readonly INDEX_PHALANX_PROXIMAL: number;
  76159. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76160. readonly INDEX_PHALANX_DISTAL: number;
  76161. readonly INDEX_PHALANX_TIP: number;
  76162. readonly MIDDLE_METACARPAL: number;
  76163. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76164. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76165. readonly MIDDLE_PHALANX_DISTAL: number;
  76166. readonly MIDDLE_PHALANX_TIP: number;
  76167. readonly RING_METACARPAL: number;
  76168. readonly RING_PHALANX_PROXIMAL: number;
  76169. readonly RING_PHALANX_INTERMEDIATE: number;
  76170. readonly RING_PHALANX_DISTAL: number;
  76171. readonly RING_PHALANX_TIP: number;
  76172. readonly LITTLE_METACARPAL: number;
  76173. readonly LITTLE_PHALANX_PROXIMAL: number;
  76174. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76175. readonly LITTLE_PHALANX_DISTAL: number;
  76176. readonly LITTLE_PHALANX_TIP: number;
  76177. }
  76178. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76179. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76180. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76181. interface XRSession {
  76182. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76183. }
  76184. interface XRFrame {
  76185. featurePointCloud? : Array<number>;
  76186. }