babylon.d.ts 3.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306
  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. }
  28138. /**
  28139. * @hidden
  28140. **/
  28141. export class _InstancesBatch {
  28142. mustReturn: boolean;
  28143. visibleInstances: Nullable<InstancedMesh[]>[];
  28144. renderSelf: boolean[];
  28145. hardwareInstancedRendering: boolean[];
  28146. }
  28147. /**
  28148. * @hidden
  28149. **/
  28150. class _ThinInstanceDataStorage {
  28151. instancesCount: number;
  28152. matrixBuffer: Nullable<Buffer>;
  28153. matrixBufferSize: number;
  28154. matrixData: Nullable<Float32Array>;
  28155. boundingVectors: Array<Vector3>;
  28156. worldMatrices: Nullable<Matrix[]>;
  28157. }
  28158. /**
  28159. * Class used to represent renderable models
  28160. */
  28161. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28162. /**
  28163. * Mesh side orientation : usually the external or front surface
  28164. */
  28165. static readonly FRONTSIDE: number;
  28166. /**
  28167. * Mesh side orientation : usually the internal or back surface
  28168. */
  28169. static readonly BACKSIDE: number;
  28170. /**
  28171. * Mesh side orientation : both internal and external or front and back surfaces
  28172. */
  28173. static readonly DOUBLESIDE: number;
  28174. /**
  28175. * Mesh side orientation : by default, `FRONTSIDE`
  28176. */
  28177. static readonly DEFAULTSIDE: number;
  28178. /**
  28179. * Mesh cap setting : no cap
  28180. */
  28181. static readonly NO_CAP: number;
  28182. /**
  28183. * Mesh cap setting : one cap at the beginning of the mesh
  28184. */
  28185. static readonly CAP_START: number;
  28186. /**
  28187. * Mesh cap setting : one cap at the end of the mesh
  28188. */
  28189. static readonly CAP_END: number;
  28190. /**
  28191. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28192. */
  28193. static readonly CAP_ALL: number;
  28194. /**
  28195. * Mesh pattern setting : no flip or rotate
  28196. */
  28197. static readonly NO_FLIP: number;
  28198. /**
  28199. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28200. */
  28201. static readonly FLIP_TILE: number;
  28202. /**
  28203. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28204. */
  28205. static readonly ROTATE_TILE: number;
  28206. /**
  28207. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28208. */
  28209. static readonly FLIP_ROW: number;
  28210. /**
  28211. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28212. */
  28213. static readonly ROTATE_ROW: number;
  28214. /**
  28215. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28216. */
  28217. static readonly FLIP_N_ROTATE_TILE: number;
  28218. /**
  28219. * Mesh pattern setting : rotate pattern and rotate
  28220. */
  28221. static readonly FLIP_N_ROTATE_ROW: number;
  28222. /**
  28223. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28224. */
  28225. static readonly CENTER: number;
  28226. /**
  28227. * Mesh tile positioning : part tiles on left
  28228. */
  28229. static readonly LEFT: number;
  28230. /**
  28231. * Mesh tile positioning : part tiles on right
  28232. */
  28233. static readonly RIGHT: number;
  28234. /**
  28235. * Mesh tile positioning : part tiles on top
  28236. */
  28237. static readonly TOP: number;
  28238. /**
  28239. * Mesh tile positioning : part tiles on bottom
  28240. */
  28241. static readonly BOTTOM: number;
  28242. /**
  28243. * Gets the default side orientation.
  28244. * @param orientation the orientation to value to attempt to get
  28245. * @returns the default orientation
  28246. * @hidden
  28247. */
  28248. static _GetDefaultSideOrientation(orientation?: number): number;
  28249. private _internalMeshDataInfo;
  28250. get computeBonesUsingShaders(): boolean;
  28251. set computeBonesUsingShaders(value: boolean);
  28252. /**
  28253. * An event triggered before rendering the mesh
  28254. */
  28255. get onBeforeRenderObservable(): Observable<Mesh>;
  28256. /**
  28257. * An event triggered before binding the mesh
  28258. */
  28259. get onBeforeBindObservable(): Observable<Mesh>;
  28260. /**
  28261. * An event triggered after rendering the mesh
  28262. */
  28263. get onAfterRenderObservable(): Observable<Mesh>;
  28264. /**
  28265. * An event triggered before drawing the mesh
  28266. */
  28267. get onBeforeDrawObservable(): Observable<Mesh>;
  28268. private _onBeforeDrawObserver;
  28269. /**
  28270. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28271. */
  28272. set onBeforeDraw(callback: () => void);
  28273. get hasInstances(): boolean;
  28274. get hasThinInstances(): boolean;
  28275. /**
  28276. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28277. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28278. */
  28279. delayLoadState: number;
  28280. /**
  28281. * Gets the list of instances created from this mesh
  28282. * it is not supposed to be modified manually.
  28283. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28284. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28285. */
  28286. instances: InstancedMesh[];
  28287. /**
  28288. * Gets the file containing delay loading data for this mesh
  28289. */
  28290. delayLoadingFile: string;
  28291. /** @hidden */
  28292. _binaryInfo: any;
  28293. /**
  28294. * User defined function used to change how LOD level selection is done
  28295. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28296. */
  28297. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28298. /**
  28299. * Gets or sets the morph target manager
  28300. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28301. */
  28302. get morphTargetManager(): Nullable<MorphTargetManager>;
  28303. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28304. /** @hidden */
  28305. _creationDataStorage: Nullable<_CreationDataStorage>;
  28306. /** @hidden */
  28307. _geometry: Nullable<Geometry>;
  28308. /** @hidden */
  28309. _delayInfo: Array<string>;
  28310. /** @hidden */
  28311. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28312. /** @hidden */
  28313. _instanceDataStorage: _InstanceDataStorage;
  28314. /** @hidden */
  28315. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28316. private _effectiveMaterial;
  28317. /** @hidden */
  28318. _shouldGenerateFlatShading: boolean;
  28319. /** @hidden */
  28320. _originalBuilderSideOrientation: number;
  28321. /**
  28322. * Use this property to change the original side orientation defined at construction time
  28323. */
  28324. overrideMaterialSideOrientation: Nullable<number>;
  28325. /**
  28326. * Gets the source mesh (the one used to clone this one from)
  28327. */
  28328. get source(): Nullable<Mesh>;
  28329. /**
  28330. * Gets the list of clones of this mesh
  28331. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28332. * Note that useClonedMeshMap=true is the default setting
  28333. */
  28334. get cloneMeshMap(): Nullable<{
  28335. [id: string]: Mesh | undefined;
  28336. }>;
  28337. /**
  28338. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28339. */
  28340. get isUnIndexed(): boolean;
  28341. set isUnIndexed(value: boolean);
  28342. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28343. get worldMatrixInstancedBuffer(): Float32Array;
  28344. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28345. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28346. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28347. /**
  28348. * @constructor
  28349. * @param name The value used by scene.getMeshByName() to do a lookup.
  28350. * @param scene The scene to add this mesh to.
  28351. * @param parent The parent of this mesh, if it has one
  28352. * @param source An optional Mesh from which geometry is shared, cloned.
  28353. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28354. * When false, achieved by calling a clone(), also passing False.
  28355. * This will make creation of children, recursive.
  28356. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28357. */
  28358. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28359. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28360. doNotInstantiate: boolean;
  28361. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28362. /**
  28363. * Gets the class name
  28364. * @returns the string "Mesh".
  28365. */
  28366. getClassName(): string;
  28367. /** @hidden */
  28368. get _isMesh(): boolean;
  28369. /**
  28370. * Returns a description of this mesh
  28371. * @param fullDetails define if full details about this mesh must be used
  28372. * @returns a descriptive string representing this mesh
  28373. */
  28374. toString(fullDetails?: boolean): string;
  28375. /** @hidden */
  28376. _unBindEffect(): void;
  28377. /**
  28378. * Gets a boolean indicating if this mesh has LOD
  28379. */
  28380. get hasLODLevels(): boolean;
  28381. /**
  28382. * Gets the list of MeshLODLevel associated with the current mesh
  28383. * @returns an array of MeshLODLevel
  28384. */
  28385. getLODLevels(): MeshLODLevel[];
  28386. private _sortLODLevels;
  28387. /**
  28388. * Add a mesh as LOD level triggered at the given distance.
  28389. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28390. * @param distance The distance from the center of the object to show this level
  28391. * @param mesh The mesh to be added as LOD level (can be null)
  28392. * @return This mesh (for chaining)
  28393. */
  28394. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28395. /**
  28396. * Returns the LOD level mesh at the passed distance or null if not found.
  28397. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28398. * @param distance The distance from the center of the object to show this level
  28399. * @returns a Mesh or `null`
  28400. */
  28401. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28402. /**
  28403. * Remove a mesh from the LOD array
  28404. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28405. * @param mesh defines the mesh to be removed
  28406. * @return This mesh (for chaining)
  28407. */
  28408. removeLODLevel(mesh: Mesh): Mesh;
  28409. /**
  28410. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28411. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28412. * @param camera defines the camera to use to compute distance
  28413. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28414. * @return This mesh (for chaining)
  28415. */
  28416. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28417. /**
  28418. * Gets the mesh internal Geometry object
  28419. */
  28420. get geometry(): Nullable<Geometry>;
  28421. /**
  28422. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28423. * @returns the total number of vertices
  28424. */
  28425. getTotalVertices(): number;
  28426. /**
  28427. * Returns the content of an associated vertex buffer
  28428. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28429. * - VertexBuffer.PositionKind
  28430. * - VertexBuffer.UVKind
  28431. * - VertexBuffer.UV2Kind
  28432. * - VertexBuffer.UV3Kind
  28433. * - VertexBuffer.UV4Kind
  28434. * - VertexBuffer.UV5Kind
  28435. * - VertexBuffer.UV6Kind
  28436. * - VertexBuffer.ColorKind
  28437. * - VertexBuffer.MatricesIndicesKind
  28438. * - VertexBuffer.MatricesIndicesExtraKind
  28439. * - VertexBuffer.MatricesWeightsKind
  28440. * - VertexBuffer.MatricesWeightsExtraKind
  28441. * @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
  28442. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28443. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28444. */
  28445. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28446. /**
  28447. * Returns the mesh VertexBuffer object from the requested `kind`
  28448. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28449. * - VertexBuffer.PositionKind
  28450. * - VertexBuffer.NormalKind
  28451. * - VertexBuffer.UVKind
  28452. * - VertexBuffer.UV2Kind
  28453. * - VertexBuffer.UV3Kind
  28454. * - VertexBuffer.UV4Kind
  28455. * - VertexBuffer.UV5Kind
  28456. * - VertexBuffer.UV6Kind
  28457. * - VertexBuffer.ColorKind
  28458. * - VertexBuffer.MatricesIndicesKind
  28459. * - VertexBuffer.MatricesIndicesExtraKind
  28460. * - VertexBuffer.MatricesWeightsKind
  28461. * - VertexBuffer.MatricesWeightsExtraKind
  28462. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28463. */
  28464. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28465. /**
  28466. * Tests if a specific vertex buffer is associated with this mesh
  28467. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28468. * - VertexBuffer.PositionKind
  28469. * - VertexBuffer.NormalKind
  28470. * - VertexBuffer.UVKind
  28471. * - VertexBuffer.UV2Kind
  28472. * - VertexBuffer.UV3Kind
  28473. * - VertexBuffer.UV4Kind
  28474. * - VertexBuffer.UV5Kind
  28475. * - VertexBuffer.UV6Kind
  28476. * - VertexBuffer.ColorKind
  28477. * - VertexBuffer.MatricesIndicesKind
  28478. * - VertexBuffer.MatricesIndicesExtraKind
  28479. * - VertexBuffer.MatricesWeightsKind
  28480. * - VertexBuffer.MatricesWeightsExtraKind
  28481. * @returns a boolean
  28482. */
  28483. isVerticesDataPresent(kind: string): boolean;
  28484. /**
  28485. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28486. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28487. * - VertexBuffer.PositionKind
  28488. * - VertexBuffer.UVKind
  28489. * - VertexBuffer.UV2Kind
  28490. * - VertexBuffer.UV3Kind
  28491. * - VertexBuffer.UV4Kind
  28492. * - VertexBuffer.UV5Kind
  28493. * - VertexBuffer.UV6Kind
  28494. * - VertexBuffer.ColorKind
  28495. * - VertexBuffer.MatricesIndicesKind
  28496. * - VertexBuffer.MatricesIndicesExtraKind
  28497. * - VertexBuffer.MatricesWeightsKind
  28498. * - VertexBuffer.MatricesWeightsExtraKind
  28499. * @returns a boolean
  28500. */
  28501. isVertexBufferUpdatable(kind: string): boolean;
  28502. /**
  28503. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28504. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28505. * - VertexBuffer.PositionKind
  28506. * - VertexBuffer.NormalKind
  28507. * - VertexBuffer.UVKind
  28508. * - VertexBuffer.UV2Kind
  28509. * - VertexBuffer.UV3Kind
  28510. * - VertexBuffer.UV4Kind
  28511. * - VertexBuffer.UV5Kind
  28512. * - VertexBuffer.UV6Kind
  28513. * - VertexBuffer.ColorKind
  28514. * - VertexBuffer.MatricesIndicesKind
  28515. * - VertexBuffer.MatricesIndicesExtraKind
  28516. * - VertexBuffer.MatricesWeightsKind
  28517. * - VertexBuffer.MatricesWeightsExtraKind
  28518. * @returns an array of strings
  28519. */
  28520. getVerticesDataKinds(): string[];
  28521. /**
  28522. * Returns a positive integer : the total number of indices in this mesh geometry.
  28523. * @returns the numner of indices or zero if the mesh has no geometry.
  28524. */
  28525. getTotalIndices(): number;
  28526. /**
  28527. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28528. * @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.
  28529. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28530. * @returns the indices array or an empty array if the mesh has no geometry
  28531. */
  28532. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28533. get isBlocked(): boolean;
  28534. /**
  28535. * Determine if the current mesh is ready to be rendered
  28536. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28537. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28538. * @returns true if all associated assets are ready (material, textures, shaders)
  28539. */
  28540. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28541. /**
  28542. * 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.
  28543. */
  28544. get areNormalsFrozen(): boolean;
  28545. /**
  28546. * 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.
  28547. * @returns the current mesh
  28548. */
  28549. freezeNormals(): Mesh;
  28550. /**
  28551. * 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
  28552. * @returns the current mesh
  28553. */
  28554. unfreezeNormals(): Mesh;
  28555. /**
  28556. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28557. */
  28558. set overridenInstanceCount(count: number);
  28559. /** @hidden */
  28560. _preActivate(): Mesh;
  28561. /** @hidden */
  28562. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28563. /** @hidden */
  28564. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28565. protected _afterComputeWorldMatrix(): void;
  28566. /** @hidden */
  28567. _postActivate(): void;
  28568. /**
  28569. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28570. * This means the mesh underlying bounding box and sphere are recomputed.
  28571. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28572. * @returns the current mesh
  28573. */
  28574. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28575. /** @hidden */
  28576. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28577. /**
  28578. * This function will subdivide the mesh into multiple submeshes
  28579. * @param count defines the expected number of submeshes
  28580. */
  28581. subdivide(count: number): void;
  28582. /**
  28583. * Copy a FloatArray into a specific associated vertex buffer
  28584. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28585. * - VertexBuffer.PositionKind
  28586. * - VertexBuffer.UVKind
  28587. * - VertexBuffer.UV2Kind
  28588. * - VertexBuffer.UV3Kind
  28589. * - VertexBuffer.UV4Kind
  28590. * - VertexBuffer.UV5Kind
  28591. * - VertexBuffer.UV6Kind
  28592. * - VertexBuffer.ColorKind
  28593. * - VertexBuffer.MatricesIndicesKind
  28594. * - VertexBuffer.MatricesIndicesExtraKind
  28595. * - VertexBuffer.MatricesWeightsKind
  28596. * - VertexBuffer.MatricesWeightsExtraKind
  28597. * @param data defines the data source
  28598. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28599. * @param stride defines the data stride size (can be null)
  28600. * @returns the current mesh
  28601. */
  28602. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28603. /**
  28604. * Delete a vertex buffer associated with this mesh
  28605. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28606. * - VertexBuffer.PositionKind
  28607. * - VertexBuffer.UVKind
  28608. * - VertexBuffer.UV2Kind
  28609. * - VertexBuffer.UV3Kind
  28610. * - VertexBuffer.UV4Kind
  28611. * - VertexBuffer.UV5Kind
  28612. * - VertexBuffer.UV6Kind
  28613. * - VertexBuffer.ColorKind
  28614. * - VertexBuffer.MatricesIndicesKind
  28615. * - VertexBuffer.MatricesIndicesExtraKind
  28616. * - VertexBuffer.MatricesWeightsKind
  28617. * - VertexBuffer.MatricesWeightsExtraKind
  28618. */
  28619. removeVerticesData(kind: string): void;
  28620. /**
  28621. * Flags an associated vertex buffer as updatable
  28622. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28623. * - VertexBuffer.PositionKind
  28624. * - VertexBuffer.UVKind
  28625. * - VertexBuffer.UV2Kind
  28626. * - VertexBuffer.UV3Kind
  28627. * - VertexBuffer.UV4Kind
  28628. * - VertexBuffer.UV5Kind
  28629. * - VertexBuffer.UV6Kind
  28630. * - VertexBuffer.ColorKind
  28631. * - VertexBuffer.MatricesIndicesKind
  28632. * - VertexBuffer.MatricesIndicesExtraKind
  28633. * - VertexBuffer.MatricesWeightsKind
  28634. * - VertexBuffer.MatricesWeightsExtraKind
  28635. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28636. */
  28637. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28638. /**
  28639. * Sets the mesh global Vertex Buffer
  28640. * @param buffer defines the buffer to use
  28641. * @returns the current mesh
  28642. */
  28643. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28644. /**
  28645. * Update a specific associated vertex buffer
  28646. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28647. * - VertexBuffer.PositionKind
  28648. * - VertexBuffer.UVKind
  28649. * - VertexBuffer.UV2Kind
  28650. * - VertexBuffer.UV3Kind
  28651. * - VertexBuffer.UV4Kind
  28652. * - VertexBuffer.UV5Kind
  28653. * - VertexBuffer.UV6Kind
  28654. * - VertexBuffer.ColorKind
  28655. * - VertexBuffer.MatricesIndicesKind
  28656. * - VertexBuffer.MatricesIndicesExtraKind
  28657. * - VertexBuffer.MatricesWeightsKind
  28658. * - VertexBuffer.MatricesWeightsExtraKind
  28659. * @param data defines the data source
  28660. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28661. * @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)
  28662. * @returns the current mesh
  28663. */
  28664. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28665. /**
  28666. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28667. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28668. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28669. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28670. * @returns the current mesh
  28671. */
  28672. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28673. /**
  28674. * Creates a un-shared specific occurence of the geometry for the mesh.
  28675. * @returns the current mesh
  28676. */
  28677. makeGeometryUnique(): Mesh;
  28678. /**
  28679. * Set the index buffer of this mesh
  28680. * @param indices defines the source data
  28681. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28682. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28683. * @returns the current mesh
  28684. */
  28685. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28686. /**
  28687. * Update the current index buffer
  28688. * @param indices defines the source data
  28689. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28690. * @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)
  28691. * @returns the current mesh
  28692. */
  28693. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28694. /**
  28695. * Invert the geometry to move from a right handed system to a left handed one.
  28696. * @returns the current mesh
  28697. */
  28698. toLeftHanded(): Mesh;
  28699. /** @hidden */
  28700. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28701. /** @hidden */
  28702. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28703. /**
  28704. * Registers for this mesh a javascript function called just before the rendering process
  28705. * @param func defines the function to call before rendering this mesh
  28706. * @returns the current mesh
  28707. */
  28708. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28709. /**
  28710. * Disposes a previously registered javascript function called before the rendering
  28711. * @param func defines the function to remove
  28712. * @returns the current mesh
  28713. */
  28714. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28715. /**
  28716. * Registers for this mesh a javascript function called just after the rendering is complete
  28717. * @param func defines the function to call after rendering this mesh
  28718. * @returns the current mesh
  28719. */
  28720. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28721. /**
  28722. * Disposes a previously registered javascript function called after the rendering.
  28723. * @param func defines the function to remove
  28724. * @returns the current mesh
  28725. */
  28726. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28727. /** @hidden */
  28728. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28729. /** @hidden */
  28730. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28731. /** @hidden */
  28732. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28733. /** @hidden */
  28734. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28735. /** @hidden */
  28736. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28737. /** @hidden */
  28738. _rebuild(): void;
  28739. /** @hidden */
  28740. _freeze(): void;
  28741. /** @hidden */
  28742. _unFreeze(): void;
  28743. /**
  28744. * 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
  28745. * @param subMesh defines the subMesh to render
  28746. * @param enableAlphaMode defines if alpha mode can be changed
  28747. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28748. * @returns the current mesh
  28749. */
  28750. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28751. private _onBeforeDraw;
  28752. /**
  28753. * Renormalize the mesh and patch it up if there are no weights
  28754. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28755. * However in the case of zero weights then we set just a single influence to 1.
  28756. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28757. */
  28758. cleanMatrixWeights(): void;
  28759. private normalizeSkinFourWeights;
  28760. private normalizeSkinWeightsAndExtra;
  28761. /**
  28762. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28763. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28764. * the user know there was an issue with importing the mesh
  28765. * @returns a validation object with skinned, valid and report string
  28766. */
  28767. validateSkinning(): {
  28768. skinned: boolean;
  28769. valid: boolean;
  28770. report: string;
  28771. };
  28772. /** @hidden */
  28773. _checkDelayState(): Mesh;
  28774. private _queueLoad;
  28775. /**
  28776. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28777. * A mesh is in the frustum if its bounding box intersects the frustum
  28778. * @param frustumPlanes defines the frustum to test
  28779. * @returns true if the mesh is in the frustum planes
  28780. */
  28781. isInFrustum(frustumPlanes: Plane[]): boolean;
  28782. /**
  28783. * Sets the mesh material by the material or multiMaterial `id` property
  28784. * @param id is a string identifying the material or the multiMaterial
  28785. * @returns the current mesh
  28786. */
  28787. setMaterialByID(id: string): Mesh;
  28788. /**
  28789. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28790. * @returns an array of IAnimatable
  28791. */
  28792. getAnimatables(): IAnimatable[];
  28793. /**
  28794. * Modifies the mesh geometry according to the passed transformation matrix.
  28795. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28796. * The mesh normals are modified using the same transformation.
  28797. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28798. * @param transform defines the transform matrix to use
  28799. * @see https://doc.babylonjs.com/resources/baking_transformations
  28800. * @returns the current mesh
  28801. */
  28802. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28803. /**
  28804. * Modifies the mesh geometry according to its own current World Matrix.
  28805. * The mesh World Matrix is then reset.
  28806. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28807. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28808. * @see https://doc.babylonjs.com/resources/baking_transformations
  28809. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28810. * @returns the current mesh
  28811. */
  28812. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28813. /** @hidden */
  28814. get _positions(): Nullable<Vector3[]>;
  28815. /** @hidden */
  28816. _resetPointsArrayCache(): Mesh;
  28817. /** @hidden */
  28818. _generatePointsArray(): boolean;
  28819. /**
  28820. * Returns a new Mesh object generated from the current mesh properties.
  28821. * This method must not get confused with createInstance()
  28822. * @param name is a string, the name given to the new mesh
  28823. * @param newParent can be any Node object (default `null`)
  28824. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28825. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28826. * @returns a new mesh
  28827. */
  28828. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28829. /**
  28830. * Releases resources associated with this mesh.
  28831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28833. */
  28834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28835. /** @hidden */
  28836. _disposeInstanceSpecificData(): void;
  28837. /** @hidden */
  28838. _disposeThinInstanceSpecificData(): void;
  28839. /**
  28840. * Modifies the mesh geometry according to a displacement map.
  28841. * 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.
  28842. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28843. * @param url is a string, the URL from the image file is to be downloaded.
  28844. * @param minHeight is the lower limit of the displacement.
  28845. * @param maxHeight is the upper limit of the displacement.
  28846. * @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.
  28847. * @param uvOffset is an optional vector2 used to offset UV.
  28848. * @param uvScale is an optional vector2 used to scale UV.
  28849. * @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.
  28850. * @returns the Mesh.
  28851. */
  28852. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28853. /**
  28854. * Modifies the mesh geometry according to a displacementMap buffer.
  28855. * 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.
  28856. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28857. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28858. * @param heightMapWidth is the width of the buffer image.
  28859. * @param heightMapHeight is the height of the buffer image.
  28860. * @param minHeight is the lower limit of the displacement.
  28861. * @param maxHeight is the upper limit of the displacement.
  28862. * @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.
  28863. * @param uvOffset is an optional vector2 used to offset UV.
  28864. * @param uvScale is an optional vector2 used to scale UV.
  28865. * @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.
  28866. * @returns the Mesh.
  28867. */
  28868. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28869. /**
  28870. * Modify the mesh to get a flat shading rendering.
  28871. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28872. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28873. * @returns current mesh
  28874. */
  28875. convertToFlatShadedMesh(): Mesh;
  28876. /**
  28877. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28878. * In other words, more vertices, no more indices and a single bigger VBO.
  28879. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28880. * @returns current mesh
  28881. */
  28882. convertToUnIndexedMesh(): Mesh;
  28883. /**
  28884. * Inverses facet orientations.
  28885. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28886. * @param flipNormals will also inverts the normals
  28887. * @returns current mesh
  28888. */
  28889. flipFaces(flipNormals?: boolean): Mesh;
  28890. /**
  28891. * Increase the number of facets and hence vertices in a mesh
  28892. * Vertex normals are interpolated from existing vertex normals
  28893. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28894. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28895. */
  28896. increaseVertices(numberPerEdge: number): void;
  28897. /**
  28898. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28899. * This will undo any application of covertToFlatShadedMesh
  28900. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28901. */
  28902. forceSharedVertices(): void;
  28903. /** @hidden */
  28904. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28905. /** @hidden */
  28906. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28907. /**
  28908. * Creates a new InstancedMesh object from the mesh model.
  28909. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28910. * @param name defines the name of the new instance
  28911. * @returns a new InstancedMesh
  28912. */
  28913. createInstance(name: string): InstancedMesh;
  28914. /**
  28915. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28916. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28917. * @returns the current mesh
  28918. */
  28919. synchronizeInstances(): Mesh;
  28920. /**
  28921. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28922. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28923. * This should be used together with the simplification to avoid disappearing triangles.
  28924. * @param successCallback an optional success callback to be called after the optimization finished.
  28925. * @returns the current mesh
  28926. */
  28927. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28928. /**
  28929. * Serialize current mesh
  28930. * @param serializationObject defines the object which will receive the serialization data
  28931. */
  28932. serialize(serializationObject: any): void;
  28933. /** @hidden */
  28934. _syncGeometryWithMorphTargetManager(): void;
  28935. /** @hidden */
  28936. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28937. /**
  28938. * Returns a new Mesh object parsed from the source provided.
  28939. * @param parsedMesh is the source
  28940. * @param scene defines the hosting scene
  28941. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28942. * @returns a new Mesh
  28943. */
  28944. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28945. /**
  28946. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28947. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28948. * @param name defines the name of the mesh to create
  28949. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28950. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28951. * @param closePath creates a seam between the first and the last points of each path of the path array
  28952. * @param offset is taken in account only if the `pathArray` is containing a single path
  28953. * @param scene defines the hosting scene
  28954. * @param updatable defines if the mesh must be flagged as updatable
  28955. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28956. * @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)
  28957. * @returns a new Mesh
  28958. */
  28959. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28960. /**
  28961. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28962. * @param name defines the name of the mesh to create
  28963. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28964. * @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
  28965. * @param scene defines the hosting scene
  28966. * @param updatable defines if the mesh must be flagged as updatable
  28967. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28968. * @returns a new Mesh
  28969. */
  28970. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28971. /**
  28972. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28973. * @param name defines the name of the mesh to create
  28974. * @param size sets the size (float) of each box side (default 1)
  28975. * @param scene defines the hosting scene
  28976. * @param updatable defines if the mesh must be flagged as updatable
  28977. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28978. * @returns a new Mesh
  28979. */
  28980. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28981. /**
  28982. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28983. * @param name defines the name of the mesh to create
  28984. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28985. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28986. * @param scene defines the hosting scene
  28987. * @param updatable defines if the mesh must be flagged as updatable
  28988. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28989. * @returns a new Mesh
  28990. */
  28991. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28992. /**
  28993. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28994. * @param name defines the name of the mesh to create
  28995. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28996. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28997. * @param scene defines the hosting scene
  28998. * @returns a new Mesh
  28999. */
  29000. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29001. /**
  29002. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29003. * @param name defines the name of the mesh to create
  29004. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29005. * @param diameterTop set the top cap diameter (floats, default 1)
  29006. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29007. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29008. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29009. * @param scene defines the hosting scene
  29010. * @param updatable defines if the mesh must be flagged as updatable
  29011. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29012. * @returns a new Mesh
  29013. */
  29014. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29015. /**
  29016. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29017. * @param name defines the name of the mesh to create
  29018. * @param diameter sets the diameter size (float) of the torus (default 1)
  29019. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29020. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29021. * @param scene defines the hosting scene
  29022. * @param updatable defines if the mesh must be flagged as updatable
  29023. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29024. * @returns a new Mesh
  29025. */
  29026. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29027. /**
  29028. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29029. * @param name defines the name of the mesh to create
  29030. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29031. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29032. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29033. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29034. * @param p the number of windings on X axis (positive integers, default 2)
  29035. * @param q the number of windings on Y axis (positive integers, default 3)
  29036. * @param scene defines the hosting scene
  29037. * @param updatable defines if the mesh must be flagged as updatable
  29038. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29039. * @returns a new Mesh
  29040. */
  29041. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29042. /**
  29043. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29044. * @param name defines the name of the mesh to create
  29045. * @param points is an array successive Vector3
  29046. * @param scene defines the hosting scene
  29047. * @param updatable defines if the mesh must be flagged as updatable
  29048. * @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).
  29049. * @returns a new Mesh
  29050. */
  29051. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29052. /**
  29053. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29054. * @param name defines the name of the mesh to create
  29055. * @param points is an array successive Vector3
  29056. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29057. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29058. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29059. * @param scene defines the hosting scene
  29060. * @param updatable defines if the mesh must be flagged as updatable
  29061. * @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)
  29062. * @returns a new Mesh
  29063. */
  29064. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29065. /**
  29066. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29067. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29068. * 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.
  29069. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29070. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29071. * Remember you can only change the shape positions, not their number when updating a polygon.
  29072. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29073. * @param name defines the name of the mesh to create
  29074. * @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
  29075. * @param scene defines the hosting scene
  29076. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29077. * @param updatable defines if the mesh must be flagged as updatable
  29078. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29079. * @param earcutInjection can be used to inject your own earcut reference
  29080. * @returns a new Mesh
  29081. */
  29082. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29083. /**
  29084. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29086. * @param name defines the name of the mesh to create
  29087. * @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
  29088. * @param depth defines the height of extrusion
  29089. * @param scene defines the hosting scene
  29090. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29091. * @param updatable defines if the mesh must be flagged as updatable
  29092. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29093. * @param earcutInjection can be used to inject your own earcut reference
  29094. * @returns a new Mesh
  29095. */
  29096. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29097. /**
  29098. * Creates an extruded shape mesh.
  29099. * 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
  29100. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29102. * @param name defines the name of the mesh to create
  29103. * @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
  29104. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29105. * @param scale is the value to scale the shape
  29106. * @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
  29107. * @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
  29108. * @param scene defines the hosting scene
  29109. * @param updatable defines if the mesh must be flagged as updatable
  29110. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29111. * @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)
  29112. * @returns a new Mesh
  29113. */
  29114. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29115. /**
  29116. * Creates an custom extruded shape mesh.
  29117. * The custom extrusion is a parametric shape.
  29118. * It has no predefined shape. Its final shape will depend on the input parameters.
  29119. * Please consider using the same method from the MeshBuilder class instead
  29120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29121. * @param name defines the name of the mesh to create
  29122. * @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
  29123. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29124. * @param scaleFunction is a custom Javascript function called on each path point
  29125. * @param rotationFunction is a custom Javascript function called on each path point
  29126. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29127. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29128. * @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
  29129. * @param scene defines the hosting scene
  29130. * @param updatable defines if the mesh must be flagged as updatable
  29131. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29132. * @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)
  29133. * @returns a new Mesh
  29134. */
  29135. 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;
  29136. /**
  29137. * Creates lathe mesh.
  29138. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29139. * Please consider using the same method from the MeshBuilder class instead
  29140. * @param name defines the name of the mesh to create
  29141. * @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
  29142. * @param radius is the radius value of the lathe
  29143. * @param tessellation is the side number of the lathe.
  29144. * @param scene defines the hosting scene
  29145. * @param updatable defines if the mesh must be flagged as updatable
  29146. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29147. * @returns a new Mesh
  29148. */
  29149. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29150. /**
  29151. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29152. * @param name defines the name of the mesh to create
  29153. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29154. * @param scene defines the hosting scene
  29155. * @param updatable defines if the mesh must be flagged as updatable
  29156. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29157. * @returns a new Mesh
  29158. */
  29159. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29160. /**
  29161. * Creates a ground mesh.
  29162. * Please consider using the same method from the MeshBuilder class instead
  29163. * @param name defines the name of the mesh to create
  29164. * @param width set the width of the ground
  29165. * @param height set the height of the ground
  29166. * @param subdivisions sets the number of subdivisions per side
  29167. * @param scene defines the hosting scene
  29168. * @param updatable defines if the mesh must be flagged as updatable
  29169. * @returns a new Mesh
  29170. */
  29171. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29172. /**
  29173. * Creates a tiled ground mesh.
  29174. * Please consider using the same method from the MeshBuilder class instead
  29175. * @param name defines the name of the mesh to create
  29176. * @param xmin set the ground minimum X coordinate
  29177. * @param zmin set the ground minimum Y coordinate
  29178. * @param xmax set the ground maximum X coordinate
  29179. * @param zmax set the ground maximum Z coordinate
  29180. * @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
  29181. * @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
  29182. * @param scene defines the hosting scene
  29183. * @param updatable defines if the mesh must be flagged as updatable
  29184. * @returns a new Mesh
  29185. */
  29186. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29187. w: number;
  29188. h: number;
  29189. }, precision: {
  29190. w: number;
  29191. h: number;
  29192. }, scene: Scene, updatable?: boolean): Mesh;
  29193. /**
  29194. * Creates a ground mesh from a height map.
  29195. * Please consider using the same method from the MeshBuilder class instead
  29196. * @see https://doc.babylonjs.com/babylon101/height_map
  29197. * @param name defines the name of the mesh to create
  29198. * @param url sets the URL of the height map image resource
  29199. * @param width set the ground width size
  29200. * @param height set the ground height size
  29201. * @param subdivisions sets the number of subdivision per side
  29202. * @param minHeight is the minimum altitude on the ground
  29203. * @param maxHeight is the maximum altitude on the ground
  29204. * @param scene defines the hosting scene
  29205. * @param updatable defines if the mesh must be flagged as updatable
  29206. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29207. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29208. * @returns a new Mesh
  29209. */
  29210. 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;
  29211. /**
  29212. * Creates a tube mesh.
  29213. * The tube is a parametric shape.
  29214. * It has no predefined shape. Its final shape will depend on the input parameters.
  29215. * Please consider using the same method from the MeshBuilder class instead
  29216. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29217. * @param name defines the name of the mesh to create
  29218. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29219. * @param radius sets the tube radius size
  29220. * @param tessellation is the number of sides on the tubular surface
  29221. * @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
  29222. * @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
  29223. * @param scene defines the hosting scene
  29224. * @param updatable defines if the mesh must be flagged as updatable
  29225. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29226. * @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)
  29227. * @returns a new Mesh
  29228. */
  29229. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29230. (i: number, distance: number): number;
  29231. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29232. /**
  29233. * Creates a polyhedron mesh.
  29234. * Please consider using the same method from the MeshBuilder class instead.
  29235. * * 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
  29236. * * The parameter `size` (positive float, default 1) sets the polygon size
  29237. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29238. * * 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`
  29239. * * 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
  29240. * * 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)`)
  29241. * * 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
  29242. * * 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
  29243. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29244. * * 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
  29245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29246. * @param name defines the name of the mesh to create
  29247. * @param options defines the options used to create the mesh
  29248. * @param scene defines the hosting scene
  29249. * @returns a new Mesh
  29250. */
  29251. static CreatePolyhedron(name: string, options: {
  29252. type?: number;
  29253. size?: number;
  29254. sizeX?: number;
  29255. sizeY?: number;
  29256. sizeZ?: number;
  29257. custom?: any;
  29258. faceUV?: Vector4[];
  29259. faceColors?: Color4[];
  29260. updatable?: boolean;
  29261. sideOrientation?: number;
  29262. }, scene: Scene): Mesh;
  29263. /**
  29264. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29265. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29266. * * 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`)
  29267. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29268. * * 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
  29269. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29270. * * 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
  29271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29272. * @param name defines the name of the mesh
  29273. * @param options defines the options used to create the mesh
  29274. * @param scene defines the hosting scene
  29275. * @returns a new Mesh
  29276. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29277. */
  29278. static CreateIcoSphere(name: string, options: {
  29279. radius?: number;
  29280. flat?: boolean;
  29281. subdivisions?: number;
  29282. sideOrientation?: number;
  29283. updatable?: boolean;
  29284. }, scene: Scene): Mesh;
  29285. /**
  29286. * Creates a decal mesh.
  29287. * Please consider using the same method from the MeshBuilder class instead.
  29288. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29289. * @param name defines the name of the mesh
  29290. * @param sourceMesh defines the mesh receiving the decal
  29291. * @param position sets the position of the decal in world coordinates
  29292. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29293. * @param size sets the decal scaling
  29294. * @param angle sets the angle to rotate the decal
  29295. * @returns a new Mesh
  29296. */
  29297. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29298. /** Creates a Capsule Mesh
  29299. * @param name defines the name of the mesh.
  29300. * @param options the constructors options used to shape the mesh.
  29301. * @param scene defines the scene the mesh is scoped to.
  29302. * @returns the capsule mesh
  29303. * @see https://doc.babylonjs.com/how_to/capsule_shape
  29304. */
  29305. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  29306. /**
  29307. * Prepare internal position array for software CPU skinning
  29308. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29309. */
  29310. setPositionsForCPUSkinning(): Float32Array;
  29311. /**
  29312. * Prepare internal normal array for software CPU skinning
  29313. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29314. */
  29315. setNormalsForCPUSkinning(): Float32Array;
  29316. /**
  29317. * Updates the vertex buffer by applying transformation from the bones
  29318. * @param skeleton defines the skeleton to apply to current mesh
  29319. * @returns the current mesh
  29320. */
  29321. applySkeleton(skeleton: Skeleton): Mesh;
  29322. /**
  29323. * 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
  29324. * @param meshes defines the list of meshes to scan
  29325. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29326. */
  29327. static MinMax(meshes: AbstractMesh[]): {
  29328. min: Vector3;
  29329. max: Vector3;
  29330. };
  29331. /**
  29332. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29333. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29334. * @returns a vector3
  29335. */
  29336. static Center(meshesOrMinMaxVector: {
  29337. min: Vector3;
  29338. max: Vector3;
  29339. } | AbstractMesh[]): Vector3;
  29340. /**
  29341. * Merge the array of meshes into a single mesh for performance reasons.
  29342. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29343. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29344. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29345. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29346. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29347. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29348. * @returns a new mesh
  29349. */
  29350. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29351. /** @hidden */
  29352. addInstance(instance: InstancedMesh): void;
  29353. /** @hidden */
  29354. removeInstance(instance: InstancedMesh): void;
  29355. }
  29356. }
  29357. declare module BABYLON {
  29358. /**
  29359. * This is the base class of all the camera used in the application.
  29360. * @see https://doc.babylonjs.com/features/cameras
  29361. */
  29362. export class Camera extends Node {
  29363. /** @hidden */
  29364. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29365. /**
  29366. * This is the default projection mode used by the cameras.
  29367. * It helps recreating a feeling of perspective and better appreciate depth.
  29368. * This is the best way to simulate real life cameras.
  29369. */
  29370. static readonly PERSPECTIVE_CAMERA: number;
  29371. /**
  29372. * This helps creating camera with an orthographic mode.
  29373. * 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.
  29374. */
  29375. static readonly ORTHOGRAPHIC_CAMERA: number;
  29376. /**
  29377. * This is the default FOV mode for perspective cameras.
  29378. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29379. */
  29380. static readonly FOVMODE_VERTICAL_FIXED: number;
  29381. /**
  29382. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29383. */
  29384. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29385. /**
  29386. * This specifies ther is no need for a camera rig.
  29387. * Basically only one eye is rendered corresponding to the camera.
  29388. */
  29389. static readonly RIG_MODE_NONE: number;
  29390. /**
  29391. * Simulates a camera Rig with one blue eye and one red eye.
  29392. * This can be use with 3d blue and red glasses.
  29393. */
  29394. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29395. /**
  29396. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29397. */
  29398. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29399. /**
  29400. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29401. */
  29402. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29403. /**
  29404. * Defines that both eyes of the camera will be rendered over under each other.
  29405. */
  29406. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29407. /**
  29408. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29409. */
  29410. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29411. /**
  29412. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29413. */
  29414. static readonly RIG_MODE_VR: number;
  29415. /**
  29416. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29417. */
  29418. static readonly RIG_MODE_WEBVR: number;
  29419. /**
  29420. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29421. */
  29422. static readonly RIG_MODE_CUSTOM: number;
  29423. /**
  29424. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29425. */
  29426. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29427. /**
  29428. * Define the input manager associated with the camera.
  29429. */
  29430. inputs: CameraInputsManager<Camera>;
  29431. /** @hidden */
  29432. _position: Vector3;
  29433. /**
  29434. * Define the current local position of the camera in the scene
  29435. */
  29436. get position(): Vector3;
  29437. set position(newPosition: Vector3);
  29438. protected _upVector: Vector3;
  29439. /**
  29440. * The vector the camera should consider as up.
  29441. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29442. */
  29443. set upVector(vec: Vector3);
  29444. get upVector(): Vector3;
  29445. /**
  29446. * Define the current limit on the left side for an orthographic camera
  29447. * In scene unit
  29448. */
  29449. orthoLeft: Nullable<number>;
  29450. /**
  29451. * Define the current limit on the right side for an orthographic camera
  29452. * In scene unit
  29453. */
  29454. orthoRight: Nullable<number>;
  29455. /**
  29456. * Define the current limit on the bottom side for an orthographic camera
  29457. * In scene unit
  29458. */
  29459. orthoBottom: Nullable<number>;
  29460. /**
  29461. * Define the current limit on the top side for an orthographic camera
  29462. * In scene unit
  29463. */
  29464. orthoTop: Nullable<number>;
  29465. /**
  29466. * Field Of View is set in Radians. (default is 0.8)
  29467. */
  29468. fov: number;
  29469. /**
  29470. * Define the minimum distance the camera can see from.
  29471. * This is important to note that the depth buffer are not infinite and the closer it starts
  29472. * the more your scene might encounter depth fighting issue.
  29473. */
  29474. minZ: number;
  29475. /**
  29476. * Define the maximum distance the camera can see to.
  29477. * This is important to note that the depth buffer are not infinite and the further it end
  29478. * the more your scene might encounter depth fighting issue.
  29479. */
  29480. maxZ: number;
  29481. /**
  29482. * Define the default inertia of the camera.
  29483. * This helps giving a smooth feeling to the camera movement.
  29484. */
  29485. inertia: number;
  29486. /**
  29487. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29488. */
  29489. mode: number;
  29490. /**
  29491. * Define whether the camera is intermediate.
  29492. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29493. */
  29494. isIntermediate: boolean;
  29495. /**
  29496. * Define the viewport of the camera.
  29497. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29498. */
  29499. viewport: Viewport;
  29500. /**
  29501. * Restricts the camera to viewing objects with the same layerMask.
  29502. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29503. */
  29504. layerMask: number;
  29505. /**
  29506. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29507. */
  29508. fovMode: number;
  29509. /**
  29510. * Rig mode of the camera.
  29511. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29512. * This is normally controlled byt the camera themselves as internal use.
  29513. */
  29514. cameraRigMode: number;
  29515. /**
  29516. * Defines the distance between both "eyes" in case of a RIG
  29517. */
  29518. interaxialDistance: number;
  29519. /**
  29520. * Defines if stereoscopic rendering is done side by side or over under.
  29521. */
  29522. isStereoscopicSideBySide: boolean;
  29523. /**
  29524. * 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
  29525. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29526. * else in the scene. (Eg. security camera)
  29527. *
  29528. * 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)
  29529. */
  29530. customRenderTargets: RenderTargetTexture[];
  29531. /**
  29532. * When set, the camera will render to this render target instead of the default canvas
  29533. *
  29534. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29535. */
  29536. outputRenderTarget: Nullable<RenderTargetTexture>;
  29537. /**
  29538. * Observable triggered when the camera view matrix has changed.
  29539. */
  29540. onViewMatrixChangedObservable: Observable<Camera>;
  29541. /**
  29542. * Observable triggered when the camera Projection matrix has changed.
  29543. */
  29544. onProjectionMatrixChangedObservable: Observable<Camera>;
  29545. /**
  29546. * Observable triggered when the inputs have been processed.
  29547. */
  29548. onAfterCheckInputsObservable: Observable<Camera>;
  29549. /**
  29550. * Observable triggered when reset has been called and applied to the camera.
  29551. */
  29552. onRestoreStateObservable: Observable<Camera>;
  29553. /**
  29554. * Is this camera a part of a rig system?
  29555. */
  29556. isRigCamera: boolean;
  29557. /**
  29558. * If isRigCamera set to true this will be set with the parent camera.
  29559. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29560. */
  29561. rigParent?: Camera;
  29562. /** @hidden */
  29563. _cameraRigParams: any;
  29564. /** @hidden */
  29565. _rigCameras: Camera[];
  29566. /** @hidden */
  29567. _rigPostProcess: Nullable<PostProcess>;
  29568. protected _webvrViewMatrix: Matrix;
  29569. /** @hidden */
  29570. _skipRendering: boolean;
  29571. /** @hidden */
  29572. _projectionMatrix: Matrix;
  29573. /** @hidden */
  29574. _postProcesses: Nullable<PostProcess>[];
  29575. /** @hidden */
  29576. _activeMeshes: SmartArray<AbstractMesh>;
  29577. protected _globalPosition: Vector3;
  29578. /** @hidden */
  29579. _computedViewMatrix: Matrix;
  29580. private _doNotComputeProjectionMatrix;
  29581. private _transformMatrix;
  29582. private _frustumPlanes;
  29583. private _refreshFrustumPlanes;
  29584. private _storedFov;
  29585. private _stateStored;
  29586. /**
  29587. * Instantiates a new camera object.
  29588. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29589. * @see https://doc.babylonjs.com/features/cameras
  29590. * @param name Defines the name of the camera in the scene
  29591. * @param position Defines the position of the camera
  29592. * @param scene Defines the scene the camera belongs too
  29593. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29594. */
  29595. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29596. /**
  29597. * Store current camera state (fov, position, etc..)
  29598. * @returns the camera
  29599. */
  29600. storeState(): Camera;
  29601. /**
  29602. * Restores the camera state values if it has been stored. You must call storeState() first
  29603. */
  29604. protected _restoreStateValues(): boolean;
  29605. /**
  29606. * Restored camera state. You must call storeState() first.
  29607. * @returns true if restored and false otherwise
  29608. */
  29609. restoreState(): boolean;
  29610. /**
  29611. * Gets the class name of the camera.
  29612. * @returns the class name
  29613. */
  29614. getClassName(): string;
  29615. /** @hidden */
  29616. readonly _isCamera: boolean;
  29617. /**
  29618. * Gets a string representation of the camera useful for debug purpose.
  29619. * @param fullDetails Defines that a more verboe level of logging is required
  29620. * @returns the string representation
  29621. */
  29622. toString(fullDetails?: boolean): string;
  29623. /**
  29624. * Gets the current world space position of the camera.
  29625. */
  29626. get globalPosition(): Vector3;
  29627. /**
  29628. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29629. * @returns the active meshe list
  29630. */
  29631. getActiveMeshes(): SmartArray<AbstractMesh>;
  29632. /**
  29633. * Check whether a mesh is part of the current active mesh list of the camera
  29634. * @param mesh Defines the mesh to check
  29635. * @returns true if active, false otherwise
  29636. */
  29637. isActiveMesh(mesh: Mesh): boolean;
  29638. /**
  29639. * Is this camera ready to be used/rendered
  29640. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29641. * @return true if the camera is ready
  29642. */
  29643. isReady(completeCheck?: boolean): boolean;
  29644. /** @hidden */
  29645. _initCache(): void;
  29646. /** @hidden */
  29647. _updateCache(ignoreParentClass?: boolean): void;
  29648. /** @hidden */
  29649. _isSynchronized(): boolean;
  29650. /** @hidden */
  29651. _isSynchronizedViewMatrix(): boolean;
  29652. /** @hidden */
  29653. _isSynchronizedProjectionMatrix(): boolean;
  29654. /**
  29655. * Attach the input controls to a specific dom element to get the input from.
  29656. * @param element Defines the element the controls should be listened from
  29657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29658. */
  29659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29660. /**
  29661. * Detach the current controls from the specified dom element.
  29662. * @param element Defines the element to stop listening the inputs from
  29663. */
  29664. detachControl(element: HTMLElement): void;
  29665. /**
  29666. * Update the camera state according to the different inputs gathered during the frame.
  29667. */
  29668. update(): void;
  29669. /** @hidden */
  29670. _checkInputs(): void;
  29671. /** @hidden */
  29672. get rigCameras(): Camera[];
  29673. /**
  29674. * Gets the post process used by the rig cameras
  29675. */
  29676. get rigPostProcess(): Nullable<PostProcess>;
  29677. /**
  29678. * Internal, gets the first post proces.
  29679. * @returns the first post process to be run on this camera.
  29680. */
  29681. _getFirstPostProcess(): Nullable<PostProcess>;
  29682. private _cascadePostProcessesToRigCams;
  29683. /**
  29684. * Attach a post process to the camera.
  29685. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29686. * @param postProcess The post process to attach to the camera
  29687. * @param insertAt The position of the post process in case several of them are in use in the scene
  29688. * @returns the position the post process has been inserted at
  29689. */
  29690. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29691. /**
  29692. * Detach a post process to the camera.
  29693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29694. * @param postProcess The post process to detach from the camera
  29695. */
  29696. detachPostProcess(postProcess: PostProcess): void;
  29697. /**
  29698. * Gets the current world matrix of the camera
  29699. */
  29700. getWorldMatrix(): Matrix;
  29701. /** @hidden */
  29702. _getViewMatrix(): Matrix;
  29703. /**
  29704. * Gets the current view matrix of the camera.
  29705. * @param force forces the camera to recompute the matrix without looking at the cached state
  29706. * @returns the view matrix
  29707. */
  29708. getViewMatrix(force?: boolean): Matrix;
  29709. /**
  29710. * Freeze the projection matrix.
  29711. * It will prevent the cache check of the camera projection compute and can speed up perf
  29712. * if no parameter of the camera are meant to change
  29713. * @param projection Defines manually a projection if necessary
  29714. */
  29715. freezeProjectionMatrix(projection?: Matrix): void;
  29716. /**
  29717. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29718. */
  29719. unfreezeProjectionMatrix(): void;
  29720. /**
  29721. * Gets the current projection matrix of the camera.
  29722. * @param force forces the camera to recompute the matrix without looking at the cached state
  29723. * @returns the projection matrix
  29724. */
  29725. getProjectionMatrix(force?: boolean): Matrix;
  29726. /**
  29727. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29728. * @returns a Matrix
  29729. */
  29730. getTransformationMatrix(): Matrix;
  29731. private _updateFrustumPlanes;
  29732. /**
  29733. * Checks if a cullable object (mesh...) is in the camera frustum
  29734. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29735. * @param target The object to check
  29736. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29737. * @returns true if the object is in frustum otherwise false
  29738. */
  29739. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29740. /**
  29741. * Checks if a cullable object (mesh...) is in the camera frustum
  29742. * Unlike isInFrustum this cheks the full bounding box
  29743. * @param target The object to check
  29744. * @returns true if the object is in frustum otherwise false
  29745. */
  29746. isCompletelyInFrustum(target: ICullable): boolean;
  29747. /**
  29748. * Gets a ray in the forward direction from the camera.
  29749. * @param length Defines the length of the ray to create
  29750. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29751. * @param origin Defines the start point of the ray which defaults to the camera position
  29752. * @returns the forward ray
  29753. */
  29754. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29755. /**
  29756. * Gets a ray in the forward direction from the camera.
  29757. * @param refRay the ray to (re)use when setting the values
  29758. * @param length Defines the length of the ray to create
  29759. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29760. * @param origin Defines the start point of the ray which defaults to the camera position
  29761. * @returns the forward ray
  29762. */
  29763. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29764. /**
  29765. * Releases resources associated with this node.
  29766. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29767. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29768. */
  29769. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29770. /** @hidden */
  29771. _isLeftCamera: boolean;
  29772. /**
  29773. * Gets the left camera of a rig setup in case of Rigged Camera
  29774. */
  29775. get isLeftCamera(): boolean;
  29776. /** @hidden */
  29777. _isRightCamera: boolean;
  29778. /**
  29779. * Gets the right camera of a rig setup in case of Rigged Camera
  29780. */
  29781. get isRightCamera(): boolean;
  29782. /**
  29783. * Gets the left camera of a rig setup in case of Rigged Camera
  29784. */
  29785. get leftCamera(): Nullable<FreeCamera>;
  29786. /**
  29787. * Gets the right camera of a rig setup in case of Rigged Camera
  29788. */
  29789. get rightCamera(): Nullable<FreeCamera>;
  29790. /**
  29791. * Gets the left camera target of a rig setup in case of Rigged Camera
  29792. * @returns the target position
  29793. */
  29794. getLeftTarget(): Nullable<Vector3>;
  29795. /**
  29796. * Gets the right camera target of a rig setup in case of Rigged Camera
  29797. * @returns the target position
  29798. */
  29799. getRightTarget(): Nullable<Vector3>;
  29800. /**
  29801. * @hidden
  29802. */
  29803. setCameraRigMode(mode: number, rigParams: any): void;
  29804. /** @hidden */
  29805. static _setStereoscopicRigMode(camera: Camera): void;
  29806. /** @hidden */
  29807. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29808. /** @hidden */
  29809. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29810. /** @hidden */
  29811. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29812. /** @hidden */
  29813. _getVRProjectionMatrix(): Matrix;
  29814. protected _updateCameraRotationMatrix(): void;
  29815. protected _updateWebVRCameraRotationMatrix(): void;
  29816. /**
  29817. * This function MUST be overwritten by the different WebVR cameras available.
  29818. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29819. * @hidden
  29820. */
  29821. _getWebVRProjectionMatrix(): Matrix;
  29822. /**
  29823. * This function MUST be overwritten by the different WebVR cameras available.
  29824. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29825. * @hidden
  29826. */
  29827. _getWebVRViewMatrix(): Matrix;
  29828. /** @hidden */
  29829. setCameraRigParameter(name: string, value: any): void;
  29830. /**
  29831. * needs to be overridden by children so sub has required properties to be copied
  29832. * @hidden
  29833. */
  29834. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29835. /**
  29836. * May need to be overridden by children
  29837. * @hidden
  29838. */
  29839. _updateRigCameras(): void;
  29840. /** @hidden */
  29841. _setupInputs(): void;
  29842. /**
  29843. * Serialiaze the camera setup to a json represention
  29844. * @returns the JSON representation
  29845. */
  29846. serialize(): any;
  29847. /**
  29848. * Clones the current camera.
  29849. * @param name The cloned camera name
  29850. * @returns the cloned camera
  29851. */
  29852. clone(name: string): Camera;
  29853. /**
  29854. * Gets the direction of the camera relative to a given local axis.
  29855. * @param localAxis Defines the reference axis to provide a relative direction.
  29856. * @return the direction
  29857. */
  29858. getDirection(localAxis: Vector3): Vector3;
  29859. /**
  29860. * Returns the current camera absolute rotation
  29861. */
  29862. get absoluteRotation(): Quaternion;
  29863. /**
  29864. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29865. * @param localAxis Defines the reference axis to provide a relative direction.
  29866. * @param result Defines the vector to store the result in
  29867. */
  29868. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29869. /**
  29870. * Gets a camera constructor for a given camera type
  29871. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29872. * @param name The name of the camera the result will be able to instantiate
  29873. * @param scene The scene the result will construct the camera in
  29874. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29875. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29876. * @returns a factory method to construc the camera
  29877. */
  29878. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29879. /**
  29880. * Compute the world matrix of the camera.
  29881. * @returns the camera world matrix
  29882. */
  29883. computeWorldMatrix(): Matrix;
  29884. /**
  29885. * Parse a JSON and creates the camera from the parsed information
  29886. * @param parsedCamera The JSON to parse
  29887. * @param scene The scene to instantiate the camera in
  29888. * @returns the newly constructed camera
  29889. */
  29890. static Parse(parsedCamera: any, scene: Scene): Camera;
  29891. }
  29892. }
  29893. declare module BABYLON {
  29894. /**
  29895. * Class containing static functions to help procedurally build meshes
  29896. */
  29897. export class DiscBuilder {
  29898. /**
  29899. * Creates a plane polygonal mesh. By default, this is a disc
  29900. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29901. * * 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
  29902. * * 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
  29903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29904. * * 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
  29905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29906. * @param name defines the name of the mesh
  29907. * @param options defines the options used to create the mesh
  29908. * @param scene defines the hosting scene
  29909. * @returns the plane polygonal mesh
  29910. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29911. */
  29912. static CreateDisc(name: string, options: {
  29913. radius?: number;
  29914. tessellation?: number;
  29915. arc?: number;
  29916. updatable?: boolean;
  29917. sideOrientation?: number;
  29918. frontUVs?: Vector4;
  29919. backUVs?: Vector4;
  29920. }, scene?: Nullable<Scene>): Mesh;
  29921. }
  29922. }
  29923. declare module BABYLON {
  29924. /**
  29925. * Options to be used when creating a FresnelParameters.
  29926. */
  29927. export type IFresnelParametersCreationOptions = {
  29928. /**
  29929. * Define the color used on edges (grazing angle)
  29930. */
  29931. leftColor?: Color3;
  29932. /**
  29933. * Define the color used on center
  29934. */
  29935. rightColor?: Color3;
  29936. /**
  29937. * Define bias applied to computed fresnel term
  29938. */
  29939. bias?: number;
  29940. /**
  29941. * Defined the power exponent applied to fresnel term
  29942. */
  29943. power?: number;
  29944. /**
  29945. * Define if the fresnel effect is enable or not.
  29946. */
  29947. isEnabled?: boolean;
  29948. };
  29949. /**
  29950. * Serialized format for FresnelParameters.
  29951. */
  29952. export type IFresnelParametersSerialized = {
  29953. /**
  29954. * Define the color used on edges (grazing angle) [as an array]
  29955. */
  29956. leftColor: number[];
  29957. /**
  29958. * Define the color used on center [as an array]
  29959. */
  29960. rightColor: number[];
  29961. /**
  29962. * Define bias applied to computed fresnel term
  29963. */
  29964. bias: number;
  29965. /**
  29966. * Defined the power exponent applied to fresnel term
  29967. */
  29968. power?: number;
  29969. /**
  29970. * Define if the fresnel effect is enable or not.
  29971. */
  29972. isEnabled: boolean;
  29973. };
  29974. /**
  29975. * This represents all the required information to add a fresnel effect on a material:
  29976. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29977. */
  29978. export class FresnelParameters {
  29979. private _isEnabled;
  29980. /**
  29981. * Define if the fresnel effect is enable or not.
  29982. */
  29983. get isEnabled(): boolean;
  29984. set isEnabled(value: boolean);
  29985. /**
  29986. * Define the color used on edges (grazing angle)
  29987. */
  29988. leftColor: Color3;
  29989. /**
  29990. * Define the color used on center
  29991. */
  29992. rightColor: Color3;
  29993. /**
  29994. * Define bias applied to computed fresnel term
  29995. */
  29996. bias: number;
  29997. /**
  29998. * Defined the power exponent applied to fresnel term
  29999. */
  30000. power: number;
  30001. /**
  30002. * Creates a new FresnelParameters object.
  30003. *
  30004. * @param options provide your own settings to optionally to override defaults
  30005. */
  30006. constructor(options?: IFresnelParametersCreationOptions);
  30007. /**
  30008. * Clones the current fresnel and its valuues
  30009. * @returns a clone fresnel configuration
  30010. */
  30011. clone(): FresnelParameters;
  30012. /**
  30013. * Determines equality between FresnelParameters objects
  30014. * @param otherFresnelParameters defines the second operand
  30015. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30016. */
  30017. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30018. /**
  30019. * Serializes the current fresnel parameters to a JSON representation.
  30020. * @return the JSON serialization
  30021. */
  30022. serialize(): IFresnelParametersSerialized;
  30023. /**
  30024. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30025. * @param parsedFresnelParameters Define the JSON representation
  30026. * @returns the parsed parameters
  30027. */
  30028. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30029. }
  30030. }
  30031. declare module BABYLON {
  30032. /**
  30033. * This groups all the flags used to control the materials channel.
  30034. */
  30035. export class MaterialFlags {
  30036. private static _DiffuseTextureEnabled;
  30037. /**
  30038. * Are diffuse textures enabled in the application.
  30039. */
  30040. static get DiffuseTextureEnabled(): boolean;
  30041. static set DiffuseTextureEnabled(value: boolean);
  30042. private static _DetailTextureEnabled;
  30043. /**
  30044. * Are detail textures enabled in the application.
  30045. */
  30046. static get DetailTextureEnabled(): boolean;
  30047. static set DetailTextureEnabled(value: boolean);
  30048. private static _AmbientTextureEnabled;
  30049. /**
  30050. * Are ambient textures enabled in the application.
  30051. */
  30052. static get AmbientTextureEnabled(): boolean;
  30053. static set AmbientTextureEnabled(value: boolean);
  30054. private static _OpacityTextureEnabled;
  30055. /**
  30056. * Are opacity textures enabled in the application.
  30057. */
  30058. static get OpacityTextureEnabled(): boolean;
  30059. static set OpacityTextureEnabled(value: boolean);
  30060. private static _ReflectionTextureEnabled;
  30061. /**
  30062. * Are reflection textures enabled in the application.
  30063. */
  30064. static get ReflectionTextureEnabled(): boolean;
  30065. static set ReflectionTextureEnabled(value: boolean);
  30066. private static _EmissiveTextureEnabled;
  30067. /**
  30068. * Are emissive textures enabled in the application.
  30069. */
  30070. static get EmissiveTextureEnabled(): boolean;
  30071. static set EmissiveTextureEnabled(value: boolean);
  30072. private static _SpecularTextureEnabled;
  30073. /**
  30074. * Are specular textures enabled in the application.
  30075. */
  30076. static get SpecularTextureEnabled(): boolean;
  30077. static set SpecularTextureEnabled(value: boolean);
  30078. private static _BumpTextureEnabled;
  30079. /**
  30080. * Are bump textures enabled in the application.
  30081. */
  30082. static get BumpTextureEnabled(): boolean;
  30083. static set BumpTextureEnabled(value: boolean);
  30084. private static _LightmapTextureEnabled;
  30085. /**
  30086. * Are lightmap textures enabled in the application.
  30087. */
  30088. static get LightmapTextureEnabled(): boolean;
  30089. static set LightmapTextureEnabled(value: boolean);
  30090. private static _RefractionTextureEnabled;
  30091. /**
  30092. * Are refraction textures enabled in the application.
  30093. */
  30094. static get RefractionTextureEnabled(): boolean;
  30095. static set RefractionTextureEnabled(value: boolean);
  30096. private static _ColorGradingTextureEnabled;
  30097. /**
  30098. * Are color grading textures enabled in the application.
  30099. */
  30100. static get ColorGradingTextureEnabled(): boolean;
  30101. static set ColorGradingTextureEnabled(value: boolean);
  30102. private static _FresnelEnabled;
  30103. /**
  30104. * Are fresnels enabled in the application.
  30105. */
  30106. static get FresnelEnabled(): boolean;
  30107. static set FresnelEnabled(value: boolean);
  30108. private static _ClearCoatTextureEnabled;
  30109. /**
  30110. * Are clear coat textures enabled in the application.
  30111. */
  30112. static get ClearCoatTextureEnabled(): boolean;
  30113. static set ClearCoatTextureEnabled(value: boolean);
  30114. private static _ClearCoatBumpTextureEnabled;
  30115. /**
  30116. * Are clear coat bump textures enabled in the application.
  30117. */
  30118. static get ClearCoatBumpTextureEnabled(): boolean;
  30119. static set ClearCoatBumpTextureEnabled(value: boolean);
  30120. private static _ClearCoatTintTextureEnabled;
  30121. /**
  30122. * Are clear coat tint textures enabled in the application.
  30123. */
  30124. static get ClearCoatTintTextureEnabled(): boolean;
  30125. static set ClearCoatTintTextureEnabled(value: boolean);
  30126. private static _SheenTextureEnabled;
  30127. /**
  30128. * Are sheen textures enabled in the application.
  30129. */
  30130. static get SheenTextureEnabled(): boolean;
  30131. static set SheenTextureEnabled(value: boolean);
  30132. private static _AnisotropicTextureEnabled;
  30133. /**
  30134. * Are anisotropic textures enabled in the application.
  30135. */
  30136. static get AnisotropicTextureEnabled(): boolean;
  30137. static set AnisotropicTextureEnabled(value: boolean);
  30138. private static _ThicknessTextureEnabled;
  30139. /**
  30140. * Are thickness textures enabled in the application.
  30141. */
  30142. static get ThicknessTextureEnabled(): boolean;
  30143. static set ThicknessTextureEnabled(value: boolean);
  30144. }
  30145. }
  30146. declare module BABYLON {
  30147. /** @hidden */
  30148. export var defaultFragmentDeclaration: {
  30149. name: string;
  30150. shader: string;
  30151. };
  30152. }
  30153. declare module BABYLON {
  30154. /** @hidden */
  30155. export var defaultUboDeclaration: {
  30156. name: string;
  30157. shader: string;
  30158. };
  30159. }
  30160. declare module BABYLON {
  30161. /** @hidden */
  30162. export var prePassDeclaration: {
  30163. name: string;
  30164. shader: string;
  30165. };
  30166. }
  30167. declare module BABYLON {
  30168. /** @hidden */
  30169. export var lightFragmentDeclaration: {
  30170. name: string;
  30171. shader: string;
  30172. };
  30173. }
  30174. declare module BABYLON {
  30175. /** @hidden */
  30176. export var lightUboDeclaration: {
  30177. name: string;
  30178. shader: string;
  30179. };
  30180. }
  30181. declare module BABYLON {
  30182. /** @hidden */
  30183. export var lightsFragmentFunctions: {
  30184. name: string;
  30185. shader: string;
  30186. };
  30187. }
  30188. declare module BABYLON {
  30189. /** @hidden */
  30190. export var shadowsFragmentFunctions: {
  30191. name: string;
  30192. shader: string;
  30193. };
  30194. }
  30195. declare module BABYLON {
  30196. /** @hidden */
  30197. export var fresnelFunction: {
  30198. name: string;
  30199. shader: string;
  30200. };
  30201. }
  30202. declare module BABYLON {
  30203. /** @hidden */
  30204. export var bumpFragmentMainFunctions: {
  30205. name: string;
  30206. shader: string;
  30207. };
  30208. }
  30209. declare module BABYLON {
  30210. /** @hidden */
  30211. export var bumpFragmentFunctions: {
  30212. name: string;
  30213. shader: string;
  30214. };
  30215. }
  30216. declare module BABYLON {
  30217. /** @hidden */
  30218. export var logDepthDeclaration: {
  30219. name: string;
  30220. shader: string;
  30221. };
  30222. }
  30223. declare module BABYLON {
  30224. /** @hidden */
  30225. export var bumpFragment: {
  30226. name: string;
  30227. shader: string;
  30228. };
  30229. }
  30230. declare module BABYLON {
  30231. /** @hidden */
  30232. export var depthPrePass: {
  30233. name: string;
  30234. shader: string;
  30235. };
  30236. }
  30237. declare module BABYLON {
  30238. /** @hidden */
  30239. export var lightFragment: {
  30240. name: string;
  30241. shader: string;
  30242. };
  30243. }
  30244. declare module BABYLON {
  30245. /** @hidden */
  30246. export var logDepthFragment: {
  30247. name: string;
  30248. shader: string;
  30249. };
  30250. }
  30251. declare module BABYLON {
  30252. /** @hidden */
  30253. export var defaultPixelShader: {
  30254. name: string;
  30255. shader: string;
  30256. };
  30257. }
  30258. declare module BABYLON {
  30259. /** @hidden */
  30260. export var defaultVertexDeclaration: {
  30261. name: string;
  30262. shader: string;
  30263. };
  30264. }
  30265. declare module BABYLON {
  30266. /** @hidden */
  30267. export var bumpVertexDeclaration: {
  30268. name: string;
  30269. shader: string;
  30270. };
  30271. }
  30272. declare module BABYLON {
  30273. /** @hidden */
  30274. export var bumpVertex: {
  30275. name: string;
  30276. shader: string;
  30277. };
  30278. }
  30279. declare module BABYLON {
  30280. /** @hidden */
  30281. export var fogVertex: {
  30282. name: string;
  30283. shader: string;
  30284. };
  30285. }
  30286. declare module BABYLON {
  30287. /** @hidden */
  30288. export var shadowsVertex: {
  30289. name: string;
  30290. shader: string;
  30291. };
  30292. }
  30293. declare module BABYLON {
  30294. /** @hidden */
  30295. export var pointCloudVertex: {
  30296. name: string;
  30297. shader: string;
  30298. };
  30299. }
  30300. declare module BABYLON {
  30301. /** @hidden */
  30302. export var logDepthVertex: {
  30303. name: string;
  30304. shader: string;
  30305. };
  30306. }
  30307. declare module BABYLON {
  30308. /** @hidden */
  30309. export var defaultVertexShader: {
  30310. name: string;
  30311. shader: string;
  30312. };
  30313. }
  30314. declare module BABYLON {
  30315. /**
  30316. * @hidden
  30317. */
  30318. export interface IMaterialDetailMapDefines {
  30319. DETAIL: boolean;
  30320. DETAILDIRECTUV: number;
  30321. DETAIL_NORMALBLENDMETHOD: number;
  30322. /** @hidden */
  30323. _areTexturesDirty: boolean;
  30324. }
  30325. /**
  30326. * Define the code related to the detail map parameters of a material
  30327. *
  30328. * Inspired from:
  30329. * 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
  30330. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30331. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30332. */
  30333. export class DetailMapConfiguration {
  30334. private _texture;
  30335. /**
  30336. * The detail texture of the material.
  30337. */
  30338. texture: Nullable<BaseTexture>;
  30339. /**
  30340. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30341. * Bigger values mean stronger blending
  30342. */
  30343. diffuseBlendLevel: number;
  30344. /**
  30345. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30346. * Bigger values mean stronger blending. Only used with PBR materials
  30347. */
  30348. roughnessBlendLevel: number;
  30349. /**
  30350. * Defines how strong the bump effect from the detail map is
  30351. * Bigger values mean stronger effect
  30352. */
  30353. bumpLevel: number;
  30354. private _normalBlendMethod;
  30355. /**
  30356. * The method used to blend the bump and detail normals together
  30357. */
  30358. normalBlendMethod: number;
  30359. private _isEnabled;
  30360. /**
  30361. * Enable or disable the detail map on this material
  30362. */
  30363. isEnabled: boolean;
  30364. /** @hidden */
  30365. private _internalMarkAllSubMeshesAsTexturesDirty;
  30366. /** @hidden */
  30367. _markAllSubMeshesAsTexturesDirty(): void;
  30368. /**
  30369. * Instantiate a new detail map
  30370. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30371. */
  30372. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30373. /**
  30374. * Gets whether the submesh is ready to be used or not.
  30375. * @param defines the list of "defines" to update.
  30376. * @param scene defines the scene the material belongs to.
  30377. * @returns - boolean indicating that the submesh is ready or not.
  30378. */
  30379. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30380. /**
  30381. * Update the defines for detail map usage
  30382. * @param defines the list of "defines" to update.
  30383. * @param scene defines the scene the material belongs to.
  30384. */
  30385. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30386. /**
  30387. * Binds the material data.
  30388. * @param uniformBuffer defines the Uniform buffer to fill in.
  30389. * @param scene defines the scene the material belongs to.
  30390. * @param isFrozen defines whether the material is frozen or not.
  30391. */
  30392. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30393. /**
  30394. * Checks to see if a texture is used in the material.
  30395. * @param texture - Base texture to use.
  30396. * @returns - Boolean specifying if a texture is used in the material.
  30397. */
  30398. hasTexture(texture: BaseTexture): boolean;
  30399. /**
  30400. * Returns an array of the actively used textures.
  30401. * @param activeTextures Array of BaseTextures
  30402. */
  30403. getActiveTextures(activeTextures: BaseTexture[]): void;
  30404. /**
  30405. * Returns the animatable textures.
  30406. * @param animatables Array of animatable textures.
  30407. */
  30408. getAnimatables(animatables: IAnimatable[]): void;
  30409. /**
  30410. * Disposes the resources of the material.
  30411. * @param forceDisposeTextures - Forces the disposal of all textures.
  30412. */
  30413. dispose(forceDisposeTextures?: boolean): void;
  30414. /**
  30415. * Get the current class name useful for serialization or dynamic coding.
  30416. * @returns "DetailMap"
  30417. */
  30418. getClassName(): string;
  30419. /**
  30420. * Add the required uniforms to the current list.
  30421. * @param uniforms defines the current uniform list.
  30422. */
  30423. static AddUniforms(uniforms: string[]): void;
  30424. /**
  30425. * Add the required samplers to the current list.
  30426. * @param samplers defines the current sampler list.
  30427. */
  30428. static AddSamplers(samplers: string[]): void;
  30429. /**
  30430. * Add the required uniforms to the current buffer.
  30431. * @param uniformBuffer defines the current uniform buffer.
  30432. */
  30433. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30434. /**
  30435. * Makes a duplicate of the current instance into another one.
  30436. * @param detailMap define the instance where to copy the info
  30437. */
  30438. copyTo(detailMap: DetailMapConfiguration): void;
  30439. /**
  30440. * Serializes this detail map instance
  30441. * @returns - An object with the serialized instance.
  30442. */
  30443. serialize(): any;
  30444. /**
  30445. * Parses a detail map setting from a serialized object.
  30446. * @param source - Serialized object.
  30447. * @param scene Defines the scene we are parsing for
  30448. * @param rootUrl Defines the rootUrl to load from
  30449. */
  30450. parse(source: any, scene: Scene, rootUrl: string): void;
  30451. }
  30452. }
  30453. declare module BABYLON {
  30454. /** @hidden */
  30455. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30456. MAINUV1: boolean;
  30457. MAINUV2: boolean;
  30458. DIFFUSE: boolean;
  30459. DIFFUSEDIRECTUV: number;
  30460. DETAIL: boolean;
  30461. DETAILDIRECTUV: number;
  30462. DETAIL_NORMALBLENDMETHOD: number;
  30463. AMBIENT: boolean;
  30464. AMBIENTDIRECTUV: number;
  30465. OPACITY: boolean;
  30466. OPACITYDIRECTUV: number;
  30467. OPACITYRGB: boolean;
  30468. REFLECTION: boolean;
  30469. EMISSIVE: boolean;
  30470. EMISSIVEDIRECTUV: number;
  30471. SPECULAR: boolean;
  30472. SPECULARDIRECTUV: number;
  30473. BUMP: boolean;
  30474. BUMPDIRECTUV: number;
  30475. PARALLAX: boolean;
  30476. PARALLAXOCCLUSION: boolean;
  30477. SPECULAROVERALPHA: boolean;
  30478. CLIPPLANE: boolean;
  30479. CLIPPLANE2: boolean;
  30480. CLIPPLANE3: boolean;
  30481. CLIPPLANE4: boolean;
  30482. CLIPPLANE5: boolean;
  30483. CLIPPLANE6: boolean;
  30484. ALPHATEST: boolean;
  30485. DEPTHPREPASS: boolean;
  30486. ALPHAFROMDIFFUSE: boolean;
  30487. POINTSIZE: boolean;
  30488. FOG: boolean;
  30489. SPECULARTERM: boolean;
  30490. DIFFUSEFRESNEL: boolean;
  30491. OPACITYFRESNEL: boolean;
  30492. REFLECTIONFRESNEL: boolean;
  30493. REFRACTIONFRESNEL: boolean;
  30494. EMISSIVEFRESNEL: boolean;
  30495. FRESNEL: boolean;
  30496. NORMAL: boolean;
  30497. UV1: boolean;
  30498. UV2: boolean;
  30499. VERTEXCOLOR: boolean;
  30500. VERTEXALPHA: boolean;
  30501. NUM_BONE_INFLUENCERS: number;
  30502. BonesPerMesh: number;
  30503. BONETEXTURE: boolean;
  30504. INSTANCES: boolean;
  30505. THIN_INSTANCES: boolean;
  30506. GLOSSINESS: boolean;
  30507. ROUGHNESS: boolean;
  30508. EMISSIVEASILLUMINATION: boolean;
  30509. LINKEMISSIVEWITHDIFFUSE: boolean;
  30510. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30511. LIGHTMAP: boolean;
  30512. LIGHTMAPDIRECTUV: number;
  30513. OBJECTSPACE_NORMALMAP: boolean;
  30514. USELIGHTMAPASSHADOWMAP: boolean;
  30515. REFLECTIONMAP_3D: boolean;
  30516. REFLECTIONMAP_SPHERICAL: boolean;
  30517. REFLECTIONMAP_PLANAR: boolean;
  30518. REFLECTIONMAP_CUBIC: boolean;
  30519. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30520. REFLECTIONMAP_PROJECTION: boolean;
  30521. REFLECTIONMAP_SKYBOX: boolean;
  30522. REFLECTIONMAP_EXPLICIT: boolean;
  30523. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30524. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30525. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30526. INVERTCUBICMAP: boolean;
  30527. LOGARITHMICDEPTH: boolean;
  30528. REFRACTION: boolean;
  30529. REFRACTIONMAP_3D: boolean;
  30530. REFLECTIONOVERALPHA: boolean;
  30531. TWOSIDEDLIGHTING: boolean;
  30532. SHADOWFLOAT: boolean;
  30533. MORPHTARGETS: boolean;
  30534. MORPHTARGETS_NORMAL: boolean;
  30535. MORPHTARGETS_TANGENT: boolean;
  30536. MORPHTARGETS_UV: boolean;
  30537. NUM_MORPH_INFLUENCERS: number;
  30538. NONUNIFORMSCALING: boolean;
  30539. PREMULTIPLYALPHA: boolean;
  30540. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30541. ALPHABLEND: boolean;
  30542. PREPASS: boolean;
  30543. SCENE_MRT_COUNT: number;
  30544. RGBDLIGHTMAP: boolean;
  30545. RGBDREFLECTION: boolean;
  30546. RGBDREFRACTION: boolean;
  30547. IMAGEPROCESSING: boolean;
  30548. VIGNETTE: boolean;
  30549. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30550. VIGNETTEBLENDMODEOPAQUE: boolean;
  30551. TONEMAPPING: boolean;
  30552. TONEMAPPING_ACES: boolean;
  30553. CONTRAST: boolean;
  30554. COLORCURVES: boolean;
  30555. COLORGRADING: boolean;
  30556. COLORGRADING3D: boolean;
  30557. SAMPLER3DGREENDEPTH: boolean;
  30558. SAMPLER3DBGRMAP: boolean;
  30559. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30560. MULTIVIEW: boolean;
  30561. /**
  30562. * If the reflection texture on this material is in linear color space
  30563. * @hidden
  30564. */
  30565. IS_REFLECTION_LINEAR: boolean;
  30566. /**
  30567. * If the refraction texture on this material is in linear color space
  30568. * @hidden
  30569. */
  30570. IS_REFRACTION_LINEAR: boolean;
  30571. EXPOSURE: boolean;
  30572. constructor();
  30573. setReflectionMode(modeToEnable: string): void;
  30574. }
  30575. /**
  30576. * This is the default material used in Babylon. It is the best trade off between quality
  30577. * and performances.
  30578. * @see https://doc.babylonjs.com/babylon101/materials
  30579. */
  30580. export class StandardMaterial extends PushMaterial {
  30581. private _diffuseTexture;
  30582. /**
  30583. * The basic texture of the material as viewed under a light.
  30584. */
  30585. diffuseTexture: Nullable<BaseTexture>;
  30586. private _ambientTexture;
  30587. /**
  30588. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30589. */
  30590. ambientTexture: Nullable<BaseTexture>;
  30591. private _opacityTexture;
  30592. /**
  30593. * Define the transparency of the material from a texture.
  30594. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30595. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30596. */
  30597. opacityTexture: Nullable<BaseTexture>;
  30598. private _reflectionTexture;
  30599. /**
  30600. * Define the texture used to display the reflection.
  30601. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30602. */
  30603. reflectionTexture: Nullable<BaseTexture>;
  30604. private _emissiveTexture;
  30605. /**
  30606. * Define texture of the material as if self lit.
  30607. * This will be mixed in the final result even in the absence of light.
  30608. */
  30609. emissiveTexture: Nullable<BaseTexture>;
  30610. private _specularTexture;
  30611. /**
  30612. * Define how the color and intensity of the highlight given by the light in the material.
  30613. */
  30614. specularTexture: Nullable<BaseTexture>;
  30615. private _bumpTexture;
  30616. /**
  30617. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30618. * 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.
  30619. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30620. */
  30621. bumpTexture: Nullable<BaseTexture>;
  30622. private _lightmapTexture;
  30623. /**
  30624. * Complex lighting can be computationally expensive to compute at runtime.
  30625. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30626. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30627. */
  30628. lightmapTexture: Nullable<BaseTexture>;
  30629. private _refractionTexture;
  30630. /**
  30631. * Define the texture used to display the refraction.
  30632. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30633. */
  30634. refractionTexture: Nullable<BaseTexture>;
  30635. /**
  30636. * The color of the material lit by the environmental background lighting.
  30637. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30638. */
  30639. ambientColor: Color3;
  30640. /**
  30641. * The basic color of the material as viewed under a light.
  30642. */
  30643. diffuseColor: Color3;
  30644. /**
  30645. * Define how the color and intensity of the highlight given by the light in the material.
  30646. */
  30647. specularColor: Color3;
  30648. /**
  30649. * Define the color of the material as if self lit.
  30650. * This will be mixed in the final result even in the absence of light.
  30651. */
  30652. emissiveColor: Color3;
  30653. /**
  30654. * Defines how sharp are the highlights in the material.
  30655. * The bigger the value the sharper giving a more glossy feeling to the result.
  30656. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30657. */
  30658. specularPower: number;
  30659. private _useAlphaFromDiffuseTexture;
  30660. /**
  30661. * Does the transparency come from the diffuse texture alpha channel.
  30662. */
  30663. useAlphaFromDiffuseTexture: boolean;
  30664. private _useEmissiveAsIllumination;
  30665. /**
  30666. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30667. */
  30668. useEmissiveAsIllumination: boolean;
  30669. private _linkEmissiveWithDiffuse;
  30670. /**
  30671. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30672. * the emissive level when the final color is close to one.
  30673. */
  30674. linkEmissiveWithDiffuse: boolean;
  30675. private _useSpecularOverAlpha;
  30676. /**
  30677. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30678. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30679. */
  30680. useSpecularOverAlpha: boolean;
  30681. private _useReflectionOverAlpha;
  30682. /**
  30683. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30684. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30685. */
  30686. useReflectionOverAlpha: boolean;
  30687. private _disableLighting;
  30688. /**
  30689. * Does lights from the scene impacts this material.
  30690. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30691. */
  30692. disableLighting: boolean;
  30693. private _useObjectSpaceNormalMap;
  30694. /**
  30695. * Allows using an object space normal map (instead of tangent space).
  30696. */
  30697. useObjectSpaceNormalMap: boolean;
  30698. private _useParallax;
  30699. /**
  30700. * Is parallax enabled or not.
  30701. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30702. */
  30703. useParallax: boolean;
  30704. private _useParallaxOcclusion;
  30705. /**
  30706. * Is parallax occlusion enabled or not.
  30707. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30708. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30709. */
  30710. useParallaxOcclusion: boolean;
  30711. /**
  30712. * 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.
  30713. */
  30714. parallaxScaleBias: number;
  30715. private _roughness;
  30716. /**
  30717. * Helps to define how blurry the reflections should appears in the material.
  30718. */
  30719. roughness: number;
  30720. /**
  30721. * In case of refraction, define the value of the index of refraction.
  30722. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30723. */
  30724. indexOfRefraction: number;
  30725. /**
  30726. * Invert the refraction texture alongside the y axis.
  30727. * It can be useful with procedural textures or probe for instance.
  30728. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30729. */
  30730. invertRefractionY: boolean;
  30731. /**
  30732. * Defines the alpha limits in alpha test mode.
  30733. */
  30734. alphaCutOff: number;
  30735. private _useLightmapAsShadowmap;
  30736. /**
  30737. * In case of light mapping, define whether the map contains light or shadow informations.
  30738. */
  30739. useLightmapAsShadowmap: boolean;
  30740. private _diffuseFresnelParameters;
  30741. /**
  30742. * Define the diffuse fresnel parameters of the material.
  30743. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30744. */
  30745. diffuseFresnelParameters: FresnelParameters;
  30746. private _opacityFresnelParameters;
  30747. /**
  30748. * Define the opacity fresnel parameters of the material.
  30749. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30750. */
  30751. opacityFresnelParameters: FresnelParameters;
  30752. private _reflectionFresnelParameters;
  30753. /**
  30754. * Define the reflection fresnel parameters of the material.
  30755. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30756. */
  30757. reflectionFresnelParameters: FresnelParameters;
  30758. private _refractionFresnelParameters;
  30759. /**
  30760. * Define the refraction fresnel parameters of the material.
  30761. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30762. */
  30763. refractionFresnelParameters: FresnelParameters;
  30764. private _emissiveFresnelParameters;
  30765. /**
  30766. * Define the emissive fresnel parameters of the material.
  30767. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30768. */
  30769. emissiveFresnelParameters: FresnelParameters;
  30770. private _useReflectionFresnelFromSpecular;
  30771. /**
  30772. * If true automatically deducts the fresnels values from the material specularity.
  30773. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30774. */
  30775. useReflectionFresnelFromSpecular: boolean;
  30776. private _useGlossinessFromSpecularMapAlpha;
  30777. /**
  30778. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30779. */
  30780. useGlossinessFromSpecularMapAlpha: boolean;
  30781. private _maxSimultaneousLights;
  30782. /**
  30783. * Defines the maximum number of lights that can be used in the material
  30784. */
  30785. maxSimultaneousLights: number;
  30786. private _invertNormalMapX;
  30787. /**
  30788. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30789. */
  30790. invertNormalMapX: boolean;
  30791. private _invertNormalMapY;
  30792. /**
  30793. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30794. */
  30795. invertNormalMapY: boolean;
  30796. private _twoSidedLighting;
  30797. /**
  30798. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30799. */
  30800. twoSidedLighting: boolean;
  30801. /**
  30802. * Default configuration related to image processing available in the standard Material.
  30803. */
  30804. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30805. /**
  30806. * Gets the image processing configuration used either in this material.
  30807. */
  30808. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30809. /**
  30810. * Sets the Default image processing configuration used either in the this material.
  30811. *
  30812. * If sets to null, the scene one is in use.
  30813. */
  30814. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30815. /**
  30816. * Keep track of the image processing observer to allow dispose and replace.
  30817. */
  30818. private _imageProcessingObserver;
  30819. /**
  30820. * Attaches a new image processing configuration to the Standard Material.
  30821. * @param configuration
  30822. */
  30823. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30824. /**
  30825. * Gets wether the color curves effect is enabled.
  30826. */
  30827. get cameraColorCurvesEnabled(): boolean;
  30828. /**
  30829. * Sets wether the color curves effect is enabled.
  30830. */
  30831. set cameraColorCurvesEnabled(value: boolean);
  30832. /**
  30833. * Gets wether the color grading effect is enabled.
  30834. */
  30835. get cameraColorGradingEnabled(): boolean;
  30836. /**
  30837. * Gets wether the color grading effect is enabled.
  30838. */
  30839. set cameraColorGradingEnabled(value: boolean);
  30840. /**
  30841. * Gets wether tonemapping is enabled or not.
  30842. */
  30843. get cameraToneMappingEnabled(): boolean;
  30844. /**
  30845. * Sets wether tonemapping is enabled or not
  30846. */
  30847. set cameraToneMappingEnabled(value: boolean);
  30848. /**
  30849. * The camera exposure used on this material.
  30850. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30851. * This corresponds to a photographic exposure.
  30852. */
  30853. get cameraExposure(): number;
  30854. /**
  30855. * The camera exposure used on this material.
  30856. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30857. * This corresponds to a photographic exposure.
  30858. */
  30859. set cameraExposure(value: number);
  30860. /**
  30861. * Gets The camera contrast used on this material.
  30862. */
  30863. get cameraContrast(): number;
  30864. /**
  30865. * Sets The camera contrast used on this material.
  30866. */
  30867. set cameraContrast(value: number);
  30868. /**
  30869. * Gets the Color Grading 2D Lookup Texture.
  30870. */
  30871. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30872. /**
  30873. * Sets the Color Grading 2D Lookup Texture.
  30874. */
  30875. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30876. /**
  30877. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30878. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30879. * 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;
  30880. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30881. */
  30882. get cameraColorCurves(): Nullable<ColorCurves>;
  30883. /**
  30884. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30885. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30886. * 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;
  30887. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30888. */
  30889. set cameraColorCurves(value: Nullable<ColorCurves>);
  30890. /**
  30891. * Can this material render to several textures at once
  30892. */
  30893. get canRenderToMRT(): boolean;
  30894. /**
  30895. * Defines the detail map parameters for the material.
  30896. */
  30897. readonly detailMap: DetailMapConfiguration;
  30898. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30899. protected _worldViewProjectionMatrix: Matrix;
  30900. protected _globalAmbientColor: Color3;
  30901. protected _useLogarithmicDepth: boolean;
  30902. protected _rebuildInParallel: boolean;
  30903. /**
  30904. * Instantiates a new standard material.
  30905. * This is the default material used in Babylon. It is the best trade off between quality
  30906. * and performances.
  30907. * @see https://doc.babylonjs.com/babylon101/materials
  30908. * @param name Define the name of the material in the scene
  30909. * @param scene Define the scene the material belong to
  30910. */
  30911. constructor(name: string, scene: Scene);
  30912. /**
  30913. * Gets a boolean indicating that current material needs to register RTT
  30914. */
  30915. get hasRenderTargetTextures(): boolean;
  30916. /**
  30917. * Gets the current class name of the material e.g. "StandardMaterial"
  30918. * Mainly use in serialization.
  30919. * @returns the class name
  30920. */
  30921. getClassName(): string;
  30922. /**
  30923. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30924. * You can try switching to logarithmic depth.
  30925. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30926. */
  30927. get useLogarithmicDepth(): boolean;
  30928. set useLogarithmicDepth(value: boolean);
  30929. /**
  30930. * Specifies if the material will require alpha blending
  30931. * @returns a boolean specifying if alpha blending is needed
  30932. */
  30933. needAlphaBlending(): boolean;
  30934. /**
  30935. * Specifies if this material should be rendered in alpha test mode
  30936. * @returns a boolean specifying if an alpha test is needed.
  30937. */
  30938. needAlphaTesting(): boolean;
  30939. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30940. /**
  30941. * Get the texture used for alpha test purpose.
  30942. * @returns the diffuse texture in case of the standard material.
  30943. */
  30944. getAlphaTestTexture(): Nullable<BaseTexture>;
  30945. /**
  30946. * Get if the submesh is ready to be used and all its information available.
  30947. * Child classes can use it to update shaders
  30948. * @param mesh defines the mesh to check
  30949. * @param subMesh defines which submesh to check
  30950. * @param useInstances specifies that instances should be used
  30951. * @returns a boolean indicating that the submesh is ready or not
  30952. */
  30953. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30954. /**
  30955. * Builds the material UBO layouts.
  30956. * Used internally during the effect preparation.
  30957. */
  30958. buildUniformLayout(): void;
  30959. /**
  30960. * Unbinds the material from the mesh
  30961. */
  30962. unbind(): void;
  30963. /**
  30964. * Binds the submesh to this material by preparing the effect and shader to draw
  30965. * @param world defines the world transformation matrix
  30966. * @param mesh defines the mesh containing the submesh
  30967. * @param subMesh defines the submesh to bind the material to
  30968. */
  30969. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30970. /**
  30971. * Get the list of animatables in the material.
  30972. * @returns the list of animatables object used in the material
  30973. */
  30974. getAnimatables(): IAnimatable[];
  30975. /**
  30976. * Gets the active textures from the material
  30977. * @returns an array of textures
  30978. */
  30979. getActiveTextures(): BaseTexture[];
  30980. /**
  30981. * Specifies if the material uses a texture
  30982. * @param texture defines the texture to check against the material
  30983. * @returns a boolean specifying if the material uses the texture
  30984. */
  30985. hasTexture(texture: BaseTexture): boolean;
  30986. /**
  30987. * Disposes the material
  30988. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30989. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30990. */
  30991. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30992. /**
  30993. * Makes a duplicate of the material, and gives it a new name
  30994. * @param name defines the new name for the duplicated material
  30995. * @returns the cloned material
  30996. */
  30997. clone(name: string): StandardMaterial;
  30998. /**
  30999. * Serializes this material in a JSON representation
  31000. * @returns the serialized material object
  31001. */
  31002. serialize(): any;
  31003. /**
  31004. * Creates a standard material from parsed material data
  31005. * @param source defines the JSON representation of the material
  31006. * @param scene defines the hosting scene
  31007. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31008. * @returns a new standard material
  31009. */
  31010. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31011. /**
  31012. * Are diffuse textures enabled in the application.
  31013. */
  31014. static get DiffuseTextureEnabled(): boolean;
  31015. static set DiffuseTextureEnabled(value: boolean);
  31016. /**
  31017. * Are detail textures enabled in the application.
  31018. */
  31019. static get DetailTextureEnabled(): boolean;
  31020. static set DetailTextureEnabled(value: boolean);
  31021. /**
  31022. * Are ambient textures enabled in the application.
  31023. */
  31024. static get AmbientTextureEnabled(): boolean;
  31025. static set AmbientTextureEnabled(value: boolean);
  31026. /**
  31027. * Are opacity textures enabled in the application.
  31028. */
  31029. static get OpacityTextureEnabled(): boolean;
  31030. static set OpacityTextureEnabled(value: boolean);
  31031. /**
  31032. * Are reflection textures enabled in the application.
  31033. */
  31034. static get ReflectionTextureEnabled(): boolean;
  31035. static set ReflectionTextureEnabled(value: boolean);
  31036. /**
  31037. * Are emissive textures enabled in the application.
  31038. */
  31039. static get EmissiveTextureEnabled(): boolean;
  31040. static set EmissiveTextureEnabled(value: boolean);
  31041. /**
  31042. * Are specular textures enabled in the application.
  31043. */
  31044. static get SpecularTextureEnabled(): boolean;
  31045. static set SpecularTextureEnabled(value: boolean);
  31046. /**
  31047. * Are bump textures enabled in the application.
  31048. */
  31049. static get BumpTextureEnabled(): boolean;
  31050. static set BumpTextureEnabled(value: boolean);
  31051. /**
  31052. * Are lightmap textures enabled in the application.
  31053. */
  31054. static get LightmapTextureEnabled(): boolean;
  31055. static set LightmapTextureEnabled(value: boolean);
  31056. /**
  31057. * Are refraction textures enabled in the application.
  31058. */
  31059. static get RefractionTextureEnabled(): boolean;
  31060. static set RefractionTextureEnabled(value: boolean);
  31061. /**
  31062. * Are color grading textures enabled in the application.
  31063. */
  31064. static get ColorGradingTextureEnabled(): boolean;
  31065. static set ColorGradingTextureEnabled(value: boolean);
  31066. /**
  31067. * Are fresnels enabled in the application.
  31068. */
  31069. static get FresnelEnabled(): boolean;
  31070. static set FresnelEnabled(value: boolean);
  31071. }
  31072. }
  31073. declare module BABYLON {
  31074. /**
  31075. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31076. *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.
  31077. * The SPS is also a particle system. It provides some methods to manage the particles.
  31078. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31079. *
  31080. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31081. */
  31082. export class SolidParticleSystem implements IDisposable {
  31083. /**
  31084. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31085. * Example : var p = SPS.particles[i];
  31086. */
  31087. particles: SolidParticle[];
  31088. /**
  31089. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31090. */
  31091. nbParticles: number;
  31092. /**
  31093. * If the particles must ever face the camera (default false). Useful for planar particles.
  31094. */
  31095. billboard: boolean;
  31096. /**
  31097. * Recompute normals when adding a shape
  31098. */
  31099. recomputeNormals: boolean;
  31100. /**
  31101. * This a counter ofr your own usage. It's not set by any SPS functions.
  31102. */
  31103. counter: number;
  31104. /**
  31105. * The SPS name. This name is also given to the underlying mesh.
  31106. */
  31107. name: string;
  31108. /**
  31109. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31110. */
  31111. mesh: Mesh;
  31112. /**
  31113. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31114. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31115. */
  31116. vars: any;
  31117. /**
  31118. * This array is populated when the SPS is set as 'pickable'.
  31119. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31120. * Each element of this array is an object `{idx: int, faceId: int}`.
  31121. * `idx` is the picked particle index in the `SPS.particles` array
  31122. * `faceId` is the picked face index counted within this particle.
  31123. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31124. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31125. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31126. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31127. */
  31128. pickedParticles: {
  31129. idx: number;
  31130. faceId: number;
  31131. }[];
  31132. /**
  31133. * This array is populated when the SPS is set as 'pickable'
  31134. * Each key of this array is a submesh index.
  31135. * Each element of this array is a second array defined like this :
  31136. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31137. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31138. * `idx` is the picked particle index in the `SPS.particles` array
  31139. * `faceId` is the picked face index counted within this particle.
  31140. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31141. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31142. */
  31143. pickedBySubMesh: {
  31144. idx: number;
  31145. faceId: number;
  31146. }[][];
  31147. /**
  31148. * This array is populated when `enableDepthSort` is set to true.
  31149. * Each element of this array is an instance of the class DepthSortedParticle.
  31150. */
  31151. depthSortedParticles: DepthSortedParticle[];
  31152. /**
  31153. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31154. * @hidden
  31155. */
  31156. _bSphereOnly: boolean;
  31157. /**
  31158. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31159. * @hidden
  31160. */
  31161. _bSphereRadiusFactor: number;
  31162. private _scene;
  31163. private _positions;
  31164. private _indices;
  31165. private _normals;
  31166. private _colors;
  31167. private _uvs;
  31168. private _indices32;
  31169. private _positions32;
  31170. private _normals32;
  31171. private _fixedNormal32;
  31172. private _colors32;
  31173. private _uvs32;
  31174. private _index;
  31175. private _updatable;
  31176. private _pickable;
  31177. private _isVisibilityBoxLocked;
  31178. private _alwaysVisible;
  31179. private _depthSort;
  31180. private _expandable;
  31181. private _shapeCounter;
  31182. private _copy;
  31183. private _color;
  31184. private _computeParticleColor;
  31185. private _computeParticleTexture;
  31186. private _computeParticleRotation;
  31187. private _computeParticleVertex;
  31188. private _computeBoundingBox;
  31189. private _depthSortParticles;
  31190. private _camera;
  31191. private _mustUnrotateFixedNormals;
  31192. private _particlesIntersect;
  31193. private _needs32Bits;
  31194. private _isNotBuilt;
  31195. private _lastParticleId;
  31196. private _idxOfId;
  31197. private _multimaterialEnabled;
  31198. private _useModelMaterial;
  31199. private _indicesByMaterial;
  31200. private _materialIndexes;
  31201. private _depthSortFunction;
  31202. private _materialSortFunction;
  31203. private _materials;
  31204. private _multimaterial;
  31205. private _materialIndexesById;
  31206. private _defaultMaterial;
  31207. private _autoUpdateSubMeshes;
  31208. private _tmpVertex;
  31209. /**
  31210. * Creates a SPS (Solid Particle System) object.
  31211. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31212. * @param scene (Scene) is the scene in which the SPS is added.
  31213. * @param options defines the options of the sps e.g.
  31214. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31215. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31216. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31217. * * 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.
  31218. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31219. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31220. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31221. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31222. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31223. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31224. */
  31225. constructor(name: string, scene: Scene, options?: {
  31226. updatable?: boolean;
  31227. isPickable?: boolean;
  31228. enableDepthSort?: boolean;
  31229. particleIntersection?: boolean;
  31230. boundingSphereOnly?: boolean;
  31231. bSphereRadiusFactor?: number;
  31232. expandable?: boolean;
  31233. useModelMaterial?: boolean;
  31234. enableMultiMaterial?: boolean;
  31235. });
  31236. /**
  31237. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31238. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31239. * @returns the created mesh
  31240. */
  31241. buildMesh(): Mesh;
  31242. /**
  31243. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31244. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31245. * Thus the particles generated from `digest()` have their property `position` set yet.
  31246. * @param mesh ( Mesh ) is the mesh to be digested
  31247. * @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
  31248. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31249. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31250. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31251. * @returns the current SPS
  31252. */
  31253. digest(mesh: Mesh, options?: {
  31254. facetNb?: number;
  31255. number?: number;
  31256. delta?: number;
  31257. storage?: [];
  31258. }): SolidParticleSystem;
  31259. /**
  31260. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31261. * @hidden
  31262. */
  31263. private _unrotateFixedNormals;
  31264. /**
  31265. * Resets the temporary working copy particle
  31266. * @hidden
  31267. */
  31268. private _resetCopy;
  31269. /**
  31270. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31271. * @param p the current index in the positions array to be updated
  31272. * @param ind the current index in the indices array
  31273. * @param shape a Vector3 array, the shape geometry
  31274. * @param positions the positions array to be updated
  31275. * @param meshInd the shape indices array
  31276. * @param indices the indices array to be updated
  31277. * @param meshUV the shape uv array
  31278. * @param uvs the uv array to be updated
  31279. * @param meshCol the shape color array
  31280. * @param colors the color array to be updated
  31281. * @param meshNor the shape normals array
  31282. * @param normals the normals array to be updated
  31283. * @param idx the particle index
  31284. * @param idxInShape the particle index in its shape
  31285. * @param options the addShape() method passed options
  31286. * @model the particle model
  31287. * @hidden
  31288. */
  31289. private _meshBuilder;
  31290. /**
  31291. * Returns a shape Vector3 array from positions float array
  31292. * @param positions float array
  31293. * @returns a vector3 array
  31294. * @hidden
  31295. */
  31296. private _posToShape;
  31297. /**
  31298. * Returns a shapeUV array from a float uvs (array deep copy)
  31299. * @param uvs as a float array
  31300. * @returns a shapeUV array
  31301. * @hidden
  31302. */
  31303. private _uvsToShapeUV;
  31304. /**
  31305. * Adds a new particle object in the particles array
  31306. * @param idx particle index in particles array
  31307. * @param id particle id
  31308. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31309. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31310. * @param model particle ModelShape object
  31311. * @param shapeId model shape identifier
  31312. * @param idxInShape index of the particle in the current model
  31313. * @param bInfo model bounding info object
  31314. * @param storage target storage array, if any
  31315. * @hidden
  31316. */
  31317. private _addParticle;
  31318. /**
  31319. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31320. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31321. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31322. * @param nb (positive integer) the number of particles to be created from this model
  31323. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31324. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31325. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31326. * @returns the number of shapes in the system
  31327. */
  31328. addShape(mesh: Mesh, nb: number, options?: {
  31329. positionFunction?: any;
  31330. vertexFunction?: any;
  31331. storage?: [];
  31332. }): number;
  31333. /**
  31334. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31335. * @hidden
  31336. */
  31337. private _rebuildParticle;
  31338. /**
  31339. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31340. * @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.
  31341. * @returns the SPS.
  31342. */
  31343. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31344. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31345. * Returns an array with the removed particles.
  31346. * 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.
  31347. * The SPS can't be empty so at least one particle needs to remain in place.
  31348. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31349. * @param start index of the first particle to remove
  31350. * @param end index of the last particle to remove (included)
  31351. * @returns an array populated with the removed particles
  31352. */
  31353. removeParticles(start: number, end: number): SolidParticle[];
  31354. /**
  31355. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31356. * @param solidParticleArray an array populated with Solid Particles objects
  31357. * @returns the SPS
  31358. */
  31359. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31360. /**
  31361. * Creates a new particle and modifies the SPS mesh geometry :
  31362. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31363. * - calls _addParticle() to populate the particle array
  31364. * factorized code from addShape() and insertParticlesFromArray()
  31365. * @param idx particle index in the particles array
  31366. * @param i particle index in its shape
  31367. * @param modelShape particle ModelShape object
  31368. * @param shape shape vertex array
  31369. * @param meshInd shape indices array
  31370. * @param meshUV shape uv array
  31371. * @param meshCol shape color array
  31372. * @param meshNor shape normals array
  31373. * @param bbInfo shape bounding info
  31374. * @param storage target particle storage
  31375. * @options addShape() passed options
  31376. * @hidden
  31377. */
  31378. private _insertNewParticle;
  31379. /**
  31380. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31381. * This method calls `updateParticle()` for each particle of the SPS.
  31382. * For an animated SPS, it is usually called within the render loop.
  31383. * 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.
  31384. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31385. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31386. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31387. * @returns the SPS.
  31388. */
  31389. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31390. /**
  31391. * Disposes the SPS.
  31392. */
  31393. dispose(): void;
  31394. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31395. * idx is the particle index in the SPS
  31396. * faceId is the picked face index counted within this particle.
  31397. * Returns null if the pickInfo can't identify a picked particle.
  31398. * @param pickingInfo (PickingInfo object)
  31399. * @returns {idx: number, faceId: number} or null
  31400. */
  31401. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31402. idx: number;
  31403. faceId: number;
  31404. }>;
  31405. /**
  31406. * Returns a SolidParticle object from its identifier : particle.id
  31407. * @param id (integer) the particle Id
  31408. * @returns the searched particle or null if not found in the SPS.
  31409. */
  31410. getParticleById(id: number): Nullable<SolidParticle>;
  31411. /**
  31412. * Returns a new array populated with the particles having the passed shapeId.
  31413. * @param shapeId (integer) the shape identifier
  31414. * @returns a new solid particle array
  31415. */
  31416. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31417. /**
  31418. * Populates the passed array "ref" with the particles having the passed shapeId.
  31419. * @param shapeId the shape identifier
  31420. * @returns the SPS
  31421. * @param ref
  31422. */
  31423. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31424. /**
  31425. * Computes the required SubMeshes according the materials assigned to the particles.
  31426. * @returns the solid particle system.
  31427. * Does nothing if called before the SPS mesh is built.
  31428. */
  31429. computeSubMeshes(): SolidParticleSystem;
  31430. /**
  31431. * Sorts the solid particles by material when MultiMaterial is enabled.
  31432. * Updates the indices32 array.
  31433. * Updates the indicesByMaterial array.
  31434. * Updates the mesh indices array.
  31435. * @returns the SPS
  31436. * @hidden
  31437. */
  31438. private _sortParticlesByMaterial;
  31439. /**
  31440. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31441. * @hidden
  31442. */
  31443. private _setMaterialIndexesById;
  31444. /**
  31445. * Returns an array with unique values of Materials from the passed array
  31446. * @param array the material array to be checked and filtered
  31447. * @hidden
  31448. */
  31449. private _filterUniqueMaterialId;
  31450. /**
  31451. * Sets a new Standard Material as _defaultMaterial if not already set.
  31452. * @hidden
  31453. */
  31454. private _setDefaultMaterial;
  31455. /**
  31456. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31457. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31458. * @returns the SPS.
  31459. */
  31460. refreshVisibleSize(): SolidParticleSystem;
  31461. /**
  31462. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31463. * @param size the size (float) of the visibility box
  31464. * note : this doesn't lock the SPS mesh bounding box.
  31465. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31466. */
  31467. setVisibilityBox(size: number): void;
  31468. /**
  31469. * Gets whether the SPS as always visible or not
  31470. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31471. */
  31472. get isAlwaysVisible(): boolean;
  31473. /**
  31474. * Sets the SPS as always visible or not
  31475. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31476. */
  31477. set isAlwaysVisible(val: boolean);
  31478. /**
  31479. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31480. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31481. */
  31482. set isVisibilityBoxLocked(val: boolean);
  31483. /**
  31484. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31485. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31486. */
  31487. get isVisibilityBoxLocked(): boolean;
  31488. /**
  31489. * Tells to `setParticles()` to compute the particle rotations or not.
  31490. * Default value : true. The SPS is faster when it's set to false.
  31491. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31492. */
  31493. set computeParticleRotation(val: boolean);
  31494. /**
  31495. * Tells to `setParticles()` to compute the particle colors or not.
  31496. * Default value : true. The SPS is faster when it's set to false.
  31497. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31498. */
  31499. set computeParticleColor(val: boolean);
  31500. set computeParticleTexture(val: boolean);
  31501. /**
  31502. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31503. * Default value : false. The SPS is faster when it's set to false.
  31504. * Note : the particle custom vertex positions aren't stored values.
  31505. */
  31506. set computeParticleVertex(val: boolean);
  31507. /**
  31508. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31509. */
  31510. set computeBoundingBox(val: boolean);
  31511. /**
  31512. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31513. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31514. * Default : `true`
  31515. */
  31516. set depthSortParticles(val: boolean);
  31517. /**
  31518. * Gets if `setParticles()` computes the particle rotations or not.
  31519. * Default value : true. The SPS is faster when it's set to false.
  31520. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31521. */
  31522. get computeParticleRotation(): boolean;
  31523. /**
  31524. * Gets if `setParticles()` computes the particle colors or not.
  31525. * Default value : true. The SPS is faster when it's set to false.
  31526. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31527. */
  31528. get computeParticleColor(): boolean;
  31529. /**
  31530. * Gets if `setParticles()` computes the particle textures or not.
  31531. * Default value : true. The SPS is faster when it's set to false.
  31532. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31533. */
  31534. get computeParticleTexture(): boolean;
  31535. /**
  31536. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31537. * Default value : false. The SPS is faster when it's set to false.
  31538. * Note : the particle custom vertex positions aren't stored values.
  31539. */
  31540. get computeParticleVertex(): boolean;
  31541. /**
  31542. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31543. */
  31544. get computeBoundingBox(): boolean;
  31545. /**
  31546. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31547. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31548. * Default : `true`
  31549. */
  31550. get depthSortParticles(): boolean;
  31551. /**
  31552. * Gets if the SPS is created as expandable at construction time.
  31553. * Default : `false`
  31554. */
  31555. get expandable(): boolean;
  31556. /**
  31557. * Gets if the SPS supports the Multi Materials
  31558. */
  31559. get multimaterialEnabled(): boolean;
  31560. /**
  31561. * Gets if the SPS uses the model materials for its own multimaterial.
  31562. */
  31563. get useModelMaterial(): boolean;
  31564. /**
  31565. * The SPS used material array.
  31566. */
  31567. get materials(): Material[];
  31568. /**
  31569. * Sets the SPS MultiMaterial from the passed materials.
  31570. * Note : the passed array is internally copied and not used then by reference.
  31571. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31572. */
  31573. setMultiMaterial(materials: Material[]): void;
  31574. /**
  31575. * The SPS computed multimaterial object
  31576. */
  31577. get multimaterial(): MultiMaterial;
  31578. set multimaterial(mm: MultiMaterial);
  31579. /**
  31580. * If the subMeshes must be updated on the next call to setParticles()
  31581. */
  31582. get autoUpdateSubMeshes(): boolean;
  31583. set autoUpdateSubMeshes(val: boolean);
  31584. /**
  31585. * This function does nothing. It may be overwritten to set all the particle first values.
  31586. * The SPS doesn't call this function, you may have to call it by your own.
  31587. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31588. */
  31589. initParticles(): void;
  31590. /**
  31591. * This function does nothing. It may be overwritten to recycle a particle.
  31592. * The SPS doesn't call this function, you may have to call it by your own.
  31593. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31594. * @param particle The particle to recycle
  31595. * @returns the recycled particle
  31596. */
  31597. recycleParticle(particle: SolidParticle): SolidParticle;
  31598. /**
  31599. * Updates a particle : this function should be overwritten by the user.
  31600. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31601. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31602. * @example : just set a particle position or velocity and recycle conditions
  31603. * @param particle The particle to update
  31604. * @returns the updated particle
  31605. */
  31606. updateParticle(particle: SolidParticle): SolidParticle;
  31607. /**
  31608. * Updates a vertex of a particle : it can be overwritten by the user.
  31609. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31610. * @param particle the current particle
  31611. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31612. * @param pt the index of the current vertex in the particle shape
  31613. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31614. * @example : just set a vertex particle position or color
  31615. * @returns the sps
  31616. */
  31617. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31618. /**
  31619. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31620. * This does nothing and may be overwritten by the user.
  31621. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31622. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31623. * @param update the boolean update value actually passed to setParticles()
  31624. */
  31625. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31626. /**
  31627. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31628. * This will be passed three parameters.
  31629. * This does nothing and may be overwritten by the user.
  31630. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31631. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31632. * @param update the boolean update value actually passed to setParticles()
  31633. */
  31634. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31635. }
  31636. }
  31637. declare module BABYLON {
  31638. /**
  31639. * Represents one particle of a solid particle system.
  31640. */
  31641. export class SolidParticle {
  31642. /**
  31643. * particle global index
  31644. */
  31645. idx: number;
  31646. /**
  31647. * particle identifier
  31648. */
  31649. id: number;
  31650. /**
  31651. * The color of the particle
  31652. */
  31653. color: Nullable<Color4>;
  31654. /**
  31655. * The world space position of the particle.
  31656. */
  31657. position: Vector3;
  31658. /**
  31659. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31660. */
  31661. rotation: Vector3;
  31662. /**
  31663. * The world space rotation quaternion of the particle.
  31664. */
  31665. rotationQuaternion: Nullable<Quaternion>;
  31666. /**
  31667. * The scaling of the particle.
  31668. */
  31669. scaling: Vector3;
  31670. /**
  31671. * The uvs of the particle.
  31672. */
  31673. uvs: Vector4;
  31674. /**
  31675. * The current speed of the particle.
  31676. */
  31677. velocity: Vector3;
  31678. /**
  31679. * The pivot point in the particle local space.
  31680. */
  31681. pivot: Vector3;
  31682. /**
  31683. * Must the particle be translated from its pivot point in its local space ?
  31684. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31685. * Default : false
  31686. */
  31687. translateFromPivot: boolean;
  31688. /**
  31689. * Is the particle active or not ?
  31690. */
  31691. alive: boolean;
  31692. /**
  31693. * Is the particle visible or not ?
  31694. */
  31695. isVisible: boolean;
  31696. /**
  31697. * Index of this particle in the global "positions" array (Internal use)
  31698. * @hidden
  31699. */
  31700. _pos: number;
  31701. /**
  31702. * @hidden Index of this particle in the global "indices" array (Internal use)
  31703. */
  31704. _ind: number;
  31705. /**
  31706. * @hidden ModelShape of this particle (Internal use)
  31707. */
  31708. _model: ModelShape;
  31709. /**
  31710. * ModelShape id of this particle
  31711. */
  31712. shapeId: number;
  31713. /**
  31714. * Index of the particle in its shape id
  31715. */
  31716. idxInShape: number;
  31717. /**
  31718. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31719. */
  31720. _modelBoundingInfo: BoundingInfo;
  31721. /**
  31722. * @hidden Particle BoundingInfo object (Internal use)
  31723. */
  31724. _boundingInfo: BoundingInfo;
  31725. /**
  31726. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31727. */
  31728. _sps: SolidParticleSystem;
  31729. /**
  31730. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31731. */
  31732. _stillInvisible: boolean;
  31733. /**
  31734. * @hidden Last computed particle rotation matrix
  31735. */
  31736. _rotationMatrix: number[];
  31737. /**
  31738. * Parent particle Id, if any.
  31739. * Default null.
  31740. */
  31741. parentId: Nullable<number>;
  31742. /**
  31743. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31744. */
  31745. materialIndex: Nullable<number>;
  31746. /**
  31747. * Custom object or properties.
  31748. */
  31749. props: Nullable<any>;
  31750. /**
  31751. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31752. * The possible values are :
  31753. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31754. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31755. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31756. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31757. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31758. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31759. * */
  31760. cullingStrategy: number;
  31761. /**
  31762. * @hidden Internal global position in the SPS.
  31763. */
  31764. _globalPosition: Vector3;
  31765. /**
  31766. * Creates a Solid Particle object.
  31767. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31768. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31769. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31770. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31771. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31772. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31773. * @param shapeId (integer) is the model shape identifier in the SPS.
  31774. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31775. * @param sps defines the sps it is associated to
  31776. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31777. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31778. */
  31779. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31780. /**
  31781. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31782. * @param target the particle target
  31783. * @returns the current particle
  31784. */
  31785. copyToRef(target: SolidParticle): SolidParticle;
  31786. /**
  31787. * Legacy support, changed scale to scaling
  31788. */
  31789. get scale(): Vector3;
  31790. /**
  31791. * Legacy support, changed scale to scaling
  31792. */
  31793. set scale(scale: Vector3);
  31794. /**
  31795. * Legacy support, changed quaternion to rotationQuaternion
  31796. */
  31797. get quaternion(): Nullable<Quaternion>;
  31798. /**
  31799. * Legacy support, changed quaternion to rotationQuaternion
  31800. */
  31801. set quaternion(q: Nullable<Quaternion>);
  31802. /**
  31803. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31804. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31805. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31806. * @returns true if it intersects
  31807. */
  31808. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31809. /**
  31810. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31811. * A particle is in the frustum if its bounding box intersects the frustum
  31812. * @param frustumPlanes defines the frustum to test
  31813. * @returns true if the particle is in the frustum planes
  31814. */
  31815. isInFrustum(frustumPlanes: Plane[]): boolean;
  31816. /**
  31817. * get the rotation matrix of the particle
  31818. * @hidden
  31819. */
  31820. getRotationMatrix(m: Matrix): void;
  31821. }
  31822. /**
  31823. * Represents the shape of the model used by one particle of a solid particle system.
  31824. * SPS internal tool, don't use it manually.
  31825. */
  31826. export class ModelShape {
  31827. /**
  31828. * The shape id
  31829. * @hidden
  31830. */
  31831. shapeID: number;
  31832. /**
  31833. * flat array of model positions (internal use)
  31834. * @hidden
  31835. */
  31836. _shape: Vector3[];
  31837. /**
  31838. * flat array of model UVs (internal use)
  31839. * @hidden
  31840. */
  31841. _shapeUV: number[];
  31842. /**
  31843. * color array of the model
  31844. * @hidden
  31845. */
  31846. _shapeColors: number[];
  31847. /**
  31848. * indices array of the model
  31849. * @hidden
  31850. */
  31851. _indices: number[];
  31852. /**
  31853. * normals array of the model
  31854. * @hidden
  31855. */
  31856. _normals: number[];
  31857. /**
  31858. * length of the shape in the model indices array (internal use)
  31859. * @hidden
  31860. */
  31861. _indicesLength: number;
  31862. /**
  31863. * Custom position function (internal use)
  31864. * @hidden
  31865. */
  31866. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31867. /**
  31868. * Custom vertex function (internal use)
  31869. * @hidden
  31870. */
  31871. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31872. /**
  31873. * Model material (internal use)
  31874. * @hidden
  31875. */
  31876. _material: Nullable<Material>;
  31877. /**
  31878. * 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.
  31879. * SPS internal tool, don't use it manually.
  31880. * @hidden
  31881. */
  31882. 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>);
  31883. }
  31884. /**
  31885. * Represents a Depth Sorted Particle in the solid particle system.
  31886. * @hidden
  31887. */
  31888. export class DepthSortedParticle {
  31889. /**
  31890. * Particle index
  31891. */
  31892. idx: number;
  31893. /**
  31894. * Index of the particle in the "indices" array
  31895. */
  31896. ind: number;
  31897. /**
  31898. * Length of the particle shape in the "indices" array
  31899. */
  31900. indicesLength: number;
  31901. /**
  31902. * Squared distance from the particle to the camera
  31903. */
  31904. sqDistance: number;
  31905. /**
  31906. * Material index when used with MultiMaterials
  31907. */
  31908. materialIndex: number;
  31909. /**
  31910. * Creates a new sorted particle
  31911. * @param materialIndex
  31912. */
  31913. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31914. }
  31915. /**
  31916. * Represents a solid particle vertex
  31917. */
  31918. export class SolidParticleVertex {
  31919. /**
  31920. * Vertex position
  31921. */
  31922. position: Vector3;
  31923. /**
  31924. * Vertex color
  31925. */
  31926. color: Color4;
  31927. /**
  31928. * Vertex UV
  31929. */
  31930. uv: Vector2;
  31931. /**
  31932. * Creates a new solid particle vertex
  31933. */
  31934. constructor();
  31935. /** Vertex x coordinate */
  31936. get x(): number;
  31937. set x(val: number);
  31938. /** Vertex y coordinate */
  31939. get y(): number;
  31940. set y(val: number);
  31941. /** Vertex z coordinate */
  31942. get z(): number;
  31943. set z(val: number);
  31944. }
  31945. }
  31946. declare module BABYLON {
  31947. /**
  31948. * @hidden
  31949. */
  31950. export class _MeshCollisionData {
  31951. _checkCollisions: boolean;
  31952. _collisionMask: number;
  31953. _collisionGroup: number;
  31954. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31955. _collider: Nullable<Collider>;
  31956. _oldPositionForCollisions: Vector3;
  31957. _diffPositionForCollisions: Vector3;
  31958. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31959. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31960. _collisionResponse: boolean;
  31961. }
  31962. }
  31963. declare module BABYLON {
  31964. /** @hidden */
  31965. class _FacetDataStorage {
  31966. facetPositions: Vector3[];
  31967. facetNormals: Vector3[];
  31968. facetPartitioning: number[][];
  31969. facetNb: number;
  31970. partitioningSubdivisions: number;
  31971. partitioningBBoxRatio: number;
  31972. facetDataEnabled: boolean;
  31973. facetParameters: any;
  31974. bbSize: Vector3;
  31975. subDiv: {
  31976. max: number;
  31977. X: number;
  31978. Y: number;
  31979. Z: number;
  31980. };
  31981. facetDepthSort: boolean;
  31982. facetDepthSortEnabled: boolean;
  31983. depthSortedIndices: IndicesArray;
  31984. depthSortedFacets: {
  31985. ind: number;
  31986. sqDistance: number;
  31987. }[];
  31988. facetDepthSortFunction: (f1: {
  31989. ind: number;
  31990. sqDistance: number;
  31991. }, f2: {
  31992. ind: number;
  31993. sqDistance: number;
  31994. }) => number;
  31995. facetDepthSortFrom: Vector3;
  31996. facetDepthSortOrigin: Vector3;
  31997. invertedMatrix: Matrix;
  31998. }
  31999. /**
  32000. * @hidden
  32001. **/
  32002. class _InternalAbstractMeshDataInfo {
  32003. _hasVertexAlpha: boolean;
  32004. _useVertexColors: boolean;
  32005. _numBoneInfluencers: number;
  32006. _applyFog: boolean;
  32007. _receiveShadows: boolean;
  32008. _facetData: _FacetDataStorage;
  32009. _visibility: number;
  32010. _skeleton: Nullable<Skeleton>;
  32011. _layerMask: number;
  32012. _computeBonesUsingShaders: boolean;
  32013. _isActive: boolean;
  32014. _onlyForInstances: boolean;
  32015. _isActiveIntermediate: boolean;
  32016. _onlyForInstancesIntermediate: boolean;
  32017. _actAsRegularMesh: boolean;
  32018. }
  32019. /**
  32020. * Class used to store all common mesh properties
  32021. */
  32022. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32023. /** No occlusion */
  32024. static OCCLUSION_TYPE_NONE: number;
  32025. /** Occlusion set to optimisitic */
  32026. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32027. /** Occlusion set to strict */
  32028. static OCCLUSION_TYPE_STRICT: number;
  32029. /** Use an accurante occlusion algorithm */
  32030. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32031. /** Use a conservative occlusion algorithm */
  32032. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32033. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32034. * Test order :
  32035. * Is the bounding sphere outside the frustum ?
  32036. * If not, are the bounding box vertices outside the frustum ?
  32037. * It not, then the cullable object is in the frustum.
  32038. */
  32039. static readonly CULLINGSTRATEGY_STANDARD: number;
  32040. /** Culling strategy : Bounding Sphere Only.
  32041. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32042. * It's also less accurate than the standard because some not visible objects can still be selected.
  32043. * Test : is the bounding sphere outside the frustum ?
  32044. * If not, then the cullable object is in the frustum.
  32045. */
  32046. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32047. /** Culling strategy : Optimistic Inclusion.
  32048. * This in an inclusion test first, then the standard exclusion test.
  32049. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32050. * 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.
  32051. * Anyway, it's as accurate as the standard strategy.
  32052. * Test :
  32053. * Is the cullable object bounding sphere center in the frustum ?
  32054. * If not, apply the default culling strategy.
  32055. */
  32056. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32057. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32058. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32059. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32060. * 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.
  32061. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32062. * Test :
  32063. * Is the cullable object bounding sphere center in the frustum ?
  32064. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32065. */
  32066. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32067. /**
  32068. * No billboard
  32069. */
  32070. static get BILLBOARDMODE_NONE(): number;
  32071. /** Billboard on X axis */
  32072. static get BILLBOARDMODE_X(): number;
  32073. /** Billboard on Y axis */
  32074. static get BILLBOARDMODE_Y(): number;
  32075. /** Billboard on Z axis */
  32076. static get BILLBOARDMODE_Z(): number;
  32077. /** Billboard on all axes */
  32078. static get BILLBOARDMODE_ALL(): number;
  32079. /** Billboard on using position instead of orientation */
  32080. static get BILLBOARDMODE_USE_POSITION(): number;
  32081. /** @hidden */
  32082. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32083. /**
  32084. * The culling strategy to use to check whether the mesh must be rendered or not.
  32085. * This value can be changed at any time and will be used on the next render mesh selection.
  32086. * The possible values are :
  32087. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32088. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32089. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32090. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32091. * Please read each static variable documentation to get details about the culling process.
  32092. * */
  32093. cullingStrategy: number;
  32094. /**
  32095. * Gets the number of facets in the mesh
  32096. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32097. */
  32098. get facetNb(): number;
  32099. /**
  32100. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32101. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32102. */
  32103. get partitioningSubdivisions(): number;
  32104. set partitioningSubdivisions(nb: number);
  32105. /**
  32106. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32107. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32108. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32109. */
  32110. get partitioningBBoxRatio(): number;
  32111. set partitioningBBoxRatio(ratio: number);
  32112. /**
  32113. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32114. * Works only for updatable meshes.
  32115. * Doesn't work with multi-materials
  32116. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32117. */
  32118. get mustDepthSortFacets(): boolean;
  32119. set mustDepthSortFacets(sort: boolean);
  32120. /**
  32121. * The location (Vector3) where the facet depth sort must be computed from.
  32122. * By default, the active camera position.
  32123. * Used only when facet depth sort is enabled
  32124. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32125. */
  32126. get facetDepthSortFrom(): Vector3;
  32127. set facetDepthSortFrom(location: Vector3);
  32128. /**
  32129. * gets a boolean indicating if facetData is enabled
  32130. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32131. */
  32132. get isFacetDataEnabled(): boolean;
  32133. /** @hidden */
  32134. _updateNonUniformScalingState(value: boolean): boolean;
  32135. /**
  32136. * An event triggered when this mesh collides with another one
  32137. */
  32138. onCollideObservable: Observable<AbstractMesh>;
  32139. /** Set a function to call when this mesh collides with another one */
  32140. set onCollide(callback: () => void);
  32141. /**
  32142. * An event triggered when the collision's position changes
  32143. */
  32144. onCollisionPositionChangeObservable: Observable<Vector3>;
  32145. /** Set a function to call when the collision's position changes */
  32146. set onCollisionPositionChange(callback: () => void);
  32147. /**
  32148. * An event triggered when material is changed
  32149. */
  32150. onMaterialChangedObservable: Observable<AbstractMesh>;
  32151. /**
  32152. * Gets or sets the orientation for POV movement & rotation
  32153. */
  32154. definedFacingForward: boolean;
  32155. /** @hidden */
  32156. _occlusionQuery: Nullable<WebGLQuery>;
  32157. /** @hidden */
  32158. _renderingGroup: Nullable<RenderingGroup>;
  32159. /**
  32160. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32161. */
  32162. get visibility(): number;
  32163. /**
  32164. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32165. */
  32166. set visibility(value: number);
  32167. /** Gets or sets the alpha index used to sort transparent meshes
  32168. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32169. */
  32170. alphaIndex: number;
  32171. /**
  32172. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32173. */
  32174. isVisible: boolean;
  32175. /**
  32176. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32177. */
  32178. isPickable: boolean;
  32179. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32180. showSubMeshesBoundingBox: boolean;
  32181. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32182. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32183. */
  32184. isBlocker: boolean;
  32185. /**
  32186. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32187. */
  32188. enablePointerMoveEvents: boolean;
  32189. private _renderingGroupId;
  32190. /**
  32191. * Specifies the rendering group id for this mesh (0 by default)
  32192. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32193. */
  32194. get renderingGroupId(): number;
  32195. set renderingGroupId(value: number);
  32196. private _material;
  32197. /** Gets or sets current material */
  32198. get material(): Nullable<Material>;
  32199. set material(value: Nullable<Material>);
  32200. /**
  32201. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32202. * @see https://doc.babylonjs.com/babylon101/shadows
  32203. */
  32204. get receiveShadows(): boolean;
  32205. set receiveShadows(value: boolean);
  32206. /** Defines color to use when rendering outline */
  32207. outlineColor: Color3;
  32208. /** Define width to use when rendering outline */
  32209. outlineWidth: number;
  32210. /** Defines color to use when rendering overlay */
  32211. overlayColor: Color3;
  32212. /** Defines alpha to use when rendering overlay */
  32213. overlayAlpha: number;
  32214. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32215. get hasVertexAlpha(): boolean;
  32216. set hasVertexAlpha(value: boolean);
  32217. /** 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) */
  32218. get useVertexColors(): boolean;
  32219. set useVertexColors(value: boolean);
  32220. /**
  32221. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32222. */
  32223. get computeBonesUsingShaders(): boolean;
  32224. set computeBonesUsingShaders(value: boolean);
  32225. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32226. get numBoneInfluencers(): number;
  32227. set numBoneInfluencers(value: number);
  32228. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32229. get applyFog(): boolean;
  32230. set applyFog(value: boolean);
  32231. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32232. useOctreeForRenderingSelection: boolean;
  32233. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32234. useOctreeForPicking: boolean;
  32235. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32236. useOctreeForCollisions: boolean;
  32237. /**
  32238. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32239. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32240. */
  32241. get layerMask(): number;
  32242. set layerMask(value: number);
  32243. /**
  32244. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32245. */
  32246. alwaysSelectAsActiveMesh: boolean;
  32247. /**
  32248. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32249. */
  32250. doNotSyncBoundingInfo: boolean;
  32251. /**
  32252. * Gets or sets the current action manager
  32253. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32254. */
  32255. actionManager: Nullable<AbstractActionManager>;
  32256. private _meshCollisionData;
  32257. /**
  32258. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32259. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32260. */
  32261. ellipsoid: Vector3;
  32262. /**
  32263. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32264. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32265. */
  32266. ellipsoidOffset: Vector3;
  32267. /**
  32268. * Gets or sets a collision mask used to mask collisions (default is -1).
  32269. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32270. */
  32271. get collisionMask(): number;
  32272. set collisionMask(mask: number);
  32273. /**
  32274. * Gets or sets a collision response flag (default is true).
  32275. * when collisionResponse is false, events are still triggered but colliding entity has no response
  32276. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  32277. * to respond to the collision.
  32278. */
  32279. get collisionResponse(): boolean;
  32280. set collisionResponse(response: boolean);
  32281. /**
  32282. * Gets or sets the current collision group mask (-1 by default).
  32283. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32284. */
  32285. get collisionGroup(): number;
  32286. set collisionGroup(mask: number);
  32287. /**
  32288. * Gets or sets current surrounding meshes (null by default).
  32289. *
  32290. * By default collision detection is tested against every mesh in the scene.
  32291. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32292. * meshes will be tested for the collision.
  32293. *
  32294. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32295. */
  32296. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32297. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32298. /**
  32299. * Defines edge width used when edgesRenderer is enabled
  32300. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32301. */
  32302. edgesWidth: number;
  32303. /**
  32304. * Defines edge color used when edgesRenderer is enabled
  32305. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32306. */
  32307. edgesColor: Color4;
  32308. /** @hidden */
  32309. _edgesRenderer: Nullable<IEdgesRenderer>;
  32310. /** @hidden */
  32311. _masterMesh: Nullable<AbstractMesh>;
  32312. /** @hidden */
  32313. _boundingInfo: Nullable<BoundingInfo>;
  32314. /** @hidden */
  32315. _renderId: number;
  32316. /**
  32317. * Gets or sets the list of subMeshes
  32318. * @see https://doc.babylonjs.com/how_to/multi_materials
  32319. */
  32320. subMeshes: SubMesh[];
  32321. /** @hidden */
  32322. _intersectionsInProgress: AbstractMesh[];
  32323. /** @hidden */
  32324. _unIndexed: boolean;
  32325. /** @hidden */
  32326. _lightSources: Light[];
  32327. /** Gets the list of lights affecting that mesh */
  32328. get lightSources(): Light[];
  32329. /** @hidden */
  32330. get _positions(): Nullable<Vector3[]>;
  32331. /** @hidden */
  32332. _waitingData: {
  32333. lods: Nullable<any>;
  32334. actions: Nullable<any>;
  32335. freezeWorldMatrix: Nullable<boolean>;
  32336. };
  32337. /** @hidden */
  32338. _bonesTransformMatrices: Nullable<Float32Array>;
  32339. /** @hidden */
  32340. _transformMatrixTexture: Nullable<RawTexture>;
  32341. /**
  32342. * Gets or sets a skeleton to apply skining transformations
  32343. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32344. */
  32345. set skeleton(value: Nullable<Skeleton>);
  32346. get skeleton(): Nullable<Skeleton>;
  32347. /**
  32348. * An event triggered when the mesh is rebuilt.
  32349. */
  32350. onRebuildObservable: Observable<AbstractMesh>;
  32351. /**
  32352. * Creates a new AbstractMesh
  32353. * @param name defines the name of the mesh
  32354. * @param scene defines the hosting scene
  32355. */
  32356. constructor(name: string, scene?: Nullable<Scene>);
  32357. /**
  32358. * Returns the string "AbstractMesh"
  32359. * @returns "AbstractMesh"
  32360. */
  32361. getClassName(): string;
  32362. /**
  32363. * Gets a string representation of the current mesh
  32364. * @param fullDetails defines a boolean indicating if full details must be included
  32365. * @returns a string representation of the current mesh
  32366. */
  32367. toString(fullDetails?: boolean): string;
  32368. /**
  32369. * @hidden
  32370. */
  32371. protected _getEffectiveParent(): Nullable<Node>;
  32372. /** @hidden */
  32373. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32374. /** @hidden */
  32375. _rebuild(): void;
  32376. /** @hidden */
  32377. _resyncLightSources(): void;
  32378. /** @hidden */
  32379. _resyncLightSource(light: Light): void;
  32380. /** @hidden */
  32381. _unBindEffect(): void;
  32382. /** @hidden */
  32383. _removeLightSource(light: Light, dispose: boolean): void;
  32384. private _markSubMeshesAsDirty;
  32385. /** @hidden */
  32386. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32387. /** @hidden */
  32388. _markSubMeshesAsAttributesDirty(): void;
  32389. /** @hidden */
  32390. _markSubMeshesAsMiscDirty(): void;
  32391. /**
  32392. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32393. */
  32394. get scaling(): Vector3;
  32395. set scaling(newScaling: Vector3);
  32396. /**
  32397. * Returns true if the mesh is blocked. Implemented by child classes
  32398. */
  32399. get isBlocked(): boolean;
  32400. /**
  32401. * Returns the mesh itself by default. Implemented by child classes
  32402. * @param camera defines the camera to use to pick the right LOD level
  32403. * @returns the currentAbstractMesh
  32404. */
  32405. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32406. /**
  32407. * Returns 0 by default. Implemented by child classes
  32408. * @returns an integer
  32409. */
  32410. getTotalVertices(): number;
  32411. /**
  32412. * Returns a positive integer : the total number of indices in this mesh geometry.
  32413. * @returns the numner of indices or zero if the mesh has no geometry.
  32414. */
  32415. getTotalIndices(): number;
  32416. /**
  32417. * Returns null by default. Implemented by child classes
  32418. * @returns null
  32419. */
  32420. getIndices(): Nullable<IndicesArray>;
  32421. /**
  32422. * Returns the array of the requested vertex data kind. Implemented by child classes
  32423. * @param kind defines the vertex data kind to use
  32424. * @returns null
  32425. */
  32426. getVerticesData(kind: string): Nullable<FloatArray>;
  32427. /**
  32428. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32429. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32430. * Note that a new underlying VertexBuffer object is created each call.
  32431. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32432. * @param kind defines vertex data kind:
  32433. * * VertexBuffer.PositionKind
  32434. * * VertexBuffer.UVKind
  32435. * * VertexBuffer.UV2Kind
  32436. * * VertexBuffer.UV3Kind
  32437. * * VertexBuffer.UV4Kind
  32438. * * VertexBuffer.UV5Kind
  32439. * * VertexBuffer.UV6Kind
  32440. * * VertexBuffer.ColorKind
  32441. * * VertexBuffer.MatricesIndicesKind
  32442. * * VertexBuffer.MatricesIndicesExtraKind
  32443. * * VertexBuffer.MatricesWeightsKind
  32444. * * VertexBuffer.MatricesWeightsExtraKind
  32445. * @param data defines the data source
  32446. * @param updatable defines if the data must be flagged as updatable (or static)
  32447. * @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
  32448. * @returns the current mesh
  32449. */
  32450. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32451. /**
  32452. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32453. * If the mesh has no geometry, it is simply returned as it is.
  32454. * @param kind defines vertex data kind:
  32455. * * VertexBuffer.PositionKind
  32456. * * VertexBuffer.UVKind
  32457. * * VertexBuffer.UV2Kind
  32458. * * VertexBuffer.UV3Kind
  32459. * * VertexBuffer.UV4Kind
  32460. * * VertexBuffer.UV5Kind
  32461. * * VertexBuffer.UV6Kind
  32462. * * VertexBuffer.ColorKind
  32463. * * VertexBuffer.MatricesIndicesKind
  32464. * * VertexBuffer.MatricesIndicesExtraKind
  32465. * * VertexBuffer.MatricesWeightsKind
  32466. * * VertexBuffer.MatricesWeightsExtraKind
  32467. * @param data defines the data source
  32468. * @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
  32469. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32470. * @returns the current mesh
  32471. */
  32472. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32473. /**
  32474. * Sets the mesh indices,
  32475. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32476. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32477. * @param totalVertices Defines the total number of vertices
  32478. * @returns the current mesh
  32479. */
  32480. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32481. /**
  32482. * Gets a boolean indicating if specific vertex data is present
  32483. * @param kind defines the vertex data kind to use
  32484. * @returns true is data kind is present
  32485. */
  32486. isVerticesDataPresent(kind: string): boolean;
  32487. /**
  32488. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32489. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32490. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32491. * @returns a BoundingInfo
  32492. */
  32493. getBoundingInfo(): BoundingInfo;
  32494. /**
  32495. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32496. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32497. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32498. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32499. * @returns the current mesh
  32500. */
  32501. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32502. /**
  32503. * Overwrite the current bounding info
  32504. * @param boundingInfo defines the new bounding info
  32505. * @returns the current mesh
  32506. */
  32507. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32508. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32509. get useBones(): boolean;
  32510. /** @hidden */
  32511. _preActivate(): void;
  32512. /** @hidden */
  32513. _preActivateForIntermediateRendering(renderId: number): void;
  32514. /** @hidden */
  32515. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32516. /** @hidden */
  32517. _postActivate(): void;
  32518. /** @hidden */
  32519. _freeze(): void;
  32520. /** @hidden */
  32521. _unFreeze(): void;
  32522. /**
  32523. * Gets the current world matrix
  32524. * @returns a Matrix
  32525. */
  32526. getWorldMatrix(): Matrix;
  32527. /** @hidden */
  32528. _getWorldMatrixDeterminant(): number;
  32529. /**
  32530. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32531. */
  32532. get isAnInstance(): boolean;
  32533. /**
  32534. * Gets a boolean indicating if this mesh has instances
  32535. */
  32536. get hasInstances(): boolean;
  32537. /**
  32538. * Gets a boolean indicating if this mesh has thin instances
  32539. */
  32540. get hasThinInstances(): boolean;
  32541. /**
  32542. * Perform relative position change from the point of view of behind the front of the mesh.
  32543. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32544. * Supports definition of mesh facing forward or backward
  32545. * @param amountRight defines the distance on the right axis
  32546. * @param amountUp defines the distance on the up axis
  32547. * @param amountForward defines the distance on the forward axis
  32548. * @returns the current mesh
  32549. */
  32550. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32551. /**
  32552. * Calculate relative position change from the point of view of behind the front of the mesh.
  32553. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32554. * Supports definition of mesh facing forward or backward
  32555. * @param amountRight defines the distance on the right axis
  32556. * @param amountUp defines the distance on the up axis
  32557. * @param amountForward defines the distance on the forward axis
  32558. * @returns the new displacement vector
  32559. */
  32560. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32561. /**
  32562. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32563. * Supports definition of mesh facing forward or backward
  32564. * @param flipBack defines the flip
  32565. * @param twirlClockwise defines the twirl
  32566. * @param tiltRight defines the tilt
  32567. * @returns the current mesh
  32568. */
  32569. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32570. /**
  32571. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32572. * Supports definition of mesh facing forward or backward.
  32573. * @param flipBack defines the flip
  32574. * @param twirlClockwise defines the twirl
  32575. * @param tiltRight defines the tilt
  32576. * @returns the new rotation vector
  32577. */
  32578. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32579. /**
  32580. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32581. * This means the mesh underlying bounding box and sphere are recomputed.
  32582. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32583. * @returns the current mesh
  32584. */
  32585. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32586. /** @hidden */
  32587. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32588. /** @hidden */
  32589. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32590. /** @hidden */
  32591. _updateBoundingInfo(): AbstractMesh;
  32592. /** @hidden */
  32593. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32594. /** @hidden */
  32595. protected _afterComputeWorldMatrix(): void;
  32596. /** @hidden */
  32597. get _effectiveMesh(): AbstractMesh;
  32598. /**
  32599. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32600. * A mesh is in the frustum if its bounding box intersects the frustum
  32601. * @param frustumPlanes defines the frustum to test
  32602. * @returns true if the mesh is in the frustum planes
  32603. */
  32604. isInFrustum(frustumPlanes: Plane[]): boolean;
  32605. /**
  32606. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32607. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32608. * @param frustumPlanes defines the frustum to test
  32609. * @returns true if the mesh is completely in the frustum planes
  32610. */
  32611. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32612. /**
  32613. * True if the mesh intersects another mesh or a SolidParticle object
  32614. * @param mesh defines a target mesh or SolidParticle to test
  32615. * @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)
  32616. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32617. * @returns true if there is an intersection
  32618. */
  32619. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32620. /**
  32621. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32622. * @param point defines the point to test
  32623. * @returns true if there is an intersection
  32624. */
  32625. intersectsPoint(point: Vector3): boolean;
  32626. /**
  32627. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32628. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32629. */
  32630. get checkCollisions(): boolean;
  32631. set checkCollisions(collisionEnabled: boolean);
  32632. /**
  32633. * Gets Collider object used to compute collisions (not physics)
  32634. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32635. */
  32636. get collider(): Nullable<Collider>;
  32637. /**
  32638. * Move the mesh using collision engine
  32639. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32640. * @param displacement defines the requested displacement vector
  32641. * @returns the current mesh
  32642. */
  32643. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32644. private _onCollisionPositionChange;
  32645. /** @hidden */
  32646. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32647. /** @hidden */
  32648. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32649. /** @hidden */
  32650. _checkCollision(collider: Collider): AbstractMesh;
  32651. /** @hidden */
  32652. _generatePointsArray(): boolean;
  32653. /**
  32654. * Checks if the passed Ray intersects with the mesh
  32655. * @param ray defines the ray to use
  32656. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32657. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32658. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32659. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32660. * @returns the picking info
  32661. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32662. */
  32663. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32664. /**
  32665. * Clones the current mesh
  32666. * @param name defines the mesh name
  32667. * @param newParent defines the new mesh parent
  32668. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32669. * @returns the new mesh
  32670. */
  32671. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32672. /**
  32673. * Disposes all the submeshes of the current meshnp
  32674. * @returns the current mesh
  32675. */
  32676. releaseSubMeshes(): AbstractMesh;
  32677. /**
  32678. * Releases resources associated with this abstract mesh.
  32679. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32680. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32681. */
  32682. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32683. /**
  32684. * Adds the passed mesh as a child to the current mesh
  32685. * @param mesh defines the child mesh
  32686. * @returns the current mesh
  32687. */
  32688. addChild(mesh: AbstractMesh): AbstractMesh;
  32689. /**
  32690. * Removes the passed mesh from the current mesh children list
  32691. * @param mesh defines the child mesh
  32692. * @returns the current mesh
  32693. */
  32694. removeChild(mesh: AbstractMesh): AbstractMesh;
  32695. /** @hidden */
  32696. private _initFacetData;
  32697. /**
  32698. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32699. * This method can be called within the render loop.
  32700. * 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
  32701. * @returns the current mesh
  32702. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32703. */
  32704. updateFacetData(): AbstractMesh;
  32705. /**
  32706. * Returns the facetLocalNormals array.
  32707. * The normals are expressed in the mesh local spac
  32708. * @returns an array of Vector3
  32709. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32710. */
  32711. getFacetLocalNormals(): Vector3[];
  32712. /**
  32713. * Returns the facetLocalPositions array.
  32714. * The facet positions are expressed in the mesh local space
  32715. * @returns an array of Vector3
  32716. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32717. */
  32718. getFacetLocalPositions(): Vector3[];
  32719. /**
  32720. * Returns the facetLocalPartioning array
  32721. * @returns an array of array of numbers
  32722. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32723. */
  32724. getFacetLocalPartitioning(): number[][];
  32725. /**
  32726. * Returns the i-th facet position in the world system.
  32727. * This method allocates a new Vector3 per call
  32728. * @param i defines the facet index
  32729. * @returns a new Vector3
  32730. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32731. */
  32732. getFacetPosition(i: number): Vector3;
  32733. /**
  32734. * Sets the reference Vector3 with the i-th facet position in the world system
  32735. * @param i defines the facet index
  32736. * @param ref defines the target vector
  32737. * @returns the current mesh
  32738. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32739. */
  32740. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32741. /**
  32742. * Returns the i-th facet normal in the world system.
  32743. * This method allocates a new Vector3 per call
  32744. * @param i defines the facet index
  32745. * @returns a new Vector3
  32746. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32747. */
  32748. getFacetNormal(i: number): Vector3;
  32749. /**
  32750. * Sets the reference Vector3 with the i-th facet normal in the world system
  32751. * @param i defines the facet index
  32752. * @param ref defines the target vector
  32753. * @returns the current mesh
  32754. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32755. */
  32756. getFacetNormalToRef(i: number, ref: Vector3): this;
  32757. /**
  32758. * 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)
  32759. * @param x defines x coordinate
  32760. * @param y defines y coordinate
  32761. * @param z defines z coordinate
  32762. * @returns the array of facet indexes
  32763. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32764. */
  32765. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32766. /**
  32767. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32768. * @param projected sets as the (x,y,z) world projection on the facet
  32769. * @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
  32770. * @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
  32771. * @param x defines x coordinate
  32772. * @param y defines y coordinate
  32773. * @param z defines z coordinate
  32774. * @returns the face index if found (or null instead)
  32775. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32776. */
  32777. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32778. /**
  32779. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32780. * @param projected sets as the (x,y,z) local projection on the facet
  32781. * @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
  32782. * @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
  32783. * @param x defines x coordinate
  32784. * @param y defines y coordinate
  32785. * @param z defines z coordinate
  32786. * @returns the face index if found (or null instead)
  32787. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32788. */
  32789. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32790. /**
  32791. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32792. * @returns the parameters
  32793. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32794. */
  32795. getFacetDataParameters(): any;
  32796. /**
  32797. * Disables the feature FacetData and frees the related memory
  32798. * @returns the current mesh
  32799. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32800. */
  32801. disableFacetData(): AbstractMesh;
  32802. /**
  32803. * Updates the AbstractMesh indices array
  32804. * @param indices defines the data source
  32805. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32806. * @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)
  32807. * @returns the current mesh
  32808. */
  32809. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32810. /**
  32811. * Creates new normals data for the mesh
  32812. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32813. * @returns the current mesh
  32814. */
  32815. createNormals(updatable: boolean): AbstractMesh;
  32816. /**
  32817. * Align the mesh with a normal
  32818. * @param normal defines the normal to use
  32819. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32820. * @returns the current mesh
  32821. */
  32822. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32823. /** @hidden */
  32824. _checkOcclusionQuery(): boolean;
  32825. /**
  32826. * Disables the mesh edge rendering mode
  32827. * @returns the currentAbstractMesh
  32828. */
  32829. disableEdgesRendering(): AbstractMesh;
  32830. /**
  32831. * Enables the edge rendering mode on the mesh.
  32832. * This mode makes the mesh edges visible
  32833. * @param epsilon defines the maximal distance between two angles to detect a face
  32834. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32835. * @returns the currentAbstractMesh
  32836. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32837. */
  32838. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32839. /**
  32840. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32841. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32842. */
  32843. getConnectedParticleSystems(): IParticleSystem[];
  32844. }
  32845. }
  32846. declare module BABYLON {
  32847. /**
  32848. * Interface used to define ActionEvent
  32849. */
  32850. export interface IActionEvent {
  32851. /** The mesh or sprite that triggered the action */
  32852. source: any;
  32853. /** The X mouse cursor position at the time of the event */
  32854. pointerX: number;
  32855. /** The Y mouse cursor position at the time of the event */
  32856. pointerY: number;
  32857. /** The mesh that is currently pointed at (can be null) */
  32858. meshUnderPointer: Nullable<AbstractMesh>;
  32859. /** the original (browser) event that triggered the ActionEvent */
  32860. sourceEvent?: any;
  32861. /** additional data for the event */
  32862. additionalData?: any;
  32863. }
  32864. /**
  32865. * ActionEvent is the event being sent when an action is triggered.
  32866. */
  32867. export class ActionEvent implements IActionEvent {
  32868. /** The mesh or sprite that triggered the action */
  32869. source: any;
  32870. /** The X mouse cursor position at the time of the event */
  32871. pointerX: number;
  32872. /** The Y mouse cursor position at the time of the event */
  32873. pointerY: number;
  32874. /** The mesh that is currently pointed at (can be null) */
  32875. meshUnderPointer: Nullable<AbstractMesh>;
  32876. /** the original (browser) event that triggered the ActionEvent */
  32877. sourceEvent?: any;
  32878. /** additional data for the event */
  32879. additionalData?: any;
  32880. /**
  32881. * Creates a new ActionEvent
  32882. * @param source The mesh or sprite that triggered the action
  32883. * @param pointerX The X mouse cursor position at the time of the event
  32884. * @param pointerY The Y mouse cursor position at the time of the event
  32885. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32886. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32887. * @param additionalData additional data for the event
  32888. */
  32889. constructor(
  32890. /** The mesh or sprite that triggered the action */
  32891. source: any,
  32892. /** The X mouse cursor position at the time of the event */
  32893. pointerX: number,
  32894. /** The Y mouse cursor position at the time of the event */
  32895. pointerY: number,
  32896. /** The mesh that is currently pointed at (can be null) */
  32897. meshUnderPointer: Nullable<AbstractMesh>,
  32898. /** the original (browser) event that triggered the ActionEvent */
  32899. sourceEvent?: any,
  32900. /** additional data for the event */
  32901. additionalData?: any);
  32902. /**
  32903. * Helper function to auto-create an ActionEvent from a source mesh.
  32904. * @param source The source mesh that triggered the event
  32905. * @param evt The original (browser) event
  32906. * @param additionalData additional data for the event
  32907. * @returns the new ActionEvent
  32908. */
  32909. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32910. /**
  32911. * Helper function to auto-create an ActionEvent from a source sprite
  32912. * @param source The source sprite that triggered the event
  32913. * @param scene Scene associated with the sprite
  32914. * @param evt The original (browser) event
  32915. * @param additionalData additional data for the event
  32916. * @returns the new ActionEvent
  32917. */
  32918. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32919. /**
  32920. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32921. * @param scene the scene where the event occurred
  32922. * @param evt The original (browser) event
  32923. * @returns the new ActionEvent
  32924. */
  32925. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32926. /**
  32927. * Helper function to auto-create an ActionEvent from a primitive
  32928. * @param prim defines the target primitive
  32929. * @param pointerPos defines the pointer position
  32930. * @param evt The original (browser) event
  32931. * @param additionalData additional data for the event
  32932. * @returns the new ActionEvent
  32933. */
  32934. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32935. }
  32936. }
  32937. declare module BABYLON {
  32938. /**
  32939. * Abstract class used to decouple action Manager from scene and meshes.
  32940. * Do not instantiate.
  32941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32942. */
  32943. export abstract class AbstractActionManager implements IDisposable {
  32944. /** Gets the list of active triggers */
  32945. static Triggers: {
  32946. [key: string]: number;
  32947. };
  32948. /** Gets the cursor to use when hovering items */
  32949. hoverCursor: string;
  32950. /** Gets the list of actions */
  32951. actions: IAction[];
  32952. /**
  32953. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32954. */
  32955. isRecursive: boolean;
  32956. /**
  32957. * Releases all associated resources
  32958. */
  32959. abstract dispose(): void;
  32960. /**
  32961. * Does this action manager has pointer triggers
  32962. */
  32963. abstract get hasPointerTriggers(): boolean;
  32964. /**
  32965. * Does this action manager has pick triggers
  32966. */
  32967. abstract get hasPickTriggers(): boolean;
  32968. /**
  32969. * Process a specific trigger
  32970. * @param trigger defines the trigger to process
  32971. * @param evt defines the event details to be processed
  32972. */
  32973. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32974. /**
  32975. * Does this action manager handles actions of any of the given triggers
  32976. * @param triggers defines the triggers to be tested
  32977. * @return a boolean indicating whether one (or more) of the triggers is handled
  32978. */
  32979. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32980. /**
  32981. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32982. * speed.
  32983. * @param triggerA defines the trigger to be tested
  32984. * @param triggerB defines the trigger to be tested
  32985. * @return a boolean indicating whether one (or more) of the triggers is handled
  32986. */
  32987. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32988. /**
  32989. * Does this action manager handles actions of a given trigger
  32990. * @param trigger defines the trigger to be tested
  32991. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32992. * @return whether the trigger is handled
  32993. */
  32994. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32995. /**
  32996. * Serialize this manager to a JSON object
  32997. * @param name defines the property name to store this manager
  32998. * @returns a JSON representation of this manager
  32999. */
  33000. abstract serialize(name: string): any;
  33001. /**
  33002. * Registers an action to this action manager
  33003. * @param action defines the action to be registered
  33004. * @return the action amended (prepared) after registration
  33005. */
  33006. abstract registerAction(action: IAction): Nullable<IAction>;
  33007. /**
  33008. * Unregisters an action to this action manager
  33009. * @param action defines the action to be unregistered
  33010. * @return a boolean indicating whether the action has been unregistered
  33011. */
  33012. abstract unregisterAction(action: IAction): Boolean;
  33013. /**
  33014. * Does exist one action manager with at least one trigger
  33015. **/
  33016. static get HasTriggers(): boolean;
  33017. /**
  33018. * Does exist one action manager with at least one pick trigger
  33019. **/
  33020. static get HasPickTriggers(): boolean;
  33021. /**
  33022. * Does exist one action manager that handles actions of a given trigger
  33023. * @param trigger defines the trigger to be tested
  33024. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33025. **/
  33026. static HasSpecificTrigger(trigger: number): boolean;
  33027. }
  33028. }
  33029. declare module BABYLON {
  33030. /**
  33031. * Defines how a node can be built from a string name.
  33032. */
  33033. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33034. /**
  33035. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33036. */
  33037. export class Node implements IBehaviorAware<Node> {
  33038. /** @hidden */
  33039. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33040. private static _NodeConstructors;
  33041. /**
  33042. * Add a new node constructor
  33043. * @param type defines the type name of the node to construct
  33044. * @param constructorFunc defines the constructor function
  33045. */
  33046. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33047. /**
  33048. * Returns a node constructor based on type name
  33049. * @param type defines the type name
  33050. * @param name defines the new node name
  33051. * @param scene defines the hosting scene
  33052. * @param options defines optional options to transmit to constructors
  33053. * @returns the new constructor or null
  33054. */
  33055. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33056. /**
  33057. * Gets or sets the name of the node
  33058. */
  33059. name: string;
  33060. /**
  33061. * Gets or sets the id of the node
  33062. */
  33063. id: string;
  33064. /**
  33065. * Gets or sets the unique id of the node
  33066. */
  33067. uniqueId: number;
  33068. /**
  33069. * Gets or sets a string used to store user defined state for the node
  33070. */
  33071. state: string;
  33072. /**
  33073. * Gets or sets an object used to store user defined information for the node
  33074. */
  33075. metadata: any;
  33076. /**
  33077. * For internal use only. Please do not use.
  33078. */
  33079. reservedDataStore: any;
  33080. /**
  33081. * List of inspectable custom properties (used by the Inspector)
  33082. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33083. */
  33084. inspectableCustomProperties: IInspectable[];
  33085. private _doNotSerialize;
  33086. /**
  33087. * Gets or sets a boolean used to define if the node must be serialized
  33088. */
  33089. get doNotSerialize(): boolean;
  33090. set doNotSerialize(value: boolean);
  33091. /** @hidden */
  33092. _isDisposed: boolean;
  33093. /**
  33094. * Gets a list of Animations associated with the node
  33095. */
  33096. animations: Animation[];
  33097. protected _ranges: {
  33098. [name: string]: Nullable<AnimationRange>;
  33099. };
  33100. /**
  33101. * Callback raised when the node is ready to be used
  33102. */
  33103. onReady: Nullable<(node: Node) => void>;
  33104. private _isEnabled;
  33105. private _isParentEnabled;
  33106. private _isReady;
  33107. /** @hidden */
  33108. _currentRenderId: number;
  33109. private _parentUpdateId;
  33110. /** @hidden */
  33111. _childUpdateId: number;
  33112. /** @hidden */
  33113. _waitingParentId: Nullable<string>;
  33114. /** @hidden */
  33115. _scene: Scene;
  33116. /** @hidden */
  33117. _cache: any;
  33118. private _parentNode;
  33119. private _children;
  33120. /** @hidden */
  33121. _worldMatrix: Matrix;
  33122. /** @hidden */
  33123. _worldMatrixDeterminant: number;
  33124. /** @hidden */
  33125. _worldMatrixDeterminantIsDirty: boolean;
  33126. /** @hidden */
  33127. private _sceneRootNodesIndex;
  33128. /**
  33129. * Gets a boolean indicating if the node has been disposed
  33130. * @returns true if the node was disposed
  33131. */
  33132. isDisposed(): boolean;
  33133. /**
  33134. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33135. * @see https://doc.babylonjs.com/how_to/parenting
  33136. */
  33137. set parent(parent: Nullable<Node>);
  33138. get parent(): Nullable<Node>;
  33139. /** @hidden */
  33140. _addToSceneRootNodes(): void;
  33141. /** @hidden */
  33142. _removeFromSceneRootNodes(): void;
  33143. private _animationPropertiesOverride;
  33144. /**
  33145. * Gets or sets the animation properties override
  33146. */
  33147. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33148. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33149. /**
  33150. * Gets a string identifying the name of the class
  33151. * @returns "Node" string
  33152. */
  33153. getClassName(): string;
  33154. /** @hidden */
  33155. readonly _isNode: boolean;
  33156. /**
  33157. * An event triggered when the mesh is disposed
  33158. */
  33159. onDisposeObservable: Observable<Node>;
  33160. private _onDisposeObserver;
  33161. /**
  33162. * Sets a callback that will be raised when the node will be disposed
  33163. */
  33164. set onDispose(callback: () => void);
  33165. /**
  33166. * Creates a new Node
  33167. * @param name the name and id to be given to this node
  33168. * @param scene the scene this node will be added to
  33169. */
  33170. constructor(name: string, scene?: Nullable<Scene>);
  33171. /**
  33172. * Gets the scene of the node
  33173. * @returns a scene
  33174. */
  33175. getScene(): Scene;
  33176. /**
  33177. * Gets the engine of the node
  33178. * @returns a Engine
  33179. */
  33180. getEngine(): Engine;
  33181. private _behaviors;
  33182. /**
  33183. * Attach a behavior to the node
  33184. * @see https://doc.babylonjs.com/features/behaviour
  33185. * @param behavior defines the behavior to attach
  33186. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33187. * @returns the current Node
  33188. */
  33189. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33190. /**
  33191. * Remove an attached behavior
  33192. * @see https://doc.babylonjs.com/features/behaviour
  33193. * @param behavior defines the behavior to attach
  33194. * @returns the current Node
  33195. */
  33196. removeBehavior(behavior: Behavior<Node>): Node;
  33197. /**
  33198. * Gets the list of attached behaviors
  33199. * @see https://doc.babylonjs.com/features/behaviour
  33200. */
  33201. get behaviors(): Behavior<Node>[];
  33202. /**
  33203. * Gets an attached behavior by name
  33204. * @param name defines the name of the behavior to look for
  33205. * @see https://doc.babylonjs.com/features/behaviour
  33206. * @returns null if behavior was not found else the requested behavior
  33207. */
  33208. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33209. /**
  33210. * Returns the latest update of the World matrix
  33211. * @returns a Matrix
  33212. */
  33213. getWorldMatrix(): Matrix;
  33214. /** @hidden */
  33215. _getWorldMatrixDeterminant(): number;
  33216. /**
  33217. * Returns directly the latest state of the mesh World matrix.
  33218. * A Matrix is returned.
  33219. */
  33220. get worldMatrixFromCache(): Matrix;
  33221. /** @hidden */
  33222. _initCache(): void;
  33223. /** @hidden */
  33224. updateCache(force?: boolean): void;
  33225. /** @hidden */
  33226. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33227. /** @hidden */
  33228. _updateCache(ignoreParentClass?: boolean): void;
  33229. /** @hidden */
  33230. _isSynchronized(): boolean;
  33231. /** @hidden */
  33232. _markSyncedWithParent(): void;
  33233. /** @hidden */
  33234. isSynchronizedWithParent(): boolean;
  33235. /** @hidden */
  33236. isSynchronized(): boolean;
  33237. /**
  33238. * Is this node ready to be used/rendered
  33239. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33240. * @return true if the node is ready
  33241. */
  33242. isReady(completeCheck?: boolean): boolean;
  33243. /**
  33244. * Is this node enabled?
  33245. * 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
  33246. * @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
  33247. * @return whether this node (and its parent) is enabled
  33248. */
  33249. isEnabled(checkAncestors?: boolean): boolean;
  33250. /** @hidden */
  33251. protected _syncParentEnabledState(): void;
  33252. /**
  33253. * Set the enabled state of this node
  33254. * @param value defines the new enabled state
  33255. */
  33256. setEnabled(value: boolean): void;
  33257. /**
  33258. * Is this node a descendant of the given node?
  33259. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33260. * @param ancestor defines the parent node to inspect
  33261. * @returns a boolean indicating if this node is a descendant of the given node
  33262. */
  33263. isDescendantOf(ancestor: Node): boolean;
  33264. /** @hidden */
  33265. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33266. /**
  33267. * Will return all nodes that have this node as ascendant
  33268. * @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
  33269. * @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
  33270. * @return all children nodes of all types
  33271. */
  33272. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33273. /**
  33274. * Get all child-meshes of this node
  33275. * @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)
  33276. * @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
  33277. * @returns an array of AbstractMesh
  33278. */
  33279. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33280. /**
  33281. * Get all direct children of this node
  33282. * @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
  33283. * @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)
  33284. * @returns an array of Node
  33285. */
  33286. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33287. /** @hidden */
  33288. _setReady(state: boolean): void;
  33289. /**
  33290. * Get an animation by name
  33291. * @param name defines the name of the animation to look for
  33292. * @returns null if not found else the requested animation
  33293. */
  33294. getAnimationByName(name: string): Nullable<Animation>;
  33295. /**
  33296. * Creates an animation range for this node
  33297. * @param name defines the name of the range
  33298. * @param from defines the starting key
  33299. * @param to defines the end key
  33300. */
  33301. createAnimationRange(name: string, from: number, to: number): void;
  33302. /**
  33303. * Delete a specific animation range
  33304. * @param name defines the name of the range to delete
  33305. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33306. */
  33307. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33308. /**
  33309. * Get an animation range by name
  33310. * @param name defines the name of the animation range to look for
  33311. * @returns null if not found else the requested animation range
  33312. */
  33313. getAnimationRange(name: string): Nullable<AnimationRange>;
  33314. /**
  33315. * Gets the list of all animation ranges defined on this node
  33316. * @returns an array
  33317. */
  33318. getAnimationRanges(): Nullable<AnimationRange>[];
  33319. /**
  33320. * Will start the animation sequence
  33321. * @param name defines the range frames for animation sequence
  33322. * @param loop defines if the animation should loop (false by default)
  33323. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33324. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33325. * @returns the object created for this animation. If range does not exist, it will return null
  33326. */
  33327. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33328. /**
  33329. * Serialize animation ranges into a JSON compatible object
  33330. * @returns serialization object
  33331. */
  33332. serializeAnimationRanges(): any;
  33333. /**
  33334. * Computes the world matrix of the node
  33335. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33336. * @returns the world matrix
  33337. */
  33338. computeWorldMatrix(force?: boolean): Matrix;
  33339. /**
  33340. * Releases resources associated with this node.
  33341. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33342. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33343. */
  33344. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33345. /**
  33346. * Parse animation range data from a serialization object and store them into a given node
  33347. * @param node defines where to store the animation ranges
  33348. * @param parsedNode defines the serialization object to read data from
  33349. * @param scene defines the hosting scene
  33350. */
  33351. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33352. /**
  33353. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33354. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33355. * @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
  33356. * @returns the new bounding vectors
  33357. */
  33358. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33359. min: Vector3;
  33360. max: Vector3;
  33361. };
  33362. }
  33363. }
  33364. declare module BABYLON {
  33365. /**
  33366. * @hidden
  33367. */
  33368. export class _IAnimationState {
  33369. key: number;
  33370. repeatCount: number;
  33371. workValue?: any;
  33372. loopMode?: number;
  33373. offsetValue?: any;
  33374. highLimitValue?: any;
  33375. }
  33376. /**
  33377. * Class used to store any kind of animation
  33378. */
  33379. export class Animation {
  33380. /**Name of the animation */
  33381. name: string;
  33382. /**Property to animate */
  33383. targetProperty: string;
  33384. /**The frames per second of the animation */
  33385. framePerSecond: number;
  33386. /**The data type of the animation */
  33387. dataType: number;
  33388. /**The loop mode of the animation */
  33389. loopMode?: number | undefined;
  33390. /**Specifies if blending should be enabled */
  33391. enableBlending?: boolean | undefined;
  33392. /**
  33393. * Use matrix interpolation instead of using direct key value when animating matrices
  33394. */
  33395. static AllowMatricesInterpolation: boolean;
  33396. /**
  33397. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33398. */
  33399. static AllowMatrixDecomposeForInterpolation: boolean;
  33400. /** Define the Url to load snippets */
  33401. static SnippetUrl: string;
  33402. /** Snippet ID if the animation was created from the snippet server */
  33403. snippetId: string;
  33404. /**
  33405. * Stores the key frames of the animation
  33406. */
  33407. private _keys;
  33408. /**
  33409. * Stores the easing function of the animation
  33410. */
  33411. private _easingFunction;
  33412. /**
  33413. * @hidden Internal use only
  33414. */
  33415. _runtimeAnimations: RuntimeAnimation[];
  33416. /**
  33417. * The set of event that will be linked to this animation
  33418. */
  33419. private _events;
  33420. /**
  33421. * Stores an array of target property paths
  33422. */
  33423. targetPropertyPath: string[];
  33424. /**
  33425. * Stores the blending speed of the animation
  33426. */
  33427. blendingSpeed: number;
  33428. /**
  33429. * Stores the animation ranges for the animation
  33430. */
  33431. private _ranges;
  33432. /**
  33433. * @hidden Internal use
  33434. */
  33435. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33436. /**
  33437. * Sets up an animation
  33438. * @param property The property to animate
  33439. * @param animationType The animation type to apply
  33440. * @param framePerSecond The frames per second of the animation
  33441. * @param easingFunction The easing function used in the animation
  33442. * @returns The created animation
  33443. */
  33444. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33445. /**
  33446. * Create and start an animation on a node
  33447. * @param name defines the name of the global animation that will be run on all nodes
  33448. * @param node defines the root node where the animation will take place
  33449. * @param targetProperty defines property to animate
  33450. * @param framePerSecond defines the number of frame per second yo use
  33451. * @param totalFrame defines the number of frames in total
  33452. * @param from defines the initial value
  33453. * @param to defines the final value
  33454. * @param loopMode defines which loop mode you want to use (off by default)
  33455. * @param easingFunction defines the easing function to use (linear by default)
  33456. * @param onAnimationEnd defines the callback to call when animation end
  33457. * @returns the animatable created for this animation
  33458. */
  33459. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33460. /**
  33461. * Create and start an animation on a node and its descendants
  33462. * @param name defines the name of the global animation that will be run on all nodes
  33463. * @param node defines the root node where the animation will take place
  33464. * @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
  33465. * @param targetProperty defines property to animate
  33466. * @param framePerSecond defines the number of frame per second to use
  33467. * @param totalFrame defines the number of frames in total
  33468. * @param from defines the initial value
  33469. * @param to defines the final value
  33470. * @param loopMode defines which loop mode you want to use (off by default)
  33471. * @param easingFunction defines the easing function to use (linear by default)
  33472. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33473. * @returns the list of animatables created for all nodes
  33474. * @example https://www.babylonjs-playground.com/#MH0VLI
  33475. */
  33476. 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[]>;
  33477. /**
  33478. * Creates a new animation, merges it with the existing animations and starts it
  33479. * @param name Name of the animation
  33480. * @param node Node which contains the scene that begins the animations
  33481. * @param targetProperty Specifies which property to animate
  33482. * @param framePerSecond The frames per second of the animation
  33483. * @param totalFrame The total number of frames
  33484. * @param from The frame at the beginning of the animation
  33485. * @param to The frame at the end of the animation
  33486. * @param loopMode Specifies the loop mode of the animation
  33487. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33488. * @param onAnimationEnd Callback to run once the animation is complete
  33489. * @returns Nullable animation
  33490. */
  33491. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33492. /**
  33493. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33494. * @param sourceAnimation defines the Animation containing keyframes to convert
  33495. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33496. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33497. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33498. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33499. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33500. */
  33501. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33502. /**
  33503. * Transition property of an host to the target Value
  33504. * @param property The property to transition
  33505. * @param targetValue The target Value of the property
  33506. * @param host The object where the property to animate belongs
  33507. * @param scene Scene used to run the animation
  33508. * @param frameRate Framerate (in frame/s) to use
  33509. * @param transition The transition type we want to use
  33510. * @param duration The duration of the animation, in milliseconds
  33511. * @param onAnimationEnd Callback trigger at the end of the animation
  33512. * @returns Nullable animation
  33513. */
  33514. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33515. /**
  33516. * Return the array of runtime animations currently using this animation
  33517. */
  33518. get runtimeAnimations(): RuntimeAnimation[];
  33519. /**
  33520. * Specifies if any of the runtime animations are currently running
  33521. */
  33522. get hasRunningRuntimeAnimations(): boolean;
  33523. /**
  33524. * Initializes the animation
  33525. * @param name Name of the animation
  33526. * @param targetProperty Property to animate
  33527. * @param framePerSecond The frames per second of the animation
  33528. * @param dataType The data type of the animation
  33529. * @param loopMode The loop mode of the animation
  33530. * @param enableBlending Specifies if blending should be enabled
  33531. */
  33532. constructor(
  33533. /**Name of the animation */
  33534. name: string,
  33535. /**Property to animate */
  33536. targetProperty: string,
  33537. /**The frames per second of the animation */
  33538. framePerSecond: number,
  33539. /**The data type of the animation */
  33540. dataType: number,
  33541. /**The loop mode of the animation */
  33542. loopMode?: number | undefined,
  33543. /**Specifies if blending should be enabled */
  33544. enableBlending?: boolean | undefined);
  33545. /**
  33546. * Converts the animation to a string
  33547. * @param fullDetails support for multiple levels of logging within scene loading
  33548. * @returns String form of the animation
  33549. */
  33550. toString(fullDetails?: boolean): string;
  33551. /**
  33552. * Add an event to this animation
  33553. * @param event Event to add
  33554. */
  33555. addEvent(event: AnimationEvent): void;
  33556. /**
  33557. * Remove all events found at the given frame
  33558. * @param frame The frame to remove events from
  33559. */
  33560. removeEvents(frame: number): void;
  33561. /**
  33562. * Retrieves all the events from the animation
  33563. * @returns Events from the animation
  33564. */
  33565. getEvents(): AnimationEvent[];
  33566. /**
  33567. * Creates an animation range
  33568. * @param name Name of the animation range
  33569. * @param from Starting frame of the animation range
  33570. * @param to Ending frame of the animation
  33571. */
  33572. createRange(name: string, from: number, to: number): void;
  33573. /**
  33574. * Deletes an animation range by name
  33575. * @param name Name of the animation range to delete
  33576. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33577. */
  33578. deleteRange(name: string, deleteFrames?: boolean): void;
  33579. /**
  33580. * Gets the animation range by name, or null if not defined
  33581. * @param name Name of the animation range
  33582. * @returns Nullable animation range
  33583. */
  33584. getRange(name: string): Nullable<AnimationRange>;
  33585. /**
  33586. * Gets the key frames from the animation
  33587. * @returns The key frames of the animation
  33588. */
  33589. getKeys(): Array<IAnimationKey>;
  33590. /**
  33591. * Gets the highest frame rate of the animation
  33592. * @returns Highest frame rate of the animation
  33593. */
  33594. getHighestFrame(): number;
  33595. /**
  33596. * Gets the easing function of the animation
  33597. * @returns Easing function of the animation
  33598. */
  33599. getEasingFunction(): IEasingFunction;
  33600. /**
  33601. * Sets the easing function of the animation
  33602. * @param easingFunction A custom mathematical formula for animation
  33603. */
  33604. setEasingFunction(easingFunction: EasingFunction): void;
  33605. /**
  33606. * Interpolates a scalar linearly
  33607. * @param startValue Start value of the animation curve
  33608. * @param endValue End value of the animation curve
  33609. * @param gradient Scalar amount to interpolate
  33610. * @returns Interpolated scalar value
  33611. */
  33612. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33613. /**
  33614. * Interpolates a scalar cubically
  33615. * @param startValue Start value of the animation curve
  33616. * @param outTangent End tangent of the animation
  33617. * @param endValue End value of the animation curve
  33618. * @param inTangent Start tangent of the animation curve
  33619. * @param gradient Scalar amount to interpolate
  33620. * @returns Interpolated scalar value
  33621. */
  33622. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33623. /**
  33624. * Interpolates a quaternion using a spherical linear interpolation
  33625. * @param startValue Start value of the animation curve
  33626. * @param endValue End value of the animation curve
  33627. * @param gradient Scalar amount to interpolate
  33628. * @returns Interpolated quaternion value
  33629. */
  33630. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33631. /**
  33632. * Interpolates a quaternion cubically
  33633. * @param startValue Start value of the animation curve
  33634. * @param outTangent End tangent of the animation curve
  33635. * @param endValue End value of the animation curve
  33636. * @param inTangent Start tangent of the animation curve
  33637. * @param gradient Scalar amount to interpolate
  33638. * @returns Interpolated quaternion value
  33639. */
  33640. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33641. /**
  33642. * Interpolates a Vector3 linearl
  33643. * @param startValue Start value of the animation curve
  33644. * @param endValue End value of the animation curve
  33645. * @param gradient Scalar amount to interpolate
  33646. * @returns Interpolated scalar value
  33647. */
  33648. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33649. /**
  33650. * Interpolates a Vector3 cubically
  33651. * @param startValue Start value of the animation curve
  33652. * @param outTangent End tangent of the animation
  33653. * @param endValue End value of the animation curve
  33654. * @param inTangent Start tangent of the animation curve
  33655. * @param gradient Scalar amount to interpolate
  33656. * @returns InterpolatedVector3 value
  33657. */
  33658. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33659. /**
  33660. * Interpolates a Vector2 linearly
  33661. * @param startValue Start value of the animation curve
  33662. * @param endValue End value of the animation curve
  33663. * @param gradient Scalar amount to interpolate
  33664. * @returns Interpolated Vector2 value
  33665. */
  33666. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33667. /**
  33668. * Interpolates a Vector2 cubically
  33669. * @param startValue Start value of the animation curve
  33670. * @param outTangent End tangent of the animation
  33671. * @param endValue End value of the animation curve
  33672. * @param inTangent Start tangent of the animation curve
  33673. * @param gradient Scalar amount to interpolate
  33674. * @returns Interpolated Vector2 value
  33675. */
  33676. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33677. /**
  33678. * Interpolates a size linearly
  33679. * @param startValue Start value of the animation curve
  33680. * @param endValue End value of the animation curve
  33681. * @param gradient Scalar amount to interpolate
  33682. * @returns Interpolated Size value
  33683. */
  33684. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33685. /**
  33686. * Interpolates a Color3 linearly
  33687. * @param startValue Start value of the animation curve
  33688. * @param endValue End value of the animation curve
  33689. * @param gradient Scalar amount to interpolate
  33690. * @returns Interpolated Color3 value
  33691. */
  33692. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33693. /**
  33694. * Interpolates a Color4 linearly
  33695. * @param startValue Start value of the animation curve
  33696. * @param endValue End value of the animation curve
  33697. * @param gradient Scalar amount to interpolate
  33698. * @returns Interpolated Color3 value
  33699. */
  33700. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33701. /**
  33702. * @hidden Internal use only
  33703. */
  33704. _getKeyValue(value: any): any;
  33705. /**
  33706. * @hidden Internal use only
  33707. */
  33708. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33709. /**
  33710. * Defines the function to use to interpolate matrices
  33711. * @param startValue defines the start matrix
  33712. * @param endValue defines the end matrix
  33713. * @param gradient defines the gradient between both matrices
  33714. * @param result defines an optional target matrix where to store the interpolation
  33715. * @returns the interpolated matrix
  33716. */
  33717. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33718. /**
  33719. * Makes a copy of the animation
  33720. * @returns Cloned animation
  33721. */
  33722. clone(): Animation;
  33723. /**
  33724. * Sets the key frames of the animation
  33725. * @param values The animation key frames to set
  33726. */
  33727. setKeys(values: Array<IAnimationKey>): void;
  33728. /**
  33729. * Serializes the animation to an object
  33730. * @returns Serialized object
  33731. */
  33732. serialize(): any;
  33733. /**
  33734. * Float animation type
  33735. */
  33736. static readonly ANIMATIONTYPE_FLOAT: number;
  33737. /**
  33738. * Vector3 animation type
  33739. */
  33740. static readonly ANIMATIONTYPE_VECTOR3: number;
  33741. /**
  33742. * Quaternion animation type
  33743. */
  33744. static readonly ANIMATIONTYPE_QUATERNION: number;
  33745. /**
  33746. * Matrix animation type
  33747. */
  33748. static readonly ANIMATIONTYPE_MATRIX: number;
  33749. /**
  33750. * Color3 animation type
  33751. */
  33752. static readonly ANIMATIONTYPE_COLOR3: number;
  33753. /**
  33754. * Color3 animation type
  33755. */
  33756. static readonly ANIMATIONTYPE_COLOR4: number;
  33757. /**
  33758. * Vector2 animation type
  33759. */
  33760. static readonly ANIMATIONTYPE_VECTOR2: number;
  33761. /**
  33762. * Size animation type
  33763. */
  33764. static readonly ANIMATIONTYPE_SIZE: number;
  33765. /**
  33766. * Relative Loop Mode
  33767. */
  33768. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33769. /**
  33770. * Cycle Loop Mode
  33771. */
  33772. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33773. /**
  33774. * Constant Loop Mode
  33775. */
  33776. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33777. /** @hidden */
  33778. static _UniversalLerp(left: any, right: any, amount: number): any;
  33779. /**
  33780. * Parses an animation object and creates an animation
  33781. * @param parsedAnimation Parsed animation object
  33782. * @returns Animation object
  33783. */
  33784. static Parse(parsedAnimation: any): Animation;
  33785. /**
  33786. * Appends the serialized animations from the source animations
  33787. * @param source Source containing the animations
  33788. * @param destination Target to store the animations
  33789. */
  33790. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33791. /**
  33792. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33793. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33794. * @param url defines the url to load from
  33795. * @returns a promise that will resolve to the new animation or an array of animations
  33796. */
  33797. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33798. /**
  33799. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33800. * @param snippetId defines the snippet to load
  33801. * @returns a promise that will resolve to the new animation or a new array of animations
  33802. */
  33803. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33804. }
  33805. }
  33806. declare module BABYLON {
  33807. /**
  33808. * Interface containing an array of animations
  33809. */
  33810. export interface IAnimatable {
  33811. /**
  33812. * Array of animations
  33813. */
  33814. animations: Nullable<Array<Animation>>;
  33815. }
  33816. }
  33817. declare module BABYLON {
  33818. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33819. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33820. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33821. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33822. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33823. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33824. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33825. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33826. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33827. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33828. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33829. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33830. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33831. /**
  33832. * Decorator used to define property that can be serialized as reference to a camera
  33833. * @param sourceName defines the name of the property to decorate
  33834. */
  33835. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33836. /**
  33837. * Class used to help serialization objects
  33838. */
  33839. export class SerializationHelper {
  33840. /** @hidden */
  33841. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33842. /** @hidden */
  33843. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33844. /** @hidden */
  33845. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33846. /** @hidden */
  33847. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33848. /**
  33849. * Appends the serialized animations from the source animations
  33850. * @param source Source containing the animations
  33851. * @param destination Target to store the animations
  33852. */
  33853. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33854. /**
  33855. * Static function used to serialized a specific entity
  33856. * @param entity defines the entity to serialize
  33857. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33858. * @returns a JSON compatible object representing the serialization of the entity
  33859. */
  33860. static Serialize<T>(entity: T, serializationObject?: any): any;
  33861. /**
  33862. * Creates a new entity from a serialization data object
  33863. * @param creationFunction defines a function used to instanciated the new entity
  33864. * @param source defines the source serialization data
  33865. * @param scene defines the hosting scene
  33866. * @param rootUrl defines the root url for resources
  33867. * @returns a new entity
  33868. */
  33869. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33870. /**
  33871. * Clones an object
  33872. * @param creationFunction defines the function used to instanciate the new object
  33873. * @param source defines the source object
  33874. * @returns the cloned object
  33875. */
  33876. static Clone<T>(creationFunction: () => T, source: T): T;
  33877. /**
  33878. * Instanciates a new object based on a source one (some data will be shared between both object)
  33879. * @param creationFunction defines the function used to instanciate the new object
  33880. * @param source defines the source object
  33881. * @returns the new object
  33882. */
  33883. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33884. }
  33885. }
  33886. declare module BABYLON {
  33887. /**
  33888. * Base class of all the textures in babylon.
  33889. * It groups all the common properties the materials, post process, lights... might need
  33890. * in order to make a correct use of the texture.
  33891. */
  33892. export class BaseTexture implements IAnimatable {
  33893. /**
  33894. * Default anisotropic filtering level for the application.
  33895. * It is set to 4 as a good tradeoff between perf and quality.
  33896. */
  33897. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33898. /**
  33899. * Gets or sets the unique id of the texture
  33900. */
  33901. uniqueId: number;
  33902. /**
  33903. * Define the name of the texture.
  33904. */
  33905. name: string;
  33906. /**
  33907. * Gets or sets an object used to store user defined information.
  33908. */
  33909. metadata: any;
  33910. /**
  33911. * For internal use only. Please do not use.
  33912. */
  33913. reservedDataStore: any;
  33914. private _hasAlpha;
  33915. /**
  33916. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33917. */
  33918. set hasAlpha(value: boolean);
  33919. get hasAlpha(): boolean;
  33920. /**
  33921. * Defines if the alpha value should be determined via the rgb values.
  33922. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33923. */
  33924. getAlphaFromRGB: boolean;
  33925. /**
  33926. * Intensity or strength of the texture.
  33927. * It is commonly used by materials to fine tune the intensity of the texture
  33928. */
  33929. level: number;
  33930. /**
  33931. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33932. * This is part of the texture as textures usually maps to one uv set.
  33933. */
  33934. coordinatesIndex: number;
  33935. protected _coordinatesMode: number;
  33936. /**
  33937. * How a texture is mapped.
  33938. *
  33939. * | Value | Type | Description |
  33940. * | ----- | ----------------------------------- | ----------- |
  33941. * | 0 | EXPLICIT_MODE | |
  33942. * | 1 | SPHERICAL_MODE | |
  33943. * | 2 | PLANAR_MODE | |
  33944. * | 3 | CUBIC_MODE | |
  33945. * | 4 | PROJECTION_MODE | |
  33946. * | 5 | SKYBOX_MODE | |
  33947. * | 6 | INVCUBIC_MODE | |
  33948. * | 7 | EQUIRECTANGULAR_MODE | |
  33949. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33950. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33951. */
  33952. set coordinatesMode(value: number);
  33953. get coordinatesMode(): number;
  33954. private _wrapU;
  33955. /**
  33956. * | Value | Type | Description |
  33957. * | ----- | ------------------ | ----------- |
  33958. * | 0 | CLAMP_ADDRESSMODE | |
  33959. * | 1 | WRAP_ADDRESSMODE | |
  33960. * | 2 | MIRROR_ADDRESSMODE | |
  33961. */
  33962. get wrapU(): number;
  33963. set wrapU(value: number);
  33964. private _wrapV;
  33965. /**
  33966. * | Value | Type | Description |
  33967. * | ----- | ------------------ | ----------- |
  33968. * | 0 | CLAMP_ADDRESSMODE | |
  33969. * | 1 | WRAP_ADDRESSMODE | |
  33970. * | 2 | MIRROR_ADDRESSMODE | |
  33971. */
  33972. get wrapV(): number;
  33973. set wrapV(value: number);
  33974. /**
  33975. * | Value | Type | Description |
  33976. * | ----- | ------------------ | ----------- |
  33977. * | 0 | CLAMP_ADDRESSMODE | |
  33978. * | 1 | WRAP_ADDRESSMODE | |
  33979. * | 2 | MIRROR_ADDRESSMODE | |
  33980. */
  33981. wrapR: number;
  33982. /**
  33983. * With compliant hardware and browser (supporting anisotropic filtering)
  33984. * this defines the level of anisotropic filtering in the texture.
  33985. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33986. */
  33987. anisotropicFilteringLevel: number;
  33988. /**
  33989. * Define if the texture is a cube texture or if false a 2d texture.
  33990. */
  33991. get isCube(): boolean;
  33992. set isCube(value: boolean);
  33993. /**
  33994. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33995. */
  33996. get is3D(): boolean;
  33997. set is3D(value: boolean);
  33998. /**
  33999. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34000. */
  34001. get is2DArray(): boolean;
  34002. set is2DArray(value: boolean);
  34003. private _gammaSpace;
  34004. /**
  34005. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34006. * HDR texture are usually stored in linear space.
  34007. * This only impacts the PBR and Background materials
  34008. */
  34009. get gammaSpace(): boolean;
  34010. set gammaSpace(gamma: boolean);
  34011. /**
  34012. * Gets or sets whether or not the texture contains RGBD data.
  34013. */
  34014. get isRGBD(): boolean;
  34015. set isRGBD(value: boolean);
  34016. /**
  34017. * Is Z inverted in the texture (useful in a cube texture).
  34018. */
  34019. invertZ: boolean;
  34020. /**
  34021. * Are mip maps generated for this texture or not.
  34022. */
  34023. get noMipmap(): boolean;
  34024. /**
  34025. * @hidden
  34026. */
  34027. lodLevelInAlpha: boolean;
  34028. /**
  34029. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34030. */
  34031. get lodGenerationOffset(): number;
  34032. set lodGenerationOffset(value: number);
  34033. /**
  34034. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34035. */
  34036. get lodGenerationScale(): number;
  34037. set lodGenerationScale(value: number);
  34038. /**
  34039. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34040. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34041. * average roughness values.
  34042. */
  34043. get linearSpecularLOD(): boolean;
  34044. set linearSpecularLOD(value: boolean);
  34045. /**
  34046. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34047. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34048. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34049. */
  34050. get irradianceTexture(): Nullable<BaseTexture>;
  34051. set irradianceTexture(value: Nullable<BaseTexture>);
  34052. /**
  34053. * Define if the texture is a render target.
  34054. */
  34055. isRenderTarget: boolean;
  34056. /**
  34057. * Define the unique id of the texture in the scene.
  34058. */
  34059. get uid(): string;
  34060. /** @hidden */
  34061. _prefiltered: boolean;
  34062. /**
  34063. * Return a string representation of the texture.
  34064. * @returns the texture as a string
  34065. */
  34066. toString(): string;
  34067. /**
  34068. * Get the class name of the texture.
  34069. * @returns "BaseTexture"
  34070. */
  34071. getClassName(): string;
  34072. /**
  34073. * Define the list of animation attached to the texture.
  34074. */
  34075. animations: Animation[];
  34076. /**
  34077. * An event triggered when the texture is disposed.
  34078. */
  34079. onDisposeObservable: Observable<BaseTexture>;
  34080. private _onDisposeObserver;
  34081. /**
  34082. * Callback triggered when the texture has been disposed.
  34083. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34084. */
  34085. set onDispose(callback: () => void);
  34086. /**
  34087. * Define the current state of the loading sequence when in delayed load mode.
  34088. */
  34089. delayLoadState: number;
  34090. protected _scene: Nullable<Scene>;
  34091. protected _engine: Nullable<ThinEngine>;
  34092. /** @hidden */
  34093. _texture: Nullable<InternalTexture>;
  34094. private _uid;
  34095. /**
  34096. * Define if the texture is preventinga material to render or not.
  34097. * If not and the texture is not ready, the engine will use a default black texture instead.
  34098. */
  34099. get isBlocking(): boolean;
  34100. /**
  34101. * Instantiates a new BaseTexture.
  34102. * Base class of all the textures in babylon.
  34103. * It groups all the common properties the materials, post process, lights... might need
  34104. * in order to make a correct use of the texture.
  34105. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34106. */
  34107. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34108. /**
  34109. * Get the scene the texture belongs to.
  34110. * @returns the scene or null if undefined
  34111. */
  34112. getScene(): Nullable<Scene>;
  34113. /** @hidden */
  34114. protected _getEngine(): Nullable<ThinEngine>;
  34115. /**
  34116. * Get the texture transform matrix used to offset tile the texture for istance.
  34117. * @returns the transformation matrix
  34118. */
  34119. getTextureMatrix(): Matrix;
  34120. /**
  34121. * Get the texture reflection matrix used to rotate/transform the reflection.
  34122. * @returns the reflection matrix
  34123. */
  34124. getReflectionTextureMatrix(): Matrix;
  34125. /**
  34126. * Get the underlying lower level texture from Babylon.
  34127. * @returns the insternal texture
  34128. */
  34129. getInternalTexture(): Nullable<InternalTexture>;
  34130. /**
  34131. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34132. * @returns true if ready or not blocking
  34133. */
  34134. isReadyOrNotBlocking(): boolean;
  34135. /**
  34136. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34137. * @returns true if fully ready
  34138. */
  34139. isReady(): boolean;
  34140. private _cachedSize;
  34141. /**
  34142. * Get the size of the texture.
  34143. * @returns the texture size.
  34144. */
  34145. getSize(): ISize;
  34146. /**
  34147. * Get the base size of the texture.
  34148. * It can be different from the size if the texture has been resized for POT for instance
  34149. * @returns the base size
  34150. */
  34151. getBaseSize(): ISize;
  34152. /**
  34153. * Update the sampling mode of the texture.
  34154. * Default is Trilinear mode.
  34155. *
  34156. * | Value | Type | Description |
  34157. * | ----- | ------------------ | ----------- |
  34158. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34159. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34160. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34161. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34162. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34163. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34164. * | 7 | NEAREST_LINEAR | |
  34165. * | 8 | NEAREST_NEAREST | |
  34166. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34167. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34168. * | 11 | LINEAR_LINEAR | |
  34169. * | 12 | LINEAR_NEAREST | |
  34170. *
  34171. * > _mag_: magnification filter (close to the viewer)
  34172. * > _min_: minification filter (far from the viewer)
  34173. * > _mip_: filter used between mip map levels
  34174. *@param samplingMode Define the new sampling mode of the texture
  34175. */
  34176. updateSamplingMode(samplingMode: number): void;
  34177. /**
  34178. * Scales the texture if is `canRescale()`
  34179. * @param ratio the resize factor we want to use to rescale
  34180. */
  34181. scale(ratio: number): void;
  34182. /**
  34183. * Get if the texture can rescale.
  34184. */
  34185. get canRescale(): boolean;
  34186. /** @hidden */
  34187. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34188. /** @hidden */
  34189. _rebuild(): void;
  34190. /**
  34191. * Triggers the load sequence in delayed load mode.
  34192. */
  34193. delayLoad(): void;
  34194. /**
  34195. * Clones the texture.
  34196. * @returns the cloned texture
  34197. */
  34198. clone(): Nullable<BaseTexture>;
  34199. /**
  34200. * Get the texture underlying type (INT, FLOAT...)
  34201. */
  34202. get textureType(): number;
  34203. /**
  34204. * Get the texture underlying format (RGB, RGBA...)
  34205. */
  34206. get textureFormat(): number;
  34207. /**
  34208. * Indicates that textures need to be re-calculated for all materials
  34209. */
  34210. protected _markAllSubMeshesAsTexturesDirty(): void;
  34211. /**
  34212. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34213. * This will returns an RGBA array buffer containing either in values (0-255) or
  34214. * float values (0-1) depending of the underlying buffer type.
  34215. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34216. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34217. * @param buffer defines a user defined buffer to fill with data (can be null)
  34218. * @returns The Array buffer containing the pixels data.
  34219. */
  34220. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34221. /**
  34222. * Release and destroy the underlying lower level texture aka internalTexture.
  34223. */
  34224. releaseInternalTexture(): void;
  34225. /** @hidden */
  34226. get _lodTextureHigh(): Nullable<BaseTexture>;
  34227. /** @hidden */
  34228. get _lodTextureMid(): Nullable<BaseTexture>;
  34229. /** @hidden */
  34230. get _lodTextureLow(): Nullable<BaseTexture>;
  34231. /**
  34232. * Dispose the texture and release its associated resources.
  34233. */
  34234. dispose(): void;
  34235. /**
  34236. * Serialize the texture into a JSON representation that can be parsed later on.
  34237. * @returns the JSON representation of the texture
  34238. */
  34239. serialize(): any;
  34240. /**
  34241. * Helper function to be called back once a list of texture contains only ready textures.
  34242. * @param textures Define the list of textures to wait for
  34243. * @param callback Define the callback triggered once the entire list will be ready
  34244. */
  34245. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34246. private static _isScene;
  34247. }
  34248. }
  34249. declare module BABYLON {
  34250. /**
  34251. * Options to be used when creating an effect.
  34252. */
  34253. export interface IEffectCreationOptions {
  34254. /**
  34255. * Atrributes that will be used in the shader.
  34256. */
  34257. attributes: string[];
  34258. /**
  34259. * Uniform varible names that will be set in the shader.
  34260. */
  34261. uniformsNames: string[];
  34262. /**
  34263. * Uniform buffer variable names that will be set in the shader.
  34264. */
  34265. uniformBuffersNames: string[];
  34266. /**
  34267. * Sampler texture variable names that will be set in the shader.
  34268. */
  34269. samplers: string[];
  34270. /**
  34271. * Define statements that will be set in the shader.
  34272. */
  34273. defines: any;
  34274. /**
  34275. * Possible fallbacks for this effect to improve performance when needed.
  34276. */
  34277. fallbacks: Nullable<IEffectFallbacks>;
  34278. /**
  34279. * Callback that will be called when the shader is compiled.
  34280. */
  34281. onCompiled: Nullable<(effect: Effect) => void>;
  34282. /**
  34283. * Callback that will be called if an error occurs during shader compilation.
  34284. */
  34285. onError: Nullable<(effect: Effect, errors: string) => void>;
  34286. /**
  34287. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34288. */
  34289. indexParameters?: any;
  34290. /**
  34291. * Max number of lights that can be used in the shader.
  34292. */
  34293. maxSimultaneousLights?: number;
  34294. /**
  34295. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34296. */
  34297. transformFeedbackVaryings?: Nullable<string[]>;
  34298. /**
  34299. * 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
  34300. */
  34301. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34302. /**
  34303. * Is this effect rendering to several color attachments ?
  34304. */
  34305. multiTarget?: boolean;
  34306. }
  34307. /**
  34308. * Effect containing vertex and fragment shader that can be executed on an object.
  34309. */
  34310. export class Effect implements IDisposable {
  34311. /**
  34312. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34313. */
  34314. static ShadersRepository: string;
  34315. /**
  34316. * Enable logging of the shader code when a compilation error occurs
  34317. */
  34318. static LogShaderCodeOnCompilationError: boolean;
  34319. /**
  34320. * Name of the effect.
  34321. */
  34322. name: any;
  34323. /**
  34324. * String container all the define statements that should be set on the shader.
  34325. */
  34326. defines: string;
  34327. /**
  34328. * Callback that will be called when the shader is compiled.
  34329. */
  34330. onCompiled: Nullable<(effect: Effect) => void>;
  34331. /**
  34332. * Callback that will be called if an error occurs during shader compilation.
  34333. */
  34334. onError: Nullable<(effect: Effect, errors: string) => void>;
  34335. /**
  34336. * Callback that will be called when effect is bound.
  34337. */
  34338. onBind: Nullable<(effect: Effect) => void>;
  34339. /**
  34340. * Unique ID of the effect.
  34341. */
  34342. uniqueId: number;
  34343. /**
  34344. * Observable that will be called when the shader is compiled.
  34345. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34346. */
  34347. onCompileObservable: Observable<Effect>;
  34348. /**
  34349. * Observable that will be called if an error occurs during shader compilation.
  34350. */
  34351. onErrorObservable: Observable<Effect>;
  34352. /** @hidden */
  34353. _onBindObservable: Nullable<Observable<Effect>>;
  34354. /**
  34355. * @hidden
  34356. * Specifies if the effect was previously ready
  34357. */
  34358. _wasPreviouslyReady: boolean;
  34359. /**
  34360. * Observable that will be called when effect is bound.
  34361. */
  34362. get onBindObservable(): Observable<Effect>;
  34363. /** @hidden */
  34364. _bonesComputationForcedToCPU: boolean;
  34365. /** @hidden */
  34366. _multiTarget: boolean;
  34367. private static _uniqueIdSeed;
  34368. private _engine;
  34369. private _uniformBuffersNames;
  34370. private _uniformBuffersNamesList;
  34371. private _uniformsNames;
  34372. private _samplerList;
  34373. private _samplers;
  34374. private _isReady;
  34375. private _compilationError;
  34376. private _allFallbacksProcessed;
  34377. private _attributesNames;
  34378. private _attributes;
  34379. private _attributeLocationByName;
  34380. private _uniforms;
  34381. /**
  34382. * Key for the effect.
  34383. * @hidden
  34384. */
  34385. _key: string;
  34386. private _indexParameters;
  34387. private _fallbacks;
  34388. private _vertexSourceCode;
  34389. private _fragmentSourceCode;
  34390. private _vertexSourceCodeOverride;
  34391. private _fragmentSourceCodeOverride;
  34392. private _transformFeedbackVaryings;
  34393. /**
  34394. * Compiled shader to webGL program.
  34395. * @hidden
  34396. */
  34397. _pipelineContext: Nullable<IPipelineContext>;
  34398. private _valueCache;
  34399. private static _baseCache;
  34400. /**
  34401. * Instantiates an effect.
  34402. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34403. * @param baseName Name of the effect.
  34404. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34405. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34406. * @param samplers List of sampler variables that will be passed to the shader.
  34407. * @param engine Engine to be used to render the effect
  34408. * @param defines Define statements to be added to the shader.
  34409. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34410. * @param onCompiled Callback that will be called when the shader is compiled.
  34411. * @param onError Callback that will be called if an error occurs during shader compilation.
  34412. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34413. */
  34414. 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);
  34415. private _useFinalCode;
  34416. /**
  34417. * Unique key for this effect
  34418. */
  34419. get key(): string;
  34420. /**
  34421. * If the effect has been compiled and prepared.
  34422. * @returns if the effect is compiled and prepared.
  34423. */
  34424. isReady(): boolean;
  34425. private _isReadyInternal;
  34426. /**
  34427. * The engine the effect was initialized with.
  34428. * @returns the engine.
  34429. */
  34430. getEngine(): Engine;
  34431. /**
  34432. * The pipeline context for this effect
  34433. * @returns the associated pipeline context
  34434. */
  34435. getPipelineContext(): Nullable<IPipelineContext>;
  34436. /**
  34437. * The set of names of attribute variables for the shader.
  34438. * @returns An array of attribute names.
  34439. */
  34440. getAttributesNames(): string[];
  34441. /**
  34442. * Returns the attribute at the given index.
  34443. * @param index The index of the attribute.
  34444. * @returns The location of the attribute.
  34445. */
  34446. getAttributeLocation(index: number): number;
  34447. /**
  34448. * Returns the attribute based on the name of the variable.
  34449. * @param name of the attribute to look up.
  34450. * @returns the attribute location.
  34451. */
  34452. getAttributeLocationByName(name: string): number;
  34453. /**
  34454. * The number of attributes.
  34455. * @returns the numnber of attributes.
  34456. */
  34457. getAttributesCount(): number;
  34458. /**
  34459. * Gets the index of a uniform variable.
  34460. * @param uniformName of the uniform to look up.
  34461. * @returns the index.
  34462. */
  34463. getUniformIndex(uniformName: string): number;
  34464. /**
  34465. * Returns the attribute based on the name of the variable.
  34466. * @param uniformName of the uniform to look up.
  34467. * @returns the location of the uniform.
  34468. */
  34469. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34470. /**
  34471. * Returns an array of sampler variable names
  34472. * @returns The array of sampler variable names.
  34473. */
  34474. getSamplers(): string[];
  34475. /**
  34476. * Returns an array of uniform variable names
  34477. * @returns The array of uniform variable names.
  34478. */
  34479. getUniformNames(): string[];
  34480. /**
  34481. * Returns an array of uniform buffer variable names
  34482. * @returns The array of uniform buffer variable names.
  34483. */
  34484. getUniformBuffersNames(): string[];
  34485. /**
  34486. * Returns the index parameters used to create the effect
  34487. * @returns The index parameters object
  34488. */
  34489. getIndexParameters(): any;
  34490. /**
  34491. * The error from the last compilation.
  34492. * @returns the error string.
  34493. */
  34494. getCompilationError(): string;
  34495. /**
  34496. * Gets a boolean indicating that all fallbacks were used during compilation
  34497. * @returns true if all fallbacks were used
  34498. */
  34499. allFallbacksProcessed(): boolean;
  34500. /**
  34501. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34502. * @param func The callback to be used.
  34503. */
  34504. executeWhenCompiled(func: (effect: Effect) => void): void;
  34505. private _checkIsReady;
  34506. private _loadShader;
  34507. /**
  34508. * Gets the vertex shader source code of this effect
  34509. */
  34510. get vertexSourceCode(): string;
  34511. /**
  34512. * Gets the fragment shader source code of this effect
  34513. */
  34514. get fragmentSourceCode(): string;
  34515. /**
  34516. * Recompiles the webGL program
  34517. * @param vertexSourceCode The source code for the vertex shader.
  34518. * @param fragmentSourceCode The source code for the fragment shader.
  34519. * @param onCompiled Callback called when completed.
  34520. * @param onError Callback called on error.
  34521. * @hidden
  34522. */
  34523. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34524. /**
  34525. * Prepares the effect
  34526. * @hidden
  34527. */
  34528. _prepareEffect(): void;
  34529. private _getShaderCodeAndErrorLine;
  34530. private _processCompilationErrors;
  34531. /**
  34532. * Checks if the effect is supported. (Must be called after compilation)
  34533. */
  34534. get isSupported(): boolean;
  34535. /**
  34536. * Binds a texture to the engine to be used as output of the shader.
  34537. * @param channel Name of the output variable.
  34538. * @param texture Texture to bind.
  34539. * @hidden
  34540. */
  34541. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34542. /**
  34543. * Sets a texture on the engine to be used in the shader.
  34544. * @param channel Name of the sampler variable.
  34545. * @param texture Texture to set.
  34546. */
  34547. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34548. /**
  34549. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34550. * @param channel Name of the sampler variable.
  34551. * @param texture Texture to set.
  34552. */
  34553. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34554. /**
  34555. * Sets an array of textures on the engine to be used in the shader.
  34556. * @param channel Name of the variable.
  34557. * @param textures Textures to set.
  34558. */
  34559. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34560. /**
  34561. * 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)
  34562. * @param channel Name of the sampler variable.
  34563. * @param postProcess Post process to get the input texture from.
  34564. */
  34565. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34566. /**
  34567. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34568. * 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)
  34569. * @param channel Name of the sampler variable.
  34570. * @param postProcess Post process to get the output texture from.
  34571. */
  34572. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34573. /** @hidden */
  34574. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34575. /** @hidden */
  34576. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34577. /** @hidden */
  34578. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34579. /** @hidden */
  34580. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34581. /**
  34582. * Binds a buffer to a uniform.
  34583. * @param buffer Buffer to bind.
  34584. * @param name Name of the uniform variable to bind to.
  34585. */
  34586. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34587. /**
  34588. * Binds block to a uniform.
  34589. * @param blockName Name of the block to bind.
  34590. * @param index Index to bind.
  34591. */
  34592. bindUniformBlock(blockName: string, index: number): void;
  34593. /**
  34594. * Sets an interger value on a uniform variable.
  34595. * @param uniformName Name of the variable.
  34596. * @param value Value to be set.
  34597. * @returns this effect.
  34598. */
  34599. setInt(uniformName: string, value: number): Effect;
  34600. /**
  34601. * Sets an int array on a uniform variable.
  34602. * @param uniformName Name of the variable.
  34603. * @param array array to be set.
  34604. * @returns this effect.
  34605. */
  34606. setIntArray(uniformName: string, array: Int32Array): Effect;
  34607. /**
  34608. * 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)
  34609. * @param uniformName Name of the variable.
  34610. * @param array array to be set.
  34611. * @returns this effect.
  34612. */
  34613. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34614. /**
  34615. * 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)
  34616. * @param uniformName Name of the variable.
  34617. * @param array array to be set.
  34618. * @returns this effect.
  34619. */
  34620. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34621. /**
  34622. * 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)
  34623. * @param uniformName Name of the variable.
  34624. * @param array array to be set.
  34625. * @returns this effect.
  34626. */
  34627. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34628. /**
  34629. * Sets an float array on a uniform variable.
  34630. * @param uniformName Name of the variable.
  34631. * @param array array to be set.
  34632. * @returns this effect.
  34633. */
  34634. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34635. /**
  34636. * 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)
  34637. * @param uniformName Name of the variable.
  34638. * @param array array to be set.
  34639. * @returns this effect.
  34640. */
  34641. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34642. /**
  34643. * 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)
  34644. * @param uniformName Name of the variable.
  34645. * @param array array to be set.
  34646. * @returns this effect.
  34647. */
  34648. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34649. /**
  34650. * 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)
  34651. * @param uniformName Name of the variable.
  34652. * @param array array to be set.
  34653. * @returns this effect.
  34654. */
  34655. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34656. /**
  34657. * Sets an array on a uniform variable.
  34658. * @param uniformName Name of the variable.
  34659. * @param array array to be set.
  34660. * @returns this effect.
  34661. */
  34662. setArray(uniformName: string, array: number[]): Effect;
  34663. /**
  34664. * 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)
  34665. * @param uniformName Name of the variable.
  34666. * @param array array to be set.
  34667. * @returns this effect.
  34668. */
  34669. setArray2(uniformName: string, array: number[]): Effect;
  34670. /**
  34671. * 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)
  34672. * @param uniformName Name of the variable.
  34673. * @param array array to be set.
  34674. * @returns this effect.
  34675. */
  34676. setArray3(uniformName: string, array: number[]): Effect;
  34677. /**
  34678. * 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)
  34679. * @param uniformName Name of the variable.
  34680. * @param array array to be set.
  34681. * @returns this effect.
  34682. */
  34683. setArray4(uniformName: string, array: number[]): Effect;
  34684. /**
  34685. * Sets matrices on a uniform variable.
  34686. * @param uniformName Name of the variable.
  34687. * @param matrices matrices to be set.
  34688. * @returns this effect.
  34689. */
  34690. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34691. /**
  34692. * Sets matrix on a uniform variable.
  34693. * @param uniformName Name of the variable.
  34694. * @param matrix matrix to be set.
  34695. * @returns this effect.
  34696. */
  34697. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34698. /**
  34699. * 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)
  34700. * @param uniformName Name of the variable.
  34701. * @param matrix matrix to be set.
  34702. * @returns this effect.
  34703. */
  34704. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34705. /**
  34706. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34707. * @param uniformName Name of the variable.
  34708. * @param matrix matrix to be set.
  34709. * @returns this effect.
  34710. */
  34711. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34712. /**
  34713. * Sets a float on a uniform variable.
  34714. * @param uniformName Name of the variable.
  34715. * @param value value to be set.
  34716. * @returns this effect.
  34717. */
  34718. setFloat(uniformName: string, value: number): Effect;
  34719. /**
  34720. * Sets a boolean on a uniform variable.
  34721. * @param uniformName Name of the variable.
  34722. * @param bool value to be set.
  34723. * @returns this effect.
  34724. */
  34725. setBool(uniformName: string, bool: boolean): Effect;
  34726. /**
  34727. * Sets a Vector2 on a uniform variable.
  34728. * @param uniformName Name of the variable.
  34729. * @param vector2 vector2 to be set.
  34730. * @returns this effect.
  34731. */
  34732. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34733. /**
  34734. * Sets a float2 on a uniform variable.
  34735. * @param uniformName Name of the variable.
  34736. * @param x First float in float2.
  34737. * @param y Second float in float2.
  34738. * @returns this effect.
  34739. */
  34740. setFloat2(uniformName: string, x: number, y: number): Effect;
  34741. /**
  34742. * Sets a Vector3 on a uniform variable.
  34743. * @param uniformName Name of the variable.
  34744. * @param vector3 Value to be set.
  34745. * @returns this effect.
  34746. */
  34747. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34748. /**
  34749. * Sets a float3 on a uniform variable.
  34750. * @param uniformName Name of the variable.
  34751. * @param x First float in float3.
  34752. * @param y Second float in float3.
  34753. * @param z Third float in float3.
  34754. * @returns this effect.
  34755. */
  34756. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34757. /**
  34758. * Sets a Vector4 on a uniform variable.
  34759. * @param uniformName Name of the variable.
  34760. * @param vector4 Value to be set.
  34761. * @returns this effect.
  34762. */
  34763. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34764. /**
  34765. * Sets a float4 on a uniform variable.
  34766. * @param uniformName Name of the variable.
  34767. * @param x First float in float4.
  34768. * @param y Second float in float4.
  34769. * @param z Third float in float4.
  34770. * @param w Fourth float in float4.
  34771. * @returns this effect.
  34772. */
  34773. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34774. /**
  34775. * Sets a Color3 on a uniform variable.
  34776. * @param uniformName Name of the variable.
  34777. * @param color3 Value to be set.
  34778. * @returns this effect.
  34779. */
  34780. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34781. /**
  34782. * Sets a Color4 on a uniform variable.
  34783. * @param uniformName Name of the variable.
  34784. * @param color3 Value to be set.
  34785. * @param alpha Alpha value to be set.
  34786. * @returns this effect.
  34787. */
  34788. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34789. /**
  34790. * Sets a Color4 on a uniform variable
  34791. * @param uniformName defines the name of the variable
  34792. * @param color4 defines the value to be set
  34793. * @returns this effect.
  34794. */
  34795. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34796. /** Release all associated resources */
  34797. dispose(): void;
  34798. /**
  34799. * This function will add a new shader to the shader store
  34800. * @param name the name of the shader
  34801. * @param pixelShader optional pixel shader content
  34802. * @param vertexShader optional vertex shader content
  34803. */
  34804. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34805. /**
  34806. * Store of each shader (The can be looked up using effect.key)
  34807. */
  34808. static ShadersStore: {
  34809. [key: string]: string;
  34810. };
  34811. /**
  34812. * Store of each included file for a shader (The can be looked up using effect.key)
  34813. */
  34814. static IncludesShadersStore: {
  34815. [key: string]: string;
  34816. };
  34817. /**
  34818. * Resets the cache of effects.
  34819. */
  34820. static ResetCache(): void;
  34821. }
  34822. }
  34823. declare module BABYLON {
  34824. /**
  34825. * Interface used to describe the capabilities of the engine relatively to the current browser
  34826. */
  34827. export interface EngineCapabilities {
  34828. /** Maximum textures units per fragment shader */
  34829. maxTexturesImageUnits: number;
  34830. /** Maximum texture units per vertex shader */
  34831. maxVertexTextureImageUnits: number;
  34832. /** Maximum textures units in the entire pipeline */
  34833. maxCombinedTexturesImageUnits: number;
  34834. /** Maximum texture size */
  34835. maxTextureSize: number;
  34836. /** Maximum texture samples */
  34837. maxSamples?: number;
  34838. /** Maximum cube texture size */
  34839. maxCubemapTextureSize: number;
  34840. /** Maximum render texture size */
  34841. maxRenderTextureSize: number;
  34842. /** Maximum number of vertex attributes */
  34843. maxVertexAttribs: number;
  34844. /** Maximum number of varyings */
  34845. maxVaryingVectors: number;
  34846. /** Maximum number of uniforms per vertex shader */
  34847. maxVertexUniformVectors: number;
  34848. /** Maximum number of uniforms per fragment shader */
  34849. maxFragmentUniformVectors: number;
  34850. /** Defines if standard derivates (dx/dy) are supported */
  34851. standardDerivatives: boolean;
  34852. /** Defines if s3tc texture compression is supported */
  34853. s3tc?: WEBGL_compressed_texture_s3tc;
  34854. /** Defines if pvrtc texture compression is supported */
  34855. pvrtc: any;
  34856. /** Defines if etc1 texture compression is supported */
  34857. etc1: any;
  34858. /** Defines if etc2 texture compression is supported */
  34859. etc2: any;
  34860. /** Defines if astc texture compression is supported */
  34861. astc: any;
  34862. /** Defines if bptc texture compression is supported */
  34863. bptc: any;
  34864. /** Defines if float textures are supported */
  34865. textureFloat: boolean;
  34866. /** Defines if vertex array objects are supported */
  34867. vertexArrayObject: boolean;
  34868. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34869. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34870. /** Gets the maximum level of anisotropy supported */
  34871. maxAnisotropy: number;
  34872. /** Defines if instancing is supported */
  34873. instancedArrays: boolean;
  34874. /** Defines if 32 bits indices are supported */
  34875. uintIndices: boolean;
  34876. /** Defines if high precision shaders are supported */
  34877. highPrecisionShaderSupported: boolean;
  34878. /** Defines if depth reading in the fragment shader is supported */
  34879. fragmentDepthSupported: boolean;
  34880. /** Defines if float texture linear filtering is supported*/
  34881. textureFloatLinearFiltering: boolean;
  34882. /** Defines if rendering to float textures is supported */
  34883. textureFloatRender: boolean;
  34884. /** Defines if half float textures are supported*/
  34885. textureHalfFloat: boolean;
  34886. /** Defines if half float texture linear filtering is supported*/
  34887. textureHalfFloatLinearFiltering: boolean;
  34888. /** Defines if rendering to half float textures is supported */
  34889. textureHalfFloatRender: boolean;
  34890. /** Defines if textureLOD shader command is supported */
  34891. textureLOD: boolean;
  34892. /** Defines if draw buffers extension is supported */
  34893. drawBuffersExtension: boolean;
  34894. /** Defines if depth textures are supported */
  34895. depthTextureExtension: boolean;
  34896. /** Defines if float color buffer are supported */
  34897. colorBufferFloat: boolean;
  34898. /** Gets disjoint timer query extension (null if not supported) */
  34899. timerQuery?: EXT_disjoint_timer_query;
  34900. /** Defines if timestamp can be used with timer query */
  34901. canUseTimestampForTimerQuery: boolean;
  34902. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34903. multiview?: any;
  34904. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34905. oculusMultiview?: any;
  34906. /** Function used to let the system compiles shaders in background */
  34907. parallelShaderCompile?: {
  34908. COMPLETION_STATUS_KHR: number;
  34909. };
  34910. /** Max number of texture samples for MSAA */
  34911. maxMSAASamples: number;
  34912. /** Defines if the blend min max extension is supported */
  34913. blendMinMax: boolean;
  34914. }
  34915. }
  34916. declare module BABYLON {
  34917. /**
  34918. * @hidden
  34919. **/
  34920. export class DepthCullingState {
  34921. private _isDepthTestDirty;
  34922. private _isDepthMaskDirty;
  34923. private _isDepthFuncDirty;
  34924. private _isCullFaceDirty;
  34925. private _isCullDirty;
  34926. private _isZOffsetDirty;
  34927. private _isFrontFaceDirty;
  34928. private _depthTest;
  34929. private _depthMask;
  34930. private _depthFunc;
  34931. private _cull;
  34932. private _cullFace;
  34933. private _zOffset;
  34934. private _frontFace;
  34935. /**
  34936. * Initializes the state.
  34937. */
  34938. constructor();
  34939. get isDirty(): boolean;
  34940. get zOffset(): number;
  34941. set zOffset(value: number);
  34942. get cullFace(): Nullable<number>;
  34943. set cullFace(value: Nullable<number>);
  34944. get cull(): Nullable<boolean>;
  34945. set cull(value: Nullable<boolean>);
  34946. get depthFunc(): Nullable<number>;
  34947. set depthFunc(value: Nullable<number>);
  34948. get depthMask(): boolean;
  34949. set depthMask(value: boolean);
  34950. get depthTest(): boolean;
  34951. set depthTest(value: boolean);
  34952. get frontFace(): Nullable<number>;
  34953. set frontFace(value: Nullable<number>);
  34954. reset(): void;
  34955. apply(gl: WebGLRenderingContext): void;
  34956. }
  34957. }
  34958. declare module BABYLON {
  34959. /**
  34960. * @hidden
  34961. **/
  34962. export class StencilState {
  34963. /** 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 */
  34964. static readonly ALWAYS: number;
  34965. /** Passed to stencilOperation to specify that stencil value must be kept */
  34966. static readonly KEEP: number;
  34967. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34968. static readonly REPLACE: number;
  34969. private _isStencilTestDirty;
  34970. private _isStencilMaskDirty;
  34971. private _isStencilFuncDirty;
  34972. private _isStencilOpDirty;
  34973. private _stencilTest;
  34974. private _stencilMask;
  34975. private _stencilFunc;
  34976. private _stencilFuncRef;
  34977. private _stencilFuncMask;
  34978. private _stencilOpStencilFail;
  34979. private _stencilOpDepthFail;
  34980. private _stencilOpStencilDepthPass;
  34981. get isDirty(): boolean;
  34982. get stencilFunc(): number;
  34983. set stencilFunc(value: number);
  34984. get stencilFuncRef(): number;
  34985. set stencilFuncRef(value: number);
  34986. get stencilFuncMask(): number;
  34987. set stencilFuncMask(value: number);
  34988. get stencilOpStencilFail(): number;
  34989. set stencilOpStencilFail(value: number);
  34990. get stencilOpDepthFail(): number;
  34991. set stencilOpDepthFail(value: number);
  34992. get stencilOpStencilDepthPass(): number;
  34993. set stencilOpStencilDepthPass(value: number);
  34994. get stencilMask(): number;
  34995. set stencilMask(value: number);
  34996. get stencilTest(): boolean;
  34997. set stencilTest(value: boolean);
  34998. constructor();
  34999. reset(): void;
  35000. apply(gl: WebGLRenderingContext): void;
  35001. }
  35002. }
  35003. declare module BABYLON {
  35004. /**
  35005. * @hidden
  35006. **/
  35007. export class AlphaState {
  35008. private _isAlphaBlendDirty;
  35009. private _isBlendFunctionParametersDirty;
  35010. private _isBlendEquationParametersDirty;
  35011. private _isBlendConstantsDirty;
  35012. private _alphaBlend;
  35013. private _blendFunctionParameters;
  35014. private _blendEquationParameters;
  35015. private _blendConstants;
  35016. /**
  35017. * Initializes the state.
  35018. */
  35019. constructor();
  35020. get isDirty(): boolean;
  35021. get alphaBlend(): boolean;
  35022. set alphaBlend(value: boolean);
  35023. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35024. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35025. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35026. reset(): void;
  35027. apply(gl: WebGLRenderingContext): void;
  35028. }
  35029. }
  35030. declare module BABYLON {
  35031. /** @hidden */
  35032. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35033. attributeProcessor(attribute: string): string;
  35034. varyingProcessor(varying: string, isFragment: boolean): string;
  35035. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35036. }
  35037. }
  35038. declare module BABYLON {
  35039. /**
  35040. * Interface for attribute information associated with buffer instanciation
  35041. */
  35042. export interface InstancingAttributeInfo {
  35043. /**
  35044. * Name of the GLSL attribute
  35045. * if attribute index is not specified, this is used to retrieve the index from the effect
  35046. */
  35047. attributeName: string;
  35048. /**
  35049. * Index/offset of the attribute in the vertex shader
  35050. * if not specified, this will be computes from the name.
  35051. */
  35052. index?: number;
  35053. /**
  35054. * size of the attribute, 1, 2, 3 or 4
  35055. */
  35056. attributeSize: number;
  35057. /**
  35058. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35059. */
  35060. offset: number;
  35061. /**
  35062. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35063. * default to 1
  35064. */
  35065. divisor?: number;
  35066. /**
  35067. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35068. * default is FLOAT
  35069. */
  35070. attributeType?: number;
  35071. /**
  35072. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35073. */
  35074. normalized?: boolean;
  35075. }
  35076. }
  35077. declare module BABYLON {
  35078. interface ThinEngine {
  35079. /**
  35080. * Update a video texture
  35081. * @param texture defines the texture to update
  35082. * @param video defines the video element to use
  35083. * @param invertY defines if data must be stored with Y axis inverted
  35084. */
  35085. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35086. }
  35087. }
  35088. declare module BABYLON {
  35089. interface ThinEngine {
  35090. /**
  35091. * Creates a dynamic texture
  35092. * @param width defines the width of the texture
  35093. * @param height defines the height of the texture
  35094. * @param generateMipMaps defines if the engine should generate the mip levels
  35095. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35096. * @returns the dynamic texture inside an InternalTexture
  35097. */
  35098. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35099. /**
  35100. * Update the content of a dynamic texture
  35101. * @param texture defines the texture to update
  35102. * @param canvas defines the canvas containing the source
  35103. * @param invertY defines if data must be stored with Y axis inverted
  35104. * @param premulAlpha defines if alpha is stored as premultiplied
  35105. * @param format defines the format of the data
  35106. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35107. */
  35108. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35109. }
  35110. }
  35111. declare module BABYLON {
  35112. /**
  35113. * Settings for finer control over video usage
  35114. */
  35115. export interface VideoTextureSettings {
  35116. /**
  35117. * Applies `autoplay` to video, if specified
  35118. */
  35119. autoPlay?: boolean;
  35120. /**
  35121. * Applies `loop` to video, if specified
  35122. */
  35123. loop?: boolean;
  35124. /**
  35125. * Automatically updates internal texture from video at every frame in the render loop
  35126. */
  35127. autoUpdateTexture: boolean;
  35128. /**
  35129. * Image src displayed during the video loading or until the user interacts with the video.
  35130. */
  35131. poster?: string;
  35132. }
  35133. /**
  35134. * If you want to display a video in your scene, this is the special texture for that.
  35135. * This special texture works similar to other textures, with the exception of a few parameters.
  35136. * @see https://doc.babylonjs.com/how_to/video_texture
  35137. */
  35138. export class VideoTexture extends Texture {
  35139. /**
  35140. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35141. */
  35142. readonly autoUpdateTexture: boolean;
  35143. /**
  35144. * The video instance used by the texture internally
  35145. */
  35146. readonly video: HTMLVideoElement;
  35147. private _onUserActionRequestedObservable;
  35148. /**
  35149. * Event triggerd when a dom action is required by the user to play the video.
  35150. * This happens due to recent changes in browser policies preventing video to auto start.
  35151. */
  35152. get onUserActionRequestedObservable(): Observable<Texture>;
  35153. private _generateMipMaps;
  35154. private _stillImageCaptured;
  35155. private _displayingPosterTexture;
  35156. private _settings;
  35157. private _createInternalTextureOnEvent;
  35158. private _frameId;
  35159. private _currentSrc;
  35160. /**
  35161. * Creates a video texture.
  35162. * If you want to display a video in your scene, this is the special texture for that.
  35163. * This special texture works similar to other textures, with the exception of a few parameters.
  35164. * @see https://doc.babylonjs.com/how_to/video_texture
  35165. * @param name optional name, will detect from video source, if not defined
  35166. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35167. * @param scene is obviously the current scene.
  35168. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35169. * @param invertY is false by default but can be used to invert video on Y axis
  35170. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35171. * @param settings allows finer control over video usage
  35172. */
  35173. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35174. private _getName;
  35175. private _getVideo;
  35176. private _createInternalTexture;
  35177. private reset;
  35178. /**
  35179. * @hidden Internal method to initiate `update`.
  35180. */
  35181. _rebuild(): void;
  35182. /**
  35183. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35184. */
  35185. update(): void;
  35186. /**
  35187. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35188. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35189. */
  35190. updateTexture(isVisible: boolean): void;
  35191. protected _updateInternalTexture: () => void;
  35192. /**
  35193. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35194. * @param url New url.
  35195. */
  35196. updateURL(url: string): void;
  35197. /**
  35198. * Clones the texture.
  35199. * @returns the cloned texture
  35200. */
  35201. clone(): VideoTexture;
  35202. /**
  35203. * Dispose the texture and release its associated resources.
  35204. */
  35205. dispose(): void;
  35206. /**
  35207. * Creates a video texture straight from a stream.
  35208. * @param scene Define the scene the texture should be created in
  35209. * @param stream Define the stream the texture should be created from
  35210. * @returns The created video texture as a promise
  35211. */
  35212. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35213. /**
  35214. * Creates a video texture straight from your WebCam video feed.
  35215. * @param scene Define the scene the texture should be created in
  35216. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35217. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35218. * @returns The created video texture as a promise
  35219. */
  35220. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35221. minWidth: number;
  35222. maxWidth: number;
  35223. minHeight: number;
  35224. maxHeight: number;
  35225. deviceId: string;
  35226. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35227. /**
  35228. * Creates a video texture straight from your WebCam video feed.
  35229. * @param scene Define the scene the texture should be created in
  35230. * @param onReady Define a callback to triggered once the texture will be ready
  35231. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35232. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35233. */
  35234. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35235. minWidth: number;
  35236. maxWidth: number;
  35237. minHeight: number;
  35238. maxHeight: number;
  35239. deviceId: string;
  35240. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35241. }
  35242. }
  35243. declare module BABYLON {
  35244. /**
  35245. * Defines the interface used by objects working like Scene
  35246. * @hidden
  35247. */
  35248. export interface ISceneLike {
  35249. _addPendingData(data: any): void;
  35250. _removePendingData(data: any): void;
  35251. offlineProvider: IOfflineProvider;
  35252. }
  35253. /**
  35254. * Information about the current host
  35255. */
  35256. export interface HostInformation {
  35257. /**
  35258. * Defines if the current host is a mobile
  35259. */
  35260. isMobile: boolean;
  35261. }
  35262. /** Interface defining initialization parameters for Engine class */
  35263. export interface EngineOptions extends WebGLContextAttributes {
  35264. /**
  35265. * Defines if the engine should no exceed a specified device ratio
  35266. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35267. */
  35268. limitDeviceRatio?: number;
  35269. /**
  35270. * Defines if webvr should be enabled automatically
  35271. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35272. */
  35273. autoEnableWebVR?: boolean;
  35274. /**
  35275. * Defines if webgl2 should be turned off even if supported
  35276. * @see https://doc.babylonjs.com/features/webgl2
  35277. */
  35278. disableWebGL2Support?: boolean;
  35279. /**
  35280. * Defines if webaudio should be initialized as well
  35281. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35282. */
  35283. audioEngine?: boolean;
  35284. /**
  35285. * Defines if animations should run using a deterministic lock step
  35286. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35287. */
  35288. deterministicLockstep?: boolean;
  35289. /** Defines the maximum steps to use with deterministic lock step mode */
  35290. lockstepMaxSteps?: number;
  35291. /** Defines the seconds between each deterministic lock step */
  35292. timeStep?: number;
  35293. /**
  35294. * Defines that engine should ignore context lost events
  35295. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35296. */
  35297. doNotHandleContextLost?: boolean;
  35298. /**
  35299. * Defines that engine should ignore modifying touch action attribute and style
  35300. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35301. */
  35302. doNotHandleTouchAction?: boolean;
  35303. /**
  35304. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35305. */
  35306. useHighPrecisionFloats?: boolean;
  35307. /**
  35308. * Make the canvas XR Compatible for XR sessions
  35309. */
  35310. xrCompatible?: boolean;
  35311. /**
  35312. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35313. */
  35314. useHighPrecisionMatrix?: boolean;
  35315. }
  35316. /**
  35317. * The base engine class (root of all engines)
  35318. */
  35319. export class ThinEngine {
  35320. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35321. static ExceptionList: ({
  35322. key: string;
  35323. capture: string;
  35324. captureConstraint: number;
  35325. targets: string[];
  35326. } | {
  35327. key: string;
  35328. capture: null;
  35329. captureConstraint: null;
  35330. targets: string[];
  35331. })[];
  35332. /** @hidden */
  35333. static _TextureLoaders: IInternalTextureLoader[];
  35334. /**
  35335. * Returns the current npm package of the sdk
  35336. */
  35337. static get NpmPackage(): string;
  35338. /**
  35339. * Returns the current version of the framework
  35340. */
  35341. static get Version(): string;
  35342. /**
  35343. * Returns a string describing the current engine
  35344. */
  35345. get description(): string;
  35346. /**
  35347. * Gets or sets the epsilon value used by collision engine
  35348. */
  35349. static CollisionsEpsilon: number;
  35350. /**
  35351. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35352. */
  35353. static get ShadersRepository(): string;
  35354. static set ShadersRepository(value: string);
  35355. /** @hidden */
  35356. _shaderProcessor: IShaderProcessor;
  35357. /**
  35358. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35359. */
  35360. forcePOTTextures: boolean;
  35361. /**
  35362. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35363. */
  35364. isFullscreen: boolean;
  35365. /**
  35366. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35367. */
  35368. cullBackFaces: boolean;
  35369. /**
  35370. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35371. */
  35372. renderEvenInBackground: boolean;
  35373. /**
  35374. * Gets or sets a boolean indicating that cache can be kept between frames
  35375. */
  35376. preventCacheWipeBetweenFrames: boolean;
  35377. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35378. validateShaderPrograms: boolean;
  35379. /**
  35380. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35381. * This can provide greater z depth for distant objects.
  35382. */
  35383. useReverseDepthBuffer: boolean;
  35384. /**
  35385. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35386. */
  35387. disableUniformBuffers: boolean;
  35388. /** @hidden */
  35389. _uniformBuffers: UniformBuffer[];
  35390. /**
  35391. * Gets a boolean indicating that the engine supports uniform buffers
  35392. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35393. */
  35394. get supportsUniformBuffers(): boolean;
  35395. /** @hidden */
  35396. _gl: WebGLRenderingContext;
  35397. /** @hidden */
  35398. _webGLVersion: number;
  35399. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35400. protected _windowIsBackground: boolean;
  35401. protected _creationOptions: EngineOptions;
  35402. protected _highPrecisionShadersAllowed: boolean;
  35403. /** @hidden */
  35404. get _shouldUseHighPrecisionShader(): boolean;
  35405. /**
  35406. * Gets a boolean indicating that only power of 2 textures are supported
  35407. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35408. */
  35409. get needPOTTextures(): boolean;
  35410. /** @hidden */
  35411. _badOS: boolean;
  35412. /** @hidden */
  35413. _badDesktopOS: boolean;
  35414. private _hardwareScalingLevel;
  35415. /** @hidden */
  35416. _caps: EngineCapabilities;
  35417. private _isStencilEnable;
  35418. private _glVersion;
  35419. private _glRenderer;
  35420. private _glVendor;
  35421. /** @hidden */
  35422. _videoTextureSupported: boolean;
  35423. protected _renderingQueueLaunched: boolean;
  35424. protected _activeRenderLoops: (() => void)[];
  35425. /**
  35426. * Observable signaled when a context lost event is raised
  35427. */
  35428. onContextLostObservable: Observable<ThinEngine>;
  35429. /**
  35430. * Observable signaled when a context restored event is raised
  35431. */
  35432. onContextRestoredObservable: Observable<ThinEngine>;
  35433. private _onContextLost;
  35434. private _onContextRestored;
  35435. protected _contextWasLost: boolean;
  35436. /** @hidden */
  35437. _doNotHandleContextLost: boolean;
  35438. /**
  35439. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35440. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35441. */
  35442. get doNotHandleContextLost(): boolean;
  35443. set doNotHandleContextLost(value: boolean);
  35444. /**
  35445. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35446. */
  35447. disableVertexArrayObjects: boolean;
  35448. /** @hidden */
  35449. protected _colorWrite: boolean;
  35450. /** @hidden */
  35451. protected _colorWriteChanged: boolean;
  35452. /** @hidden */
  35453. protected _depthCullingState: DepthCullingState;
  35454. /** @hidden */
  35455. protected _stencilState: StencilState;
  35456. /** @hidden */
  35457. _alphaState: AlphaState;
  35458. /** @hidden */
  35459. _alphaMode: number;
  35460. /** @hidden */
  35461. _alphaEquation: number;
  35462. /** @hidden */
  35463. _internalTexturesCache: InternalTexture[];
  35464. /** @hidden */
  35465. protected _activeChannel: number;
  35466. private _currentTextureChannel;
  35467. /** @hidden */
  35468. protected _boundTexturesCache: {
  35469. [key: string]: Nullable<InternalTexture>;
  35470. };
  35471. /** @hidden */
  35472. protected _currentEffect: Nullable<Effect>;
  35473. /** @hidden */
  35474. protected _currentProgram: Nullable<WebGLProgram>;
  35475. private _compiledEffects;
  35476. private _vertexAttribArraysEnabled;
  35477. /** @hidden */
  35478. protected _cachedViewport: Nullable<IViewportLike>;
  35479. private _cachedVertexArrayObject;
  35480. /** @hidden */
  35481. protected _cachedVertexBuffers: any;
  35482. /** @hidden */
  35483. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35484. /** @hidden */
  35485. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35486. /** @hidden */
  35487. _currentRenderTarget: Nullable<InternalTexture>;
  35488. private _uintIndicesCurrentlySet;
  35489. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35490. /** @hidden */
  35491. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35492. /** @hidden */
  35493. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35494. private _currentBufferPointers;
  35495. private _currentInstanceLocations;
  35496. private _currentInstanceBuffers;
  35497. private _textureUnits;
  35498. /** @hidden */
  35499. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35500. /** @hidden */
  35501. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35502. /** @hidden */
  35503. _boundRenderFunction: any;
  35504. private _vaoRecordInProgress;
  35505. private _mustWipeVertexAttributes;
  35506. private _emptyTexture;
  35507. private _emptyCubeTexture;
  35508. private _emptyTexture3D;
  35509. private _emptyTexture2DArray;
  35510. /** @hidden */
  35511. _frameHandler: number;
  35512. private _nextFreeTextureSlots;
  35513. private _maxSimultaneousTextures;
  35514. private _activeRequests;
  35515. /** @hidden */
  35516. _transformTextureUrl: Nullable<(url: string) => string>;
  35517. /**
  35518. * Gets information about the current host
  35519. */
  35520. hostInformation: HostInformation;
  35521. protected get _supportsHardwareTextureRescaling(): boolean;
  35522. private _framebufferDimensionsObject;
  35523. /**
  35524. * sets the object from which width and height will be taken from when getting render width and height
  35525. * Will fallback to the gl object
  35526. * @param dimensions the framebuffer width and height that will be used.
  35527. */
  35528. set framebufferDimensionsObject(dimensions: Nullable<{
  35529. framebufferWidth: number;
  35530. framebufferHeight: number;
  35531. }>);
  35532. /**
  35533. * Gets the current viewport
  35534. */
  35535. get currentViewport(): Nullable<IViewportLike>;
  35536. /**
  35537. * Gets the default empty texture
  35538. */
  35539. get emptyTexture(): InternalTexture;
  35540. /**
  35541. * Gets the default empty 3D texture
  35542. */
  35543. get emptyTexture3D(): InternalTexture;
  35544. /**
  35545. * Gets the default empty 2D array texture
  35546. */
  35547. get emptyTexture2DArray(): InternalTexture;
  35548. /**
  35549. * Gets the default empty cube texture
  35550. */
  35551. get emptyCubeTexture(): InternalTexture;
  35552. /**
  35553. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35554. */
  35555. readonly premultipliedAlpha: boolean;
  35556. /**
  35557. * Observable event triggered before each texture is initialized
  35558. */
  35559. onBeforeTextureInitObservable: Observable<Texture>;
  35560. /**
  35561. * Creates a new engine
  35562. * @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
  35563. * @param antialias defines enable antialiasing (default: false)
  35564. * @param options defines further options to be sent to the getContext() function
  35565. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35566. */
  35567. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35568. private _rebuildInternalTextures;
  35569. private _rebuildEffects;
  35570. /**
  35571. * Gets a boolean indicating if all created effects are ready
  35572. * @returns true if all effects are ready
  35573. */
  35574. areAllEffectsReady(): boolean;
  35575. protected _rebuildBuffers(): void;
  35576. protected _initGLContext(): void;
  35577. /**
  35578. * Gets version of the current webGL context
  35579. */
  35580. get webGLVersion(): number;
  35581. /**
  35582. * Gets a string identifying the name of the class
  35583. * @returns "Engine" string
  35584. */
  35585. getClassName(): string;
  35586. /**
  35587. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35588. */
  35589. get isStencilEnable(): boolean;
  35590. /** @hidden */
  35591. _prepareWorkingCanvas(): void;
  35592. /**
  35593. * Reset the texture cache to empty state
  35594. */
  35595. resetTextureCache(): void;
  35596. /**
  35597. * Gets an object containing information about the current webGL context
  35598. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35599. */
  35600. getGlInfo(): {
  35601. vendor: string;
  35602. renderer: string;
  35603. version: string;
  35604. };
  35605. /**
  35606. * Defines the hardware scaling level.
  35607. * By default the hardware scaling level is computed from the window device ratio.
  35608. * 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.
  35609. * @param level defines the level to use
  35610. */
  35611. setHardwareScalingLevel(level: number): void;
  35612. /**
  35613. * Gets the current hardware scaling level.
  35614. * By default the hardware scaling level is computed from the window device ratio.
  35615. * 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.
  35616. * @returns a number indicating the current hardware scaling level
  35617. */
  35618. getHardwareScalingLevel(): number;
  35619. /**
  35620. * Gets the list of loaded textures
  35621. * @returns an array containing all loaded textures
  35622. */
  35623. getLoadedTexturesCache(): InternalTexture[];
  35624. /**
  35625. * Gets the object containing all engine capabilities
  35626. * @returns the EngineCapabilities object
  35627. */
  35628. getCaps(): EngineCapabilities;
  35629. /**
  35630. * stop executing a render loop function and remove it from the execution array
  35631. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35632. */
  35633. stopRenderLoop(renderFunction?: () => void): void;
  35634. /** @hidden */
  35635. _renderLoop(): void;
  35636. /**
  35637. * Gets the HTML canvas attached with the current webGL context
  35638. * @returns a HTML canvas
  35639. */
  35640. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35641. /**
  35642. * Gets host window
  35643. * @returns the host window object
  35644. */
  35645. getHostWindow(): Nullable<Window>;
  35646. /**
  35647. * Gets the current render width
  35648. * @param useScreen defines if screen size must be used (or the current render target if any)
  35649. * @returns a number defining the current render width
  35650. */
  35651. getRenderWidth(useScreen?: boolean): number;
  35652. /**
  35653. * Gets the current render height
  35654. * @param useScreen defines if screen size must be used (or the current render target if any)
  35655. * @returns a number defining the current render height
  35656. */
  35657. getRenderHeight(useScreen?: boolean): number;
  35658. /**
  35659. * Can be used to override the current requestAnimationFrame requester.
  35660. * @hidden
  35661. */
  35662. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35663. /**
  35664. * Register and execute a render loop. The engine can have more than one render function
  35665. * @param renderFunction defines the function to continuously execute
  35666. */
  35667. runRenderLoop(renderFunction: () => void): void;
  35668. /**
  35669. * Clear the current render buffer or the current render target (if any is set up)
  35670. * @param color defines the color to use
  35671. * @param backBuffer defines if the back buffer must be cleared
  35672. * @param depth defines if the depth buffer must be cleared
  35673. * @param stencil defines if the stencil buffer must be cleared
  35674. */
  35675. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35676. private _viewportCached;
  35677. /** @hidden */
  35678. _viewport(x: number, y: number, width: number, height: number): void;
  35679. /**
  35680. * Set the WebGL's viewport
  35681. * @param viewport defines the viewport element to be used
  35682. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35683. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35684. */
  35685. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35686. /**
  35687. * Begin a new frame
  35688. */
  35689. beginFrame(): void;
  35690. /**
  35691. * Enf the current frame
  35692. */
  35693. endFrame(): void;
  35694. /**
  35695. * Resize the view according to the canvas' size
  35696. */
  35697. resize(): void;
  35698. /**
  35699. * Force a specific size of the canvas
  35700. * @param width defines the new canvas' width
  35701. * @param height defines the new canvas' height
  35702. * @returns true if the size was changed
  35703. */
  35704. setSize(width: number, height: number): boolean;
  35705. /**
  35706. * Binds the frame buffer to the specified texture.
  35707. * @param texture The texture to render to or null for the default canvas
  35708. * @param faceIndex The face of the texture to render to in case of cube texture
  35709. * @param requiredWidth The width of the target to render to
  35710. * @param requiredHeight The height of the target to render to
  35711. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35712. * @param lodLevel defines the lod level to bind to the frame buffer
  35713. * @param layer defines the 2d array index to bind to frame buffer to
  35714. */
  35715. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35716. /** @hidden */
  35717. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35718. /**
  35719. * Unbind the current render target texture from the webGL context
  35720. * @param texture defines the render target texture to unbind
  35721. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35722. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35723. */
  35724. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35725. /**
  35726. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35727. */
  35728. flushFramebuffer(): void;
  35729. /**
  35730. * Unbind the current render target and bind the default framebuffer
  35731. */
  35732. restoreDefaultFramebuffer(): void;
  35733. /** @hidden */
  35734. protected _resetVertexBufferBinding(): void;
  35735. /**
  35736. * Creates a vertex buffer
  35737. * @param data the data for the vertex buffer
  35738. * @returns the new WebGL static buffer
  35739. */
  35740. createVertexBuffer(data: DataArray): DataBuffer;
  35741. private _createVertexBuffer;
  35742. /**
  35743. * Creates a dynamic vertex buffer
  35744. * @param data the data for the dynamic vertex buffer
  35745. * @returns the new WebGL dynamic buffer
  35746. */
  35747. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35748. protected _resetIndexBufferBinding(): void;
  35749. /**
  35750. * Creates a new index buffer
  35751. * @param indices defines the content of the index buffer
  35752. * @param updatable defines if the index buffer must be updatable
  35753. * @returns a new webGL buffer
  35754. */
  35755. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35756. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35757. /**
  35758. * Bind a webGL buffer to the webGL context
  35759. * @param buffer defines the buffer to bind
  35760. */
  35761. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35762. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35763. private bindBuffer;
  35764. /**
  35765. * update the bound buffer with the given data
  35766. * @param data defines the data to update
  35767. */
  35768. updateArrayBuffer(data: Float32Array): void;
  35769. private _vertexAttribPointer;
  35770. /** @hidden */
  35771. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35772. private _bindVertexBuffersAttributes;
  35773. /**
  35774. * Records a vertex array object
  35775. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35776. * @param vertexBuffers defines the list of vertex buffers to store
  35777. * @param indexBuffer defines the index buffer to store
  35778. * @param effect defines the effect to store
  35779. * @returns the new vertex array object
  35780. */
  35781. recordVertexArrayObject(vertexBuffers: {
  35782. [key: string]: VertexBuffer;
  35783. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35784. /**
  35785. * Bind a specific vertex array object
  35786. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35787. * @param vertexArrayObject defines the vertex array object to bind
  35788. * @param indexBuffer defines the index buffer to bind
  35789. */
  35790. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35791. /**
  35792. * Bind webGl buffers directly to the webGL context
  35793. * @param vertexBuffer defines the vertex buffer to bind
  35794. * @param indexBuffer defines the index buffer to bind
  35795. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35796. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35797. * @param effect defines the effect associated with the vertex buffer
  35798. */
  35799. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35800. private _unbindVertexArrayObject;
  35801. /**
  35802. * Bind a list of vertex buffers to the webGL context
  35803. * @param vertexBuffers defines the list of vertex buffers to bind
  35804. * @param indexBuffer defines the index buffer to bind
  35805. * @param effect defines the effect associated with the vertex buffers
  35806. */
  35807. bindBuffers(vertexBuffers: {
  35808. [key: string]: Nullable<VertexBuffer>;
  35809. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35810. /**
  35811. * Unbind all instance attributes
  35812. */
  35813. unbindInstanceAttributes(): void;
  35814. /**
  35815. * Release and free the memory of a vertex array object
  35816. * @param vao defines the vertex array object to delete
  35817. */
  35818. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35819. /** @hidden */
  35820. _releaseBuffer(buffer: DataBuffer): boolean;
  35821. protected _deleteBuffer(buffer: DataBuffer): void;
  35822. /**
  35823. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35824. * @param instancesBuffer defines the webGL buffer to update and bind
  35825. * @param data defines the data to store in the buffer
  35826. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35827. */
  35828. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35829. /**
  35830. * Bind the content of a webGL buffer used with instantiation
  35831. * @param instancesBuffer defines the webGL buffer to bind
  35832. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35833. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35834. */
  35835. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35836. /**
  35837. * Disable the instance attribute corresponding to the name in parameter
  35838. * @param name defines the name of the attribute to disable
  35839. */
  35840. disableInstanceAttributeByName(name: string): void;
  35841. /**
  35842. * Disable the instance attribute corresponding to the location in parameter
  35843. * @param attributeLocation defines the attribute location of the attribute to disable
  35844. */
  35845. disableInstanceAttribute(attributeLocation: number): void;
  35846. /**
  35847. * Disable the attribute corresponding to the location in parameter
  35848. * @param attributeLocation defines the attribute location of the attribute to disable
  35849. */
  35850. disableAttributeByIndex(attributeLocation: number): void;
  35851. /**
  35852. * Send a draw order
  35853. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35854. * @param indexStart defines the starting index
  35855. * @param indexCount defines the number of index to draw
  35856. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35857. */
  35858. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35859. /**
  35860. * Draw a list of points
  35861. * @param verticesStart defines the index of first vertex to draw
  35862. * @param verticesCount defines the count of vertices to draw
  35863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35864. */
  35865. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35866. /**
  35867. * Draw a list of unindexed primitives
  35868. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35869. * @param verticesStart defines the index of first vertex to draw
  35870. * @param verticesCount defines the count of vertices to draw
  35871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35872. */
  35873. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35874. /**
  35875. * Draw a list of indexed primitives
  35876. * @param fillMode defines the primitive to use
  35877. * @param indexStart defines the starting index
  35878. * @param indexCount defines the number of index to draw
  35879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35880. */
  35881. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35882. /**
  35883. * Draw a list of unindexed primitives
  35884. * @param fillMode defines the primitive to use
  35885. * @param verticesStart defines the index of first vertex to draw
  35886. * @param verticesCount defines the count of vertices to draw
  35887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35888. */
  35889. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35890. private _drawMode;
  35891. /** @hidden */
  35892. protected _reportDrawCall(): void;
  35893. /** @hidden */
  35894. _releaseEffect(effect: Effect): void;
  35895. /** @hidden */
  35896. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35897. /**
  35898. * Create a new effect (used to store vertex/fragment shaders)
  35899. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35900. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35901. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35902. * @param samplers defines an array of string used to represent textures
  35903. * @param defines defines the string containing the defines to use to compile the shaders
  35904. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35905. * @param onCompiled defines a function to call when the effect creation is successful
  35906. * @param onError defines a function to call when the effect creation has failed
  35907. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35908. * @returns the new Effect
  35909. */
  35910. 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;
  35911. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35912. private _compileShader;
  35913. private _compileRawShader;
  35914. /** @hidden */
  35915. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35916. /**
  35917. * Directly creates a webGL program
  35918. * @param pipelineContext defines the pipeline context to attach to
  35919. * @param vertexCode defines the vertex shader code to use
  35920. * @param fragmentCode defines the fragment shader code to use
  35921. * @param context defines the webGL context to use (if not set, the current one will be used)
  35922. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35923. * @returns the new webGL program
  35924. */
  35925. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35926. /**
  35927. * Creates a webGL program
  35928. * @param pipelineContext defines the pipeline context to attach to
  35929. * @param vertexCode defines the vertex shader code to use
  35930. * @param fragmentCode defines the fragment shader code to use
  35931. * @param defines defines the string containing the defines to use to compile the shaders
  35932. * @param context defines the webGL context to use (if not set, the current one will be used)
  35933. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35934. * @returns the new webGL program
  35935. */
  35936. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35937. /**
  35938. * Creates a new pipeline context
  35939. * @returns the new pipeline
  35940. */
  35941. createPipelineContext(): IPipelineContext;
  35942. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35943. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35944. /** @hidden */
  35945. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35946. /** @hidden */
  35947. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35948. /** @hidden */
  35949. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35950. /**
  35951. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35952. * @param pipelineContext defines the pipeline context to use
  35953. * @param uniformsNames defines the list of uniform names
  35954. * @returns an array of webGL uniform locations
  35955. */
  35956. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35957. /**
  35958. * Gets the lsit of active attributes for a given webGL program
  35959. * @param pipelineContext defines the pipeline context to use
  35960. * @param attributesNames defines the list of attribute names to get
  35961. * @returns an array of indices indicating the offset of each attribute
  35962. */
  35963. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35964. /**
  35965. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35966. * @param effect defines the effect to activate
  35967. */
  35968. enableEffect(effect: Nullable<Effect>): void;
  35969. /**
  35970. * Set the value of an uniform to a number (int)
  35971. * @param uniform defines the webGL uniform location where to store the value
  35972. * @param value defines the int number to store
  35973. */
  35974. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35975. /**
  35976. * Set the value of an uniform to an array of int32
  35977. * @param uniform defines the webGL uniform location where to store the value
  35978. * @param array defines the array of int32 to store
  35979. */
  35980. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35981. /**
  35982. * Set the value of an uniform to an array of int32 (stored as vec2)
  35983. * @param uniform defines the webGL uniform location where to store the value
  35984. * @param array defines the array of int32 to store
  35985. */
  35986. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35987. /**
  35988. * Set the value of an uniform to an array of int32 (stored as vec3)
  35989. * @param uniform defines the webGL uniform location where to store the value
  35990. * @param array defines the array of int32 to store
  35991. */
  35992. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35993. /**
  35994. * Set the value of an uniform to an array of int32 (stored as vec4)
  35995. * @param uniform defines the webGL uniform location where to store the value
  35996. * @param array defines the array of int32 to store
  35997. */
  35998. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35999. /**
  36000. * Set the value of an uniform to an array of number
  36001. * @param uniform defines the webGL uniform location where to store the value
  36002. * @param array defines the array of number to store
  36003. */
  36004. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36005. /**
  36006. * Set the value of an uniform to an array of number (stored as vec2)
  36007. * @param uniform defines the webGL uniform location where to store the value
  36008. * @param array defines the array of number to store
  36009. */
  36010. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36011. /**
  36012. * Set the value of an uniform to an array of number (stored as vec3)
  36013. * @param uniform defines the webGL uniform location where to store the value
  36014. * @param array defines the array of number to store
  36015. */
  36016. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36017. /**
  36018. * Set the value of an uniform to an array of number (stored as vec4)
  36019. * @param uniform defines the webGL uniform location where to store the value
  36020. * @param array defines the array of number to store
  36021. */
  36022. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36023. /**
  36024. * Set the value of an uniform to an array of float32 (stored as matrices)
  36025. * @param uniform defines the webGL uniform location where to store the value
  36026. * @param matrices defines the array of float32 to store
  36027. */
  36028. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36029. /**
  36030. * Set the value of an uniform to a matrix (3x3)
  36031. * @param uniform defines the webGL uniform location where to store the value
  36032. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36033. */
  36034. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36035. /**
  36036. * Set the value of an uniform to a matrix (2x2)
  36037. * @param uniform defines the webGL uniform location where to store the value
  36038. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36039. */
  36040. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36041. /**
  36042. * Set the value of an uniform to a number (float)
  36043. * @param uniform defines the webGL uniform location where to store the value
  36044. * @param value defines the float number to store
  36045. */
  36046. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36047. /**
  36048. * Set the value of an uniform to a vec2
  36049. * @param uniform defines the webGL uniform location where to store the value
  36050. * @param x defines the 1st component of the value
  36051. * @param y defines the 2nd component of the value
  36052. */
  36053. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36054. /**
  36055. * Set the value of an uniform to a vec3
  36056. * @param uniform defines the webGL uniform location where to store the value
  36057. * @param x defines the 1st component of the value
  36058. * @param y defines the 2nd component of the value
  36059. * @param z defines the 3rd component of the value
  36060. */
  36061. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36062. /**
  36063. * Set the value of an uniform to a vec4
  36064. * @param uniform defines the webGL uniform location where to store the value
  36065. * @param x defines the 1st component of the value
  36066. * @param y defines the 2nd component of the value
  36067. * @param z defines the 3rd component of the value
  36068. * @param w defines the 4th component of the value
  36069. */
  36070. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36071. /**
  36072. * Apply all cached states (depth, culling, stencil and alpha)
  36073. */
  36074. applyStates(): void;
  36075. /**
  36076. * Enable or disable color writing
  36077. * @param enable defines the state to set
  36078. */
  36079. setColorWrite(enable: boolean): void;
  36080. /**
  36081. * Gets a boolean indicating if color writing is enabled
  36082. * @returns the current color writing state
  36083. */
  36084. getColorWrite(): boolean;
  36085. /**
  36086. * Gets the depth culling state manager
  36087. */
  36088. get depthCullingState(): DepthCullingState;
  36089. /**
  36090. * Gets the alpha state manager
  36091. */
  36092. get alphaState(): AlphaState;
  36093. /**
  36094. * Gets the stencil state manager
  36095. */
  36096. get stencilState(): StencilState;
  36097. /**
  36098. * Clears the list of texture accessible through engine.
  36099. * This can help preventing texture load conflict due to name collision.
  36100. */
  36101. clearInternalTexturesCache(): void;
  36102. /**
  36103. * Force the entire cache to be cleared
  36104. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36105. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36106. */
  36107. wipeCaches(bruteForce?: boolean): void;
  36108. /** @hidden */
  36109. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36110. min: number;
  36111. mag: number;
  36112. };
  36113. /** @hidden */
  36114. _createTexture(): WebGLTexture;
  36115. /**
  36116. * Usually called from Texture.ts.
  36117. * Passed information to create a WebGLTexture
  36118. * @param url defines a value which contains one of the following:
  36119. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36120. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36121. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36122. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36123. * @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)
  36124. * @param scene needed for loading to the correct scene
  36125. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36126. * @param onLoad optional callback to be called upon successful completion
  36127. * @param onError optional callback to be called upon failure
  36128. * @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
  36129. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36130. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36131. * @param forcedExtension defines the extension to use to pick the right loader
  36132. * @param mimeType defines an optional mime type
  36133. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36134. */
  36135. 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;
  36136. /**
  36137. * Loads an image as an HTMLImageElement.
  36138. * @param input url string, ArrayBuffer, or Blob to load
  36139. * @param onLoad callback called when the image successfully loads
  36140. * @param onError callback called when the image fails to load
  36141. * @param offlineProvider offline provider for caching
  36142. * @param mimeType optional mime type
  36143. * @returns the HTMLImageElement of the loaded image
  36144. * @hidden
  36145. */
  36146. 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>;
  36147. /**
  36148. * @hidden
  36149. */
  36150. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36151. private _unpackFlipYCached;
  36152. /**
  36153. * In case you are sharing the context with other applications, it might
  36154. * be interested to not cache the unpack flip y state to ensure a consistent
  36155. * value would be set.
  36156. */
  36157. enableUnpackFlipYCached: boolean;
  36158. /** @hidden */
  36159. _unpackFlipY(value: boolean): void;
  36160. /** @hidden */
  36161. _getUnpackAlignement(): number;
  36162. private _getTextureTarget;
  36163. /**
  36164. * Update the sampling mode of a given texture
  36165. * @param samplingMode defines the required sampling mode
  36166. * @param texture defines the texture to update
  36167. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36168. */
  36169. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36170. /**
  36171. * Update the sampling mode of a given texture
  36172. * @param texture defines the texture to update
  36173. * @param wrapU defines the texture wrap mode of the u coordinates
  36174. * @param wrapV defines the texture wrap mode of the v coordinates
  36175. * @param wrapR defines the texture wrap mode of the r coordinates
  36176. */
  36177. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36178. /** @hidden */
  36179. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36180. width: number;
  36181. height: number;
  36182. layers?: number;
  36183. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36184. /** @hidden */
  36185. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36186. /** @hidden */
  36187. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36188. /**
  36189. * Update a portion of an internal texture
  36190. * @param texture defines the texture to update
  36191. * @param imageData defines the data to store into the texture
  36192. * @param xOffset defines the x coordinates of the update rectangle
  36193. * @param yOffset defines the y coordinates of the update rectangle
  36194. * @param width defines the width of the update rectangle
  36195. * @param height defines the height of the update rectangle
  36196. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36197. * @param lod defines the lod level to update (0 by default)
  36198. */
  36199. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36200. /** @hidden */
  36201. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36202. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36203. private _prepareWebGLTexture;
  36204. /** @hidden */
  36205. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36206. private _getDepthStencilBuffer;
  36207. /** @hidden */
  36208. _releaseFramebufferObjects(texture: InternalTexture): void;
  36209. /** @hidden */
  36210. _releaseTexture(texture: InternalTexture): void;
  36211. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36212. protected _setProgram(program: WebGLProgram): void;
  36213. protected _boundUniforms: {
  36214. [key: number]: WebGLUniformLocation;
  36215. };
  36216. /**
  36217. * Binds an effect to the webGL context
  36218. * @param effect defines the effect to bind
  36219. */
  36220. bindSamplers(effect: Effect): void;
  36221. private _activateCurrentTexture;
  36222. /** @hidden */
  36223. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36224. /** @hidden */
  36225. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36226. /**
  36227. * Unbind all textures from the webGL context
  36228. */
  36229. unbindAllTextures(): void;
  36230. /**
  36231. * Sets a texture to the according uniform.
  36232. * @param channel The texture channel
  36233. * @param uniform The uniform to set
  36234. * @param texture The texture to apply
  36235. */
  36236. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36237. private _bindSamplerUniformToChannel;
  36238. private _getTextureWrapMode;
  36239. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36240. /**
  36241. * Sets an array of texture to the webGL context
  36242. * @param channel defines the channel where the texture array must be set
  36243. * @param uniform defines the associated uniform location
  36244. * @param textures defines the array of textures to bind
  36245. */
  36246. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36247. /** @hidden */
  36248. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36249. private _setTextureParameterFloat;
  36250. private _setTextureParameterInteger;
  36251. /**
  36252. * Unbind all vertex attributes from the webGL context
  36253. */
  36254. unbindAllAttributes(): void;
  36255. /**
  36256. * 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
  36257. */
  36258. releaseEffects(): void;
  36259. /**
  36260. * Dispose and release all associated resources
  36261. */
  36262. dispose(): void;
  36263. /**
  36264. * Attach a new callback raised when context lost event is fired
  36265. * @param callback defines the callback to call
  36266. */
  36267. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36268. /**
  36269. * Attach a new callback raised when context restored event is fired
  36270. * @param callback defines the callback to call
  36271. */
  36272. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36273. /**
  36274. * Get the current error code of the webGL context
  36275. * @returns the error code
  36276. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36277. */
  36278. getError(): number;
  36279. private _canRenderToFloatFramebuffer;
  36280. private _canRenderToHalfFloatFramebuffer;
  36281. private _canRenderToFramebuffer;
  36282. /** @hidden */
  36283. _getWebGLTextureType(type: number): number;
  36284. /** @hidden */
  36285. _getInternalFormat(format: number): number;
  36286. /** @hidden */
  36287. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36288. /** @hidden */
  36289. _getRGBAMultiSampleBufferFormat(type: number): number;
  36290. /** @hidden */
  36291. _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;
  36292. /**
  36293. * Loads a file from a url
  36294. * @param url url to load
  36295. * @param onSuccess callback called when the file successfully loads
  36296. * @param onProgress callback called while file is loading (if the server supports this mode)
  36297. * @param offlineProvider defines the offline provider for caching
  36298. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36299. * @param onError callback called when the file fails to load
  36300. * @returns a file request object
  36301. * @hidden
  36302. */
  36303. 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;
  36304. /**
  36305. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36306. * @param x defines the x coordinate of the rectangle where pixels must be read
  36307. * @param y defines the y coordinate of the rectangle where pixels must be read
  36308. * @param width defines the width of the rectangle where pixels must be read
  36309. * @param height defines the height of the rectangle where pixels must be read
  36310. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36311. * @returns a Uint8Array containing RGBA colors
  36312. */
  36313. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36314. private static _isSupported;
  36315. /**
  36316. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36317. * @returns true if the engine can be created
  36318. * @ignorenaming
  36319. */
  36320. static isSupported(): boolean;
  36321. /**
  36322. * Find the next highest power of two.
  36323. * @param x Number to start search from.
  36324. * @return Next highest power of two.
  36325. */
  36326. static CeilingPOT(x: number): number;
  36327. /**
  36328. * Find the next lowest power of two.
  36329. * @param x Number to start search from.
  36330. * @return Next lowest power of two.
  36331. */
  36332. static FloorPOT(x: number): number;
  36333. /**
  36334. * Find the nearest power of two.
  36335. * @param x Number to start search from.
  36336. * @return Next nearest power of two.
  36337. */
  36338. static NearestPOT(x: number): number;
  36339. /**
  36340. * Get the closest exponent of two
  36341. * @param value defines the value to approximate
  36342. * @param max defines the maximum value to return
  36343. * @param mode defines how to define the closest value
  36344. * @returns closest exponent of two of the given value
  36345. */
  36346. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36347. /**
  36348. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36349. * @param func - the function to be called
  36350. * @param requester - the object that will request the next frame. Falls back to window.
  36351. * @returns frame number
  36352. */
  36353. static QueueNewFrame(func: () => void, requester?: any): number;
  36354. /**
  36355. * Gets host document
  36356. * @returns the host document object
  36357. */
  36358. getHostDocument(): Nullable<Document>;
  36359. }
  36360. }
  36361. declare module BABYLON {
  36362. /**
  36363. * Class representing spherical harmonics coefficients to the 3rd degree
  36364. */
  36365. export class SphericalHarmonics {
  36366. /**
  36367. * Defines whether or not the harmonics have been prescaled for rendering.
  36368. */
  36369. preScaled: boolean;
  36370. /**
  36371. * The l0,0 coefficients of the spherical harmonics
  36372. */
  36373. l00: Vector3;
  36374. /**
  36375. * The l1,-1 coefficients of the spherical harmonics
  36376. */
  36377. l1_1: Vector3;
  36378. /**
  36379. * The l1,0 coefficients of the spherical harmonics
  36380. */
  36381. l10: Vector3;
  36382. /**
  36383. * The l1,1 coefficients of the spherical harmonics
  36384. */
  36385. l11: Vector3;
  36386. /**
  36387. * The l2,-2 coefficients of the spherical harmonics
  36388. */
  36389. l2_2: Vector3;
  36390. /**
  36391. * The l2,-1 coefficients of the spherical harmonics
  36392. */
  36393. l2_1: Vector3;
  36394. /**
  36395. * The l2,0 coefficients of the spherical harmonics
  36396. */
  36397. l20: Vector3;
  36398. /**
  36399. * The l2,1 coefficients of the spherical harmonics
  36400. */
  36401. l21: Vector3;
  36402. /**
  36403. * The l2,2 coefficients of the spherical harmonics
  36404. */
  36405. l22: Vector3;
  36406. /**
  36407. * Adds a light to the spherical harmonics
  36408. * @param direction the direction of the light
  36409. * @param color the color of the light
  36410. * @param deltaSolidAngle the delta solid angle of the light
  36411. */
  36412. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36413. /**
  36414. * Scales the spherical harmonics by the given amount
  36415. * @param scale the amount to scale
  36416. */
  36417. scaleInPlace(scale: number): void;
  36418. /**
  36419. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36420. *
  36421. * ```
  36422. * E_lm = A_l * L_lm
  36423. * ```
  36424. *
  36425. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36426. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36427. * the scaling factors are given in equation 9.
  36428. */
  36429. convertIncidentRadianceToIrradiance(): void;
  36430. /**
  36431. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36432. *
  36433. * ```
  36434. * L = (1/pi) * E * rho
  36435. * ```
  36436. *
  36437. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36438. */
  36439. convertIrradianceToLambertianRadiance(): void;
  36440. /**
  36441. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36442. * required operations at run time.
  36443. *
  36444. * This is simply done by scaling back the SH with Ylm constants parameter.
  36445. * The trigonometric part being applied by the shader at run time.
  36446. */
  36447. preScaleForRendering(): void;
  36448. /**
  36449. * Constructs a spherical harmonics from an array.
  36450. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36451. * @returns the spherical harmonics
  36452. */
  36453. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36454. /**
  36455. * Gets the spherical harmonics from polynomial
  36456. * @param polynomial the spherical polynomial
  36457. * @returns the spherical harmonics
  36458. */
  36459. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36460. }
  36461. /**
  36462. * Class representing spherical polynomial coefficients to the 3rd degree
  36463. */
  36464. export class SphericalPolynomial {
  36465. private _harmonics;
  36466. /**
  36467. * The spherical harmonics used to create the polynomials.
  36468. */
  36469. get preScaledHarmonics(): SphericalHarmonics;
  36470. /**
  36471. * The x coefficients of the spherical polynomial
  36472. */
  36473. x: Vector3;
  36474. /**
  36475. * The y coefficients of the spherical polynomial
  36476. */
  36477. y: Vector3;
  36478. /**
  36479. * The z coefficients of the spherical polynomial
  36480. */
  36481. z: Vector3;
  36482. /**
  36483. * The xx coefficients of the spherical polynomial
  36484. */
  36485. xx: Vector3;
  36486. /**
  36487. * The yy coefficients of the spherical polynomial
  36488. */
  36489. yy: Vector3;
  36490. /**
  36491. * The zz coefficients of the spherical polynomial
  36492. */
  36493. zz: Vector3;
  36494. /**
  36495. * The xy coefficients of the spherical polynomial
  36496. */
  36497. xy: Vector3;
  36498. /**
  36499. * The yz coefficients of the spherical polynomial
  36500. */
  36501. yz: Vector3;
  36502. /**
  36503. * The zx coefficients of the spherical polynomial
  36504. */
  36505. zx: Vector3;
  36506. /**
  36507. * Adds an ambient color to the spherical polynomial
  36508. * @param color the color to add
  36509. */
  36510. addAmbient(color: Color3): void;
  36511. /**
  36512. * Scales the spherical polynomial by the given amount
  36513. * @param scale the amount to scale
  36514. */
  36515. scaleInPlace(scale: number): void;
  36516. /**
  36517. * Gets the spherical polynomial from harmonics
  36518. * @param harmonics the spherical harmonics
  36519. * @returns the spherical polynomial
  36520. */
  36521. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36522. /**
  36523. * Constructs a spherical polynomial from an array.
  36524. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36525. * @returns the spherical polynomial
  36526. */
  36527. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36528. }
  36529. }
  36530. declare module BABYLON {
  36531. /**
  36532. * Defines the source of the internal texture
  36533. */
  36534. export enum InternalTextureSource {
  36535. /**
  36536. * The source of the texture data is unknown
  36537. */
  36538. Unknown = 0,
  36539. /**
  36540. * Texture data comes from an URL
  36541. */
  36542. Url = 1,
  36543. /**
  36544. * Texture data is only used for temporary storage
  36545. */
  36546. Temp = 2,
  36547. /**
  36548. * Texture data comes from raw data (ArrayBuffer)
  36549. */
  36550. Raw = 3,
  36551. /**
  36552. * Texture content is dynamic (video or dynamic texture)
  36553. */
  36554. Dynamic = 4,
  36555. /**
  36556. * Texture content is generated by rendering to it
  36557. */
  36558. RenderTarget = 5,
  36559. /**
  36560. * Texture content is part of a multi render target process
  36561. */
  36562. MultiRenderTarget = 6,
  36563. /**
  36564. * Texture data comes from a cube data file
  36565. */
  36566. Cube = 7,
  36567. /**
  36568. * Texture data comes from a raw cube data
  36569. */
  36570. CubeRaw = 8,
  36571. /**
  36572. * Texture data come from a prefiltered cube data file
  36573. */
  36574. CubePrefiltered = 9,
  36575. /**
  36576. * Texture content is raw 3D data
  36577. */
  36578. Raw3D = 10,
  36579. /**
  36580. * Texture content is raw 2D array data
  36581. */
  36582. Raw2DArray = 11,
  36583. /**
  36584. * Texture content is a depth texture
  36585. */
  36586. Depth = 12,
  36587. /**
  36588. * Texture data comes from a raw cube data encoded with RGBD
  36589. */
  36590. CubeRawRGBD = 13
  36591. }
  36592. /**
  36593. * Class used to store data associated with WebGL texture data for the engine
  36594. * This class should not be used directly
  36595. */
  36596. export class InternalTexture {
  36597. /** @hidden */
  36598. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36599. /**
  36600. * Defines if the texture is ready
  36601. */
  36602. isReady: boolean;
  36603. /**
  36604. * Defines if the texture is a cube texture
  36605. */
  36606. isCube: boolean;
  36607. /**
  36608. * Defines if the texture contains 3D data
  36609. */
  36610. is3D: boolean;
  36611. /**
  36612. * Defines if the texture contains 2D array data
  36613. */
  36614. is2DArray: boolean;
  36615. /**
  36616. * Defines if the texture contains multiview data
  36617. */
  36618. isMultiview: boolean;
  36619. /**
  36620. * Gets the URL used to load this texture
  36621. */
  36622. url: string;
  36623. /**
  36624. * Gets the sampling mode of the texture
  36625. */
  36626. samplingMode: number;
  36627. /**
  36628. * Gets a boolean indicating if the texture needs mipmaps generation
  36629. */
  36630. generateMipMaps: boolean;
  36631. /**
  36632. * Gets the number of samples used by the texture (WebGL2+ only)
  36633. */
  36634. samples: number;
  36635. /**
  36636. * Gets the type of the texture (int, float...)
  36637. */
  36638. type: number;
  36639. /**
  36640. * Gets the format of the texture (RGB, RGBA...)
  36641. */
  36642. format: number;
  36643. /**
  36644. * Observable called when the texture is loaded
  36645. */
  36646. onLoadedObservable: Observable<InternalTexture>;
  36647. /**
  36648. * Gets the width of the texture
  36649. */
  36650. width: number;
  36651. /**
  36652. * Gets the height of the texture
  36653. */
  36654. height: number;
  36655. /**
  36656. * Gets the depth of the texture
  36657. */
  36658. depth: number;
  36659. /**
  36660. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36661. */
  36662. baseWidth: number;
  36663. /**
  36664. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36665. */
  36666. baseHeight: number;
  36667. /**
  36668. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36669. */
  36670. baseDepth: number;
  36671. /**
  36672. * Gets a boolean indicating if the texture is inverted on Y axis
  36673. */
  36674. invertY: boolean;
  36675. /** @hidden */
  36676. _invertVScale: boolean;
  36677. /** @hidden */
  36678. _associatedChannel: number;
  36679. /** @hidden */
  36680. _source: InternalTextureSource;
  36681. /** @hidden */
  36682. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36683. /** @hidden */
  36684. _bufferView: Nullable<ArrayBufferView>;
  36685. /** @hidden */
  36686. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36687. /** @hidden */
  36688. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36689. /** @hidden */
  36690. _size: number;
  36691. /** @hidden */
  36692. _extension: string;
  36693. /** @hidden */
  36694. _files: Nullable<string[]>;
  36695. /** @hidden */
  36696. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36697. /** @hidden */
  36698. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36699. /** @hidden */
  36700. _framebuffer: Nullable<WebGLFramebuffer>;
  36701. /** @hidden */
  36702. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36703. /** @hidden */
  36704. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36705. /** @hidden */
  36706. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36707. /** @hidden */
  36708. _attachments: Nullable<number[]>;
  36709. /** @hidden */
  36710. _textureArray: Nullable<InternalTexture[]>;
  36711. /** @hidden */
  36712. _cachedCoordinatesMode: Nullable<number>;
  36713. /** @hidden */
  36714. _cachedWrapU: Nullable<number>;
  36715. /** @hidden */
  36716. _cachedWrapV: Nullable<number>;
  36717. /** @hidden */
  36718. _cachedWrapR: Nullable<number>;
  36719. /** @hidden */
  36720. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36721. /** @hidden */
  36722. _isDisabled: boolean;
  36723. /** @hidden */
  36724. _compression: Nullable<string>;
  36725. /** @hidden */
  36726. _generateStencilBuffer: boolean;
  36727. /** @hidden */
  36728. _generateDepthBuffer: boolean;
  36729. /** @hidden */
  36730. _comparisonFunction: number;
  36731. /** @hidden */
  36732. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36733. /** @hidden */
  36734. _lodGenerationScale: number;
  36735. /** @hidden */
  36736. _lodGenerationOffset: number;
  36737. /** @hidden */
  36738. _depthStencilTexture: Nullable<InternalTexture>;
  36739. /** @hidden */
  36740. _colorTextureArray: Nullable<WebGLTexture>;
  36741. /** @hidden */
  36742. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36743. /** @hidden */
  36744. _lodTextureHigh: Nullable<BaseTexture>;
  36745. /** @hidden */
  36746. _lodTextureMid: Nullable<BaseTexture>;
  36747. /** @hidden */
  36748. _lodTextureLow: Nullable<BaseTexture>;
  36749. /** @hidden */
  36750. _isRGBD: boolean;
  36751. /** @hidden */
  36752. _linearSpecularLOD: boolean;
  36753. /** @hidden */
  36754. _irradianceTexture: Nullable<BaseTexture>;
  36755. /** @hidden */
  36756. _webGLTexture: Nullable<WebGLTexture>;
  36757. /** @hidden */
  36758. _references: number;
  36759. /** @hidden */
  36760. _gammaSpace: Nullable<boolean>;
  36761. private _engine;
  36762. /**
  36763. * Gets the Engine the texture belongs to.
  36764. * @returns The babylon engine
  36765. */
  36766. getEngine(): ThinEngine;
  36767. /**
  36768. * Gets the data source type of the texture
  36769. */
  36770. get source(): InternalTextureSource;
  36771. /**
  36772. * Creates a new InternalTexture
  36773. * @param engine defines the engine to use
  36774. * @param source defines the type of data that will be used
  36775. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36776. */
  36777. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36778. /**
  36779. * Increments the number of references (ie. the number of Texture that point to it)
  36780. */
  36781. incrementReferences(): void;
  36782. /**
  36783. * Change the size of the texture (not the size of the content)
  36784. * @param width defines the new width
  36785. * @param height defines the new height
  36786. * @param depth defines the new depth (1 by default)
  36787. */
  36788. updateSize(width: int, height: int, depth?: int): void;
  36789. /** @hidden */
  36790. _rebuild(): void;
  36791. /** @hidden */
  36792. _swapAndDie(target: InternalTexture): void;
  36793. /**
  36794. * Dispose the current allocated resources
  36795. */
  36796. dispose(): void;
  36797. }
  36798. }
  36799. declare module BABYLON {
  36800. /**
  36801. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36802. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36803. */
  36804. export class Analyser {
  36805. /**
  36806. * Gets or sets the smoothing
  36807. * @ignorenaming
  36808. */
  36809. SMOOTHING: number;
  36810. /**
  36811. * Gets or sets the FFT table size
  36812. * @ignorenaming
  36813. */
  36814. FFT_SIZE: number;
  36815. /**
  36816. * Gets or sets the bar graph amplitude
  36817. * @ignorenaming
  36818. */
  36819. BARGRAPHAMPLITUDE: number;
  36820. /**
  36821. * Gets or sets the position of the debug canvas
  36822. * @ignorenaming
  36823. */
  36824. DEBUGCANVASPOS: {
  36825. x: number;
  36826. y: number;
  36827. };
  36828. /**
  36829. * Gets or sets the debug canvas size
  36830. * @ignorenaming
  36831. */
  36832. DEBUGCANVASSIZE: {
  36833. width: number;
  36834. height: number;
  36835. };
  36836. private _byteFreqs;
  36837. private _byteTime;
  36838. private _floatFreqs;
  36839. private _webAudioAnalyser;
  36840. private _debugCanvas;
  36841. private _debugCanvasContext;
  36842. private _scene;
  36843. private _registerFunc;
  36844. private _audioEngine;
  36845. /**
  36846. * Creates a new analyser
  36847. * @param scene defines hosting scene
  36848. */
  36849. constructor(scene: Scene);
  36850. /**
  36851. * Get the number of data values you will have to play with for the visualization
  36852. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36853. * @returns a number
  36854. */
  36855. getFrequencyBinCount(): number;
  36856. /**
  36857. * Gets the current frequency data as a byte array
  36858. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36859. * @returns a Uint8Array
  36860. */
  36861. getByteFrequencyData(): Uint8Array;
  36862. /**
  36863. * Gets the current waveform as a byte array
  36864. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36865. * @returns a Uint8Array
  36866. */
  36867. getByteTimeDomainData(): Uint8Array;
  36868. /**
  36869. * Gets the current frequency data as a float array
  36870. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36871. * @returns a Float32Array
  36872. */
  36873. getFloatFrequencyData(): Float32Array;
  36874. /**
  36875. * Renders the debug canvas
  36876. */
  36877. drawDebugCanvas(): void;
  36878. /**
  36879. * Stops rendering the debug canvas and removes it
  36880. */
  36881. stopDebugCanvas(): void;
  36882. /**
  36883. * Connects two audio nodes
  36884. * @param inputAudioNode defines first node to connect
  36885. * @param outputAudioNode defines second node to connect
  36886. */
  36887. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36888. /**
  36889. * Releases all associated resources
  36890. */
  36891. dispose(): void;
  36892. }
  36893. }
  36894. declare module BABYLON {
  36895. /**
  36896. * This represents an audio engine and it is responsible
  36897. * to play, synchronize and analyse sounds throughout the application.
  36898. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36899. */
  36900. export interface IAudioEngine extends IDisposable {
  36901. /**
  36902. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36903. */
  36904. readonly canUseWebAudio: boolean;
  36905. /**
  36906. * Gets the current AudioContext if available.
  36907. */
  36908. readonly audioContext: Nullable<AudioContext>;
  36909. /**
  36910. * The master gain node defines the global audio volume of your audio engine.
  36911. */
  36912. readonly masterGain: GainNode;
  36913. /**
  36914. * Gets whether or not mp3 are supported by your browser.
  36915. */
  36916. readonly isMP3supported: boolean;
  36917. /**
  36918. * Gets whether or not ogg are supported by your browser.
  36919. */
  36920. readonly isOGGsupported: boolean;
  36921. /**
  36922. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36923. * @ignoreNaming
  36924. */
  36925. WarnedWebAudioUnsupported: boolean;
  36926. /**
  36927. * Defines if the audio engine relies on a custom unlocked button.
  36928. * In this case, the embedded button will not be displayed.
  36929. */
  36930. useCustomUnlockedButton: boolean;
  36931. /**
  36932. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36933. */
  36934. readonly unlocked: boolean;
  36935. /**
  36936. * Event raised when audio has been unlocked on the browser.
  36937. */
  36938. onAudioUnlockedObservable: Observable<AudioEngine>;
  36939. /**
  36940. * Event raised when audio has been locked on the browser.
  36941. */
  36942. onAudioLockedObservable: Observable<AudioEngine>;
  36943. /**
  36944. * Flags the audio engine in Locked state.
  36945. * This happens due to new browser policies preventing audio to autoplay.
  36946. */
  36947. lock(): void;
  36948. /**
  36949. * Unlocks the audio engine once a user action has been done on the dom.
  36950. * This is helpful to resume play once browser policies have been satisfied.
  36951. */
  36952. unlock(): void;
  36953. /**
  36954. * Gets the global volume sets on the master gain.
  36955. * @returns the global volume if set or -1 otherwise
  36956. */
  36957. getGlobalVolume(): number;
  36958. /**
  36959. * Sets the global volume of your experience (sets on the master gain).
  36960. * @param newVolume Defines the new global volume of the application
  36961. */
  36962. setGlobalVolume(newVolume: number): void;
  36963. /**
  36964. * Connect the audio engine to an audio analyser allowing some amazing
  36965. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36966. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36967. * @param analyser The analyser to connect to the engine
  36968. */
  36969. connectToAnalyser(analyser: Analyser): void;
  36970. }
  36971. /**
  36972. * This represents the default audio engine used in babylon.
  36973. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36974. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36975. */
  36976. export class AudioEngine implements IAudioEngine {
  36977. private _audioContext;
  36978. private _audioContextInitialized;
  36979. private _muteButton;
  36980. private _hostElement;
  36981. /**
  36982. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36983. */
  36984. canUseWebAudio: boolean;
  36985. /**
  36986. * The master gain node defines the global audio volume of your audio engine.
  36987. */
  36988. masterGain: GainNode;
  36989. /**
  36990. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36991. * @ignoreNaming
  36992. */
  36993. WarnedWebAudioUnsupported: boolean;
  36994. /**
  36995. * Gets whether or not mp3 are supported by your browser.
  36996. */
  36997. isMP3supported: boolean;
  36998. /**
  36999. * Gets whether or not ogg are supported by your browser.
  37000. */
  37001. isOGGsupported: boolean;
  37002. /**
  37003. * Gets whether audio has been unlocked on the device.
  37004. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37005. * a user interaction has happened.
  37006. */
  37007. unlocked: boolean;
  37008. /**
  37009. * Defines if the audio engine relies on a custom unlocked button.
  37010. * In this case, the embedded button will not be displayed.
  37011. */
  37012. useCustomUnlockedButton: boolean;
  37013. /**
  37014. * Event raised when audio has been unlocked on the browser.
  37015. */
  37016. onAudioUnlockedObservable: Observable<AudioEngine>;
  37017. /**
  37018. * Event raised when audio has been locked on the browser.
  37019. */
  37020. onAudioLockedObservable: Observable<AudioEngine>;
  37021. /**
  37022. * Gets the current AudioContext if available.
  37023. */
  37024. get audioContext(): Nullable<AudioContext>;
  37025. private _connectedAnalyser;
  37026. /**
  37027. * Instantiates a new audio engine.
  37028. *
  37029. * There should be only one per page as some browsers restrict the number
  37030. * of audio contexts you can create.
  37031. * @param hostElement defines the host element where to display the mute icon if necessary
  37032. */
  37033. constructor(hostElement?: Nullable<HTMLElement>);
  37034. /**
  37035. * Flags the audio engine in Locked state.
  37036. * This happens due to new browser policies preventing audio to autoplay.
  37037. */
  37038. lock(): void;
  37039. /**
  37040. * Unlocks the audio engine once a user action has been done on the dom.
  37041. * This is helpful to resume play once browser policies have been satisfied.
  37042. */
  37043. unlock(): void;
  37044. private _resumeAudioContext;
  37045. private _initializeAudioContext;
  37046. private _tryToRun;
  37047. private _triggerRunningState;
  37048. private _triggerSuspendedState;
  37049. private _displayMuteButton;
  37050. private _moveButtonToTopLeft;
  37051. private _onResize;
  37052. private _hideMuteButton;
  37053. /**
  37054. * Destroy and release the resources associated with the audio ccontext.
  37055. */
  37056. dispose(): void;
  37057. /**
  37058. * Gets the global volume sets on the master gain.
  37059. * @returns the global volume if set or -1 otherwise
  37060. */
  37061. getGlobalVolume(): number;
  37062. /**
  37063. * Sets the global volume of your experience (sets on the master gain).
  37064. * @param newVolume Defines the new global volume of the application
  37065. */
  37066. setGlobalVolume(newVolume: number): void;
  37067. /**
  37068. * Connect the audio engine to an audio analyser allowing some amazing
  37069. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37071. * @param analyser The analyser to connect to the engine
  37072. */
  37073. connectToAnalyser(analyser: Analyser): void;
  37074. }
  37075. }
  37076. declare module BABYLON {
  37077. /**
  37078. * Interface used to present a loading screen while loading a scene
  37079. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37080. */
  37081. export interface ILoadingScreen {
  37082. /**
  37083. * Function called to display the loading screen
  37084. */
  37085. displayLoadingUI: () => void;
  37086. /**
  37087. * Function called to hide the loading screen
  37088. */
  37089. hideLoadingUI: () => void;
  37090. /**
  37091. * Gets or sets the color to use for the background
  37092. */
  37093. loadingUIBackgroundColor: string;
  37094. /**
  37095. * Gets or sets the text to display while loading
  37096. */
  37097. loadingUIText: string;
  37098. }
  37099. /**
  37100. * Class used for the default loading screen
  37101. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37102. */
  37103. export class DefaultLoadingScreen implements ILoadingScreen {
  37104. private _renderingCanvas;
  37105. private _loadingText;
  37106. private _loadingDivBackgroundColor;
  37107. private _loadingDiv;
  37108. private _loadingTextDiv;
  37109. /** Gets or sets the logo url to use for the default loading screen */
  37110. static DefaultLogoUrl: string;
  37111. /** Gets or sets the spinner url to use for the default loading screen */
  37112. static DefaultSpinnerUrl: string;
  37113. /**
  37114. * Creates a new default loading screen
  37115. * @param _renderingCanvas defines the canvas used to render the scene
  37116. * @param _loadingText defines the default text to display
  37117. * @param _loadingDivBackgroundColor defines the default background color
  37118. */
  37119. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37120. /**
  37121. * Function called to display the loading screen
  37122. */
  37123. displayLoadingUI(): void;
  37124. /**
  37125. * Function called to hide the loading screen
  37126. */
  37127. hideLoadingUI(): void;
  37128. /**
  37129. * Gets or sets the text to display while loading
  37130. */
  37131. set loadingUIText(text: string);
  37132. get loadingUIText(): string;
  37133. /**
  37134. * Gets or sets the color to use for the background
  37135. */
  37136. get loadingUIBackgroundColor(): string;
  37137. set loadingUIBackgroundColor(color: string);
  37138. private _resizeLoadingUI;
  37139. }
  37140. }
  37141. declare module BABYLON {
  37142. /**
  37143. * Interface for any object that can request an animation frame
  37144. */
  37145. export interface ICustomAnimationFrameRequester {
  37146. /**
  37147. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37148. */
  37149. renderFunction?: Function;
  37150. /**
  37151. * Called to request the next frame to render to
  37152. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37153. */
  37154. requestAnimationFrame: Function;
  37155. /**
  37156. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37157. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37158. */
  37159. requestID?: number;
  37160. }
  37161. }
  37162. declare module BABYLON {
  37163. /**
  37164. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37165. */
  37166. export class PerformanceMonitor {
  37167. private _enabled;
  37168. private _rollingFrameTime;
  37169. private _lastFrameTimeMs;
  37170. /**
  37171. * constructor
  37172. * @param frameSampleSize The number of samples required to saturate the sliding window
  37173. */
  37174. constructor(frameSampleSize?: number);
  37175. /**
  37176. * Samples current frame
  37177. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37178. */
  37179. sampleFrame(timeMs?: number): void;
  37180. /**
  37181. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37182. */
  37183. get averageFrameTime(): number;
  37184. /**
  37185. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37186. */
  37187. get averageFrameTimeVariance(): number;
  37188. /**
  37189. * Returns the frame time of the most recent frame
  37190. */
  37191. get instantaneousFrameTime(): number;
  37192. /**
  37193. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37194. */
  37195. get averageFPS(): number;
  37196. /**
  37197. * Returns the average framerate in frames per second using the most recent frame time
  37198. */
  37199. get instantaneousFPS(): number;
  37200. /**
  37201. * Returns true if enough samples have been taken to completely fill the sliding window
  37202. */
  37203. get isSaturated(): boolean;
  37204. /**
  37205. * Enables contributions to the sliding window sample set
  37206. */
  37207. enable(): void;
  37208. /**
  37209. * Disables contributions to the sliding window sample set
  37210. * Samples will not be interpolated over the disabled period
  37211. */
  37212. disable(): void;
  37213. /**
  37214. * Returns true if sampling is enabled
  37215. */
  37216. get isEnabled(): boolean;
  37217. /**
  37218. * Resets performance monitor
  37219. */
  37220. reset(): void;
  37221. }
  37222. /**
  37223. * RollingAverage
  37224. *
  37225. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37226. */
  37227. export class RollingAverage {
  37228. /**
  37229. * Current average
  37230. */
  37231. average: number;
  37232. /**
  37233. * Current variance
  37234. */
  37235. variance: number;
  37236. protected _samples: Array<number>;
  37237. protected _sampleCount: number;
  37238. protected _pos: number;
  37239. protected _m2: number;
  37240. /**
  37241. * constructor
  37242. * @param length The number of samples required to saturate the sliding window
  37243. */
  37244. constructor(length: number);
  37245. /**
  37246. * Adds a sample to the sample set
  37247. * @param v The sample value
  37248. */
  37249. add(v: number): void;
  37250. /**
  37251. * Returns previously added values or null if outside of history or outside the sliding window domain
  37252. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37253. * @return Value previously recorded with add() or null if outside of range
  37254. */
  37255. history(i: number): number;
  37256. /**
  37257. * Returns true if enough samples have been taken to completely fill the sliding window
  37258. * @return true if sample-set saturated
  37259. */
  37260. isSaturated(): boolean;
  37261. /**
  37262. * Resets the rolling average (equivalent to 0 samples taken so far)
  37263. */
  37264. reset(): void;
  37265. /**
  37266. * Wraps a value around the sample range boundaries
  37267. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37268. * @return Wrapped position in sample range
  37269. */
  37270. protected _wrapPosition(i: number): number;
  37271. }
  37272. }
  37273. declare module BABYLON {
  37274. /**
  37275. * This class is used to track a performance counter which is number based.
  37276. * The user has access to many properties which give statistics of different nature.
  37277. *
  37278. * The implementer can track two kinds of Performance Counter: time and count.
  37279. * 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.
  37280. * 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.
  37281. */
  37282. export class PerfCounter {
  37283. /**
  37284. * Gets or sets a global boolean to turn on and off all the counters
  37285. */
  37286. static Enabled: boolean;
  37287. /**
  37288. * Returns the smallest value ever
  37289. */
  37290. get min(): number;
  37291. /**
  37292. * Returns the biggest value ever
  37293. */
  37294. get max(): number;
  37295. /**
  37296. * Returns the average value since the performance counter is running
  37297. */
  37298. get average(): number;
  37299. /**
  37300. * Returns the average value of the last second the counter was monitored
  37301. */
  37302. get lastSecAverage(): number;
  37303. /**
  37304. * Returns the current value
  37305. */
  37306. get current(): number;
  37307. /**
  37308. * Gets the accumulated total
  37309. */
  37310. get total(): number;
  37311. /**
  37312. * Gets the total value count
  37313. */
  37314. get count(): number;
  37315. /**
  37316. * Creates a new counter
  37317. */
  37318. constructor();
  37319. /**
  37320. * Call this method to start monitoring a new frame.
  37321. * 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.
  37322. */
  37323. fetchNewFrame(): void;
  37324. /**
  37325. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37326. * @param newCount the count value to add to the monitored count
  37327. * @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.
  37328. */
  37329. addCount(newCount: number, fetchResult: boolean): void;
  37330. /**
  37331. * Start monitoring this performance counter
  37332. */
  37333. beginMonitoring(): void;
  37334. /**
  37335. * Compute the time lapsed since the previous beginMonitoring() call.
  37336. * @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
  37337. */
  37338. endMonitoring(newFrame?: boolean): void;
  37339. private _fetchResult;
  37340. private _startMonitoringTime;
  37341. private _min;
  37342. private _max;
  37343. private _average;
  37344. private _current;
  37345. private _totalValueCount;
  37346. private _totalAccumulated;
  37347. private _lastSecAverage;
  37348. private _lastSecAccumulated;
  37349. private _lastSecTime;
  37350. private _lastSecValueCount;
  37351. }
  37352. }
  37353. declare module BABYLON {
  37354. interface ThinEngine {
  37355. /** @hidden */
  37356. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37357. }
  37358. }
  37359. declare module BABYLON {
  37360. /**
  37361. * Defines the interface used by display changed events
  37362. */
  37363. export interface IDisplayChangedEventArgs {
  37364. /** Gets the vrDisplay object (if any) */
  37365. vrDisplay: Nullable<any>;
  37366. /** Gets a boolean indicating if webVR is supported */
  37367. vrSupported: boolean;
  37368. }
  37369. /**
  37370. * Defines the interface used by objects containing a viewport (like a camera)
  37371. */
  37372. interface IViewportOwnerLike {
  37373. /**
  37374. * Gets or sets the viewport
  37375. */
  37376. viewport: IViewportLike;
  37377. }
  37378. /**
  37379. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37380. */
  37381. export class Engine extends ThinEngine {
  37382. /** Defines that alpha blending is disabled */
  37383. static readonly ALPHA_DISABLE: number;
  37384. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37385. static readonly ALPHA_ADD: number;
  37386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37387. static readonly ALPHA_COMBINE: number;
  37388. /** Defines that alpha blending to DEST - SRC * DEST */
  37389. static readonly ALPHA_SUBTRACT: number;
  37390. /** Defines that alpha blending to SRC * DEST */
  37391. static readonly ALPHA_MULTIPLY: number;
  37392. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37393. static readonly ALPHA_MAXIMIZED: number;
  37394. /** Defines that alpha blending to SRC + DEST */
  37395. static readonly ALPHA_ONEONE: number;
  37396. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37397. static readonly ALPHA_PREMULTIPLIED: number;
  37398. /**
  37399. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37400. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37401. */
  37402. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37403. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37404. static readonly ALPHA_INTERPOLATE: number;
  37405. /**
  37406. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37407. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37408. */
  37409. static readonly ALPHA_SCREENMODE: number;
  37410. /** Defines that the ressource is not delayed*/
  37411. static readonly DELAYLOADSTATE_NONE: number;
  37412. /** Defines that the ressource was successfully delay loaded */
  37413. static readonly DELAYLOADSTATE_LOADED: number;
  37414. /** Defines that the ressource is currently delay loading */
  37415. static readonly DELAYLOADSTATE_LOADING: number;
  37416. /** Defines that the ressource is delayed and has not started loading */
  37417. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37419. static readonly NEVER: number;
  37420. /** 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 */
  37421. static readonly ALWAYS: number;
  37422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37423. static readonly LESS: number;
  37424. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37425. static readonly EQUAL: number;
  37426. /** 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 */
  37427. static readonly LEQUAL: number;
  37428. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37429. static readonly GREATER: number;
  37430. /** 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 */
  37431. static readonly GEQUAL: number;
  37432. /** 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 */
  37433. static readonly NOTEQUAL: number;
  37434. /** Passed to stencilOperation to specify that stencil value must be kept */
  37435. static readonly KEEP: number;
  37436. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37437. static readonly REPLACE: number;
  37438. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37439. static readonly INCR: number;
  37440. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37441. static readonly DECR: number;
  37442. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37443. static readonly INVERT: number;
  37444. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37445. static readonly INCR_WRAP: number;
  37446. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37447. static readonly DECR_WRAP: number;
  37448. /** Texture is not repeating outside of 0..1 UVs */
  37449. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37450. /** Texture is repeating outside of 0..1 UVs */
  37451. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37452. /** Texture is repeating and mirrored */
  37453. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37454. /** ALPHA */
  37455. static readonly TEXTUREFORMAT_ALPHA: number;
  37456. /** LUMINANCE */
  37457. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37458. /** LUMINANCE_ALPHA */
  37459. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37460. /** RGB */
  37461. static readonly TEXTUREFORMAT_RGB: number;
  37462. /** RGBA */
  37463. static readonly TEXTUREFORMAT_RGBA: number;
  37464. /** RED */
  37465. static readonly TEXTUREFORMAT_RED: number;
  37466. /** RED (2nd reference) */
  37467. static readonly TEXTUREFORMAT_R: number;
  37468. /** RG */
  37469. static readonly TEXTUREFORMAT_RG: number;
  37470. /** RED_INTEGER */
  37471. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37472. /** RED_INTEGER (2nd reference) */
  37473. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37474. /** RG_INTEGER */
  37475. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37476. /** RGB_INTEGER */
  37477. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37478. /** RGBA_INTEGER */
  37479. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37480. /** UNSIGNED_BYTE */
  37481. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37482. /** UNSIGNED_BYTE (2nd reference) */
  37483. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37484. /** FLOAT */
  37485. static readonly TEXTURETYPE_FLOAT: number;
  37486. /** HALF_FLOAT */
  37487. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37488. /** BYTE */
  37489. static readonly TEXTURETYPE_BYTE: number;
  37490. /** SHORT */
  37491. static readonly TEXTURETYPE_SHORT: number;
  37492. /** UNSIGNED_SHORT */
  37493. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37494. /** INT */
  37495. static readonly TEXTURETYPE_INT: number;
  37496. /** UNSIGNED_INT */
  37497. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37498. /** UNSIGNED_SHORT_4_4_4_4 */
  37499. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37500. /** UNSIGNED_SHORT_5_5_5_1 */
  37501. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37502. /** UNSIGNED_SHORT_5_6_5 */
  37503. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37504. /** UNSIGNED_INT_2_10_10_10_REV */
  37505. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37506. /** UNSIGNED_INT_24_8 */
  37507. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37508. /** UNSIGNED_INT_10F_11F_11F_REV */
  37509. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37510. /** UNSIGNED_INT_5_9_9_9_REV */
  37511. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37512. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37513. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37514. /** nearest is mag = nearest and min = nearest and mip = linear */
  37515. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37517. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37518. /** Trilinear is mag = linear and min = linear and mip = linear */
  37519. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37520. /** nearest is mag = nearest and min = nearest and mip = linear */
  37521. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37522. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37523. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37524. /** Trilinear is mag = linear and min = linear and mip = linear */
  37525. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37526. /** mag = nearest and min = nearest and mip = nearest */
  37527. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37528. /** mag = nearest and min = linear and mip = nearest */
  37529. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37530. /** mag = nearest and min = linear and mip = linear */
  37531. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37532. /** mag = nearest and min = linear and mip = none */
  37533. static readonly TEXTURE_NEAREST_LINEAR: number;
  37534. /** mag = nearest and min = nearest and mip = none */
  37535. static readonly TEXTURE_NEAREST_NEAREST: number;
  37536. /** mag = linear and min = nearest and mip = nearest */
  37537. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37538. /** mag = linear and min = nearest and mip = linear */
  37539. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37540. /** mag = linear and min = linear and mip = none */
  37541. static readonly TEXTURE_LINEAR_LINEAR: number;
  37542. /** mag = linear and min = nearest and mip = none */
  37543. static readonly TEXTURE_LINEAR_NEAREST: number;
  37544. /** Explicit coordinates mode */
  37545. static readonly TEXTURE_EXPLICIT_MODE: number;
  37546. /** Spherical coordinates mode */
  37547. static readonly TEXTURE_SPHERICAL_MODE: number;
  37548. /** Planar coordinates mode */
  37549. static readonly TEXTURE_PLANAR_MODE: number;
  37550. /** Cubic coordinates mode */
  37551. static readonly TEXTURE_CUBIC_MODE: number;
  37552. /** Projection coordinates mode */
  37553. static readonly TEXTURE_PROJECTION_MODE: number;
  37554. /** Skybox coordinates mode */
  37555. static readonly TEXTURE_SKYBOX_MODE: number;
  37556. /** Inverse Cubic coordinates mode */
  37557. static readonly TEXTURE_INVCUBIC_MODE: number;
  37558. /** Equirectangular coordinates mode */
  37559. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37560. /** Equirectangular Fixed coordinates mode */
  37561. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37562. /** Equirectangular Fixed Mirrored coordinates mode */
  37563. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37564. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37565. static readonly SCALEMODE_FLOOR: number;
  37566. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37567. static readonly SCALEMODE_NEAREST: number;
  37568. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37569. static readonly SCALEMODE_CEILING: number;
  37570. /**
  37571. * Returns the current npm package of the sdk
  37572. */
  37573. static get NpmPackage(): string;
  37574. /**
  37575. * Returns the current version of the framework
  37576. */
  37577. static get Version(): string;
  37578. /** Gets the list of created engines */
  37579. static get Instances(): Engine[];
  37580. /**
  37581. * Gets the latest created engine
  37582. */
  37583. static get LastCreatedEngine(): Nullable<Engine>;
  37584. /**
  37585. * Gets the latest created scene
  37586. */
  37587. static get LastCreatedScene(): Nullable<Scene>;
  37588. /**
  37589. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37590. * @param flag defines which part of the materials must be marked as dirty
  37591. * @param predicate defines a predicate used to filter which materials should be affected
  37592. */
  37593. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37594. /**
  37595. * Method called to create the default loading screen.
  37596. * This can be overriden in your own app.
  37597. * @param canvas The rendering canvas element
  37598. * @returns The loading screen
  37599. */
  37600. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37601. /**
  37602. * Method called to create the default rescale post process on each engine.
  37603. */
  37604. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37605. /**
  37606. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37607. **/
  37608. enableOfflineSupport: boolean;
  37609. /**
  37610. * 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)
  37611. **/
  37612. disableManifestCheck: boolean;
  37613. /**
  37614. * Gets the list of created scenes
  37615. */
  37616. scenes: Scene[];
  37617. /**
  37618. * Event raised when a new scene is created
  37619. */
  37620. onNewSceneAddedObservable: Observable<Scene>;
  37621. /**
  37622. * Gets the list of created postprocesses
  37623. */
  37624. postProcesses: PostProcess[];
  37625. /**
  37626. * Gets a boolean indicating if the pointer is currently locked
  37627. */
  37628. isPointerLock: boolean;
  37629. /**
  37630. * Observable event triggered each time the rendering canvas is resized
  37631. */
  37632. onResizeObservable: Observable<Engine>;
  37633. /**
  37634. * Observable event triggered each time the canvas loses focus
  37635. */
  37636. onCanvasBlurObservable: Observable<Engine>;
  37637. /**
  37638. * Observable event triggered each time the canvas gains focus
  37639. */
  37640. onCanvasFocusObservable: Observable<Engine>;
  37641. /**
  37642. * Observable event triggered each time the canvas receives pointerout event
  37643. */
  37644. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37645. /**
  37646. * Observable raised when the engine begins a new frame
  37647. */
  37648. onBeginFrameObservable: Observable<Engine>;
  37649. /**
  37650. * If set, will be used to request the next animation frame for the render loop
  37651. */
  37652. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37653. /**
  37654. * Observable raised when the engine ends the current frame
  37655. */
  37656. onEndFrameObservable: Observable<Engine>;
  37657. /**
  37658. * Observable raised when the engine is about to compile a shader
  37659. */
  37660. onBeforeShaderCompilationObservable: Observable<Engine>;
  37661. /**
  37662. * Observable raised when the engine has jsut compiled a shader
  37663. */
  37664. onAfterShaderCompilationObservable: Observable<Engine>;
  37665. /**
  37666. * Gets the audio engine
  37667. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37668. * @ignorenaming
  37669. */
  37670. static audioEngine: IAudioEngine;
  37671. /**
  37672. * Default AudioEngine factory responsible of creating the Audio Engine.
  37673. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37674. */
  37675. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37676. /**
  37677. * Default offline support factory responsible of creating a tool used to store data locally.
  37678. * By default, this will create a Database object if the workload has been embedded.
  37679. */
  37680. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37681. private _loadingScreen;
  37682. private _pointerLockRequested;
  37683. private _rescalePostProcess;
  37684. private _deterministicLockstep;
  37685. private _lockstepMaxSteps;
  37686. private _timeStep;
  37687. protected get _supportsHardwareTextureRescaling(): boolean;
  37688. private _fps;
  37689. private _deltaTime;
  37690. /** @hidden */
  37691. _drawCalls: PerfCounter;
  37692. /** 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 */
  37693. canvasTabIndex: number;
  37694. /**
  37695. * Turn this value on if you want to pause FPS computation when in background
  37696. */
  37697. disablePerformanceMonitorInBackground: boolean;
  37698. private _performanceMonitor;
  37699. /**
  37700. * Gets the performance monitor attached to this engine
  37701. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37702. */
  37703. get performanceMonitor(): PerformanceMonitor;
  37704. private _onFocus;
  37705. private _onBlur;
  37706. private _onCanvasPointerOut;
  37707. private _onCanvasBlur;
  37708. private _onCanvasFocus;
  37709. private _onFullscreenChange;
  37710. private _onPointerLockChange;
  37711. /**
  37712. * Gets the HTML element used to attach event listeners
  37713. * @returns a HTML element
  37714. */
  37715. getInputElement(): Nullable<HTMLElement>;
  37716. /**
  37717. * Creates a new engine
  37718. * @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
  37719. * @param antialias defines enable antialiasing (default: false)
  37720. * @param options defines further options to be sent to the getContext() function
  37721. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37722. */
  37723. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37724. /**
  37725. * Gets current aspect ratio
  37726. * @param viewportOwner defines the camera to use to get the aspect ratio
  37727. * @param useScreen defines if screen size must be used (or the current render target if any)
  37728. * @returns a number defining the aspect ratio
  37729. */
  37730. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37731. /**
  37732. * Gets current screen aspect ratio
  37733. * @returns a number defining the aspect ratio
  37734. */
  37735. getScreenAspectRatio(): number;
  37736. /**
  37737. * Gets the client rect of the HTML canvas attached with the current webGL context
  37738. * @returns a client rectanglee
  37739. */
  37740. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37741. /**
  37742. * Gets the client rect of the HTML element used for events
  37743. * @returns a client rectanglee
  37744. */
  37745. getInputElementClientRect(): Nullable<ClientRect>;
  37746. /**
  37747. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37748. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37749. * @returns true if engine is in deterministic lock step mode
  37750. */
  37751. isDeterministicLockStep(): boolean;
  37752. /**
  37753. * Gets the max steps when engine is running in deterministic lock step
  37754. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37755. * @returns the max steps
  37756. */
  37757. getLockstepMaxSteps(): number;
  37758. /**
  37759. * Returns the time in ms between steps when using deterministic lock step.
  37760. * @returns time step in (ms)
  37761. */
  37762. getTimeStep(): number;
  37763. /**
  37764. * Force the mipmap generation for the given render target texture
  37765. * @param texture defines the render target texture to use
  37766. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37767. */
  37768. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37769. /** States */
  37770. /**
  37771. * Set various states to the webGL context
  37772. * @param culling defines backface culling state
  37773. * @param zOffset defines the value to apply to zOffset (0 by default)
  37774. * @param force defines if states must be applied even if cache is up to date
  37775. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37776. */
  37777. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37778. /**
  37779. * Set the z offset to apply to current rendering
  37780. * @param value defines the offset to apply
  37781. */
  37782. setZOffset(value: number): void;
  37783. /**
  37784. * Gets the current value of the zOffset
  37785. * @returns the current zOffset state
  37786. */
  37787. getZOffset(): number;
  37788. /**
  37789. * Enable or disable depth buffering
  37790. * @param enable defines the state to set
  37791. */
  37792. setDepthBuffer(enable: boolean): void;
  37793. /**
  37794. * Gets a boolean indicating if depth writing is enabled
  37795. * @returns the current depth writing state
  37796. */
  37797. getDepthWrite(): boolean;
  37798. /**
  37799. * Enable or disable depth writing
  37800. * @param enable defines the state to set
  37801. */
  37802. setDepthWrite(enable: boolean): void;
  37803. /**
  37804. * Gets a boolean indicating if stencil buffer is enabled
  37805. * @returns the current stencil buffer state
  37806. */
  37807. getStencilBuffer(): boolean;
  37808. /**
  37809. * Enable or disable the stencil buffer
  37810. * @param enable defines if the stencil buffer must be enabled or disabled
  37811. */
  37812. setStencilBuffer(enable: boolean): void;
  37813. /**
  37814. * Gets the current stencil mask
  37815. * @returns a number defining the new stencil mask to use
  37816. */
  37817. getStencilMask(): number;
  37818. /**
  37819. * Sets the current stencil mask
  37820. * @param mask defines the new stencil mask to use
  37821. */
  37822. setStencilMask(mask: number): void;
  37823. /**
  37824. * Gets the current stencil function
  37825. * @returns a number defining the stencil function to use
  37826. */
  37827. getStencilFunction(): number;
  37828. /**
  37829. * Gets the current stencil reference value
  37830. * @returns a number defining the stencil reference value to use
  37831. */
  37832. getStencilFunctionReference(): number;
  37833. /**
  37834. * Gets the current stencil mask
  37835. * @returns a number defining the stencil mask to use
  37836. */
  37837. getStencilFunctionMask(): number;
  37838. /**
  37839. * Sets the current stencil function
  37840. * @param stencilFunc defines the new stencil function to use
  37841. */
  37842. setStencilFunction(stencilFunc: number): void;
  37843. /**
  37844. * Sets the current stencil reference
  37845. * @param reference defines the new stencil reference to use
  37846. */
  37847. setStencilFunctionReference(reference: number): void;
  37848. /**
  37849. * Sets the current stencil mask
  37850. * @param mask defines the new stencil mask to use
  37851. */
  37852. setStencilFunctionMask(mask: number): void;
  37853. /**
  37854. * Gets the current stencil operation when stencil fails
  37855. * @returns a number defining stencil operation to use when stencil fails
  37856. */
  37857. getStencilOperationFail(): number;
  37858. /**
  37859. * Gets the current stencil operation when depth fails
  37860. * @returns a number defining stencil operation to use when depth fails
  37861. */
  37862. getStencilOperationDepthFail(): number;
  37863. /**
  37864. * Gets the current stencil operation when stencil passes
  37865. * @returns a number defining stencil operation to use when stencil passes
  37866. */
  37867. getStencilOperationPass(): number;
  37868. /**
  37869. * Sets the stencil operation to use when stencil fails
  37870. * @param operation defines the stencil operation to use when stencil fails
  37871. */
  37872. setStencilOperationFail(operation: number): void;
  37873. /**
  37874. * Sets the stencil operation to use when depth fails
  37875. * @param operation defines the stencil operation to use when depth fails
  37876. */
  37877. setStencilOperationDepthFail(operation: number): void;
  37878. /**
  37879. * Sets the stencil operation to use when stencil passes
  37880. * @param operation defines the stencil operation to use when stencil passes
  37881. */
  37882. setStencilOperationPass(operation: number): void;
  37883. /**
  37884. * Sets a boolean indicating if the dithering state is enabled or disabled
  37885. * @param value defines the dithering state
  37886. */
  37887. setDitheringState(value: boolean): void;
  37888. /**
  37889. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37890. * @param value defines the rasterizer state
  37891. */
  37892. setRasterizerState(value: boolean): void;
  37893. /**
  37894. * Gets the current depth function
  37895. * @returns a number defining the depth function
  37896. */
  37897. getDepthFunction(): Nullable<number>;
  37898. /**
  37899. * Sets the current depth function
  37900. * @param depthFunc defines the function to use
  37901. */
  37902. setDepthFunction(depthFunc: number): void;
  37903. /**
  37904. * Sets the current depth function to GREATER
  37905. */
  37906. setDepthFunctionToGreater(): void;
  37907. /**
  37908. * Sets the current depth function to GEQUAL
  37909. */
  37910. setDepthFunctionToGreaterOrEqual(): void;
  37911. /**
  37912. * Sets the current depth function to LESS
  37913. */
  37914. setDepthFunctionToLess(): void;
  37915. /**
  37916. * Sets the current depth function to LEQUAL
  37917. */
  37918. setDepthFunctionToLessOrEqual(): void;
  37919. private _cachedStencilBuffer;
  37920. private _cachedStencilFunction;
  37921. private _cachedStencilMask;
  37922. private _cachedStencilOperationPass;
  37923. private _cachedStencilOperationFail;
  37924. private _cachedStencilOperationDepthFail;
  37925. private _cachedStencilReference;
  37926. /**
  37927. * Caches the the state of the stencil buffer
  37928. */
  37929. cacheStencilState(): void;
  37930. /**
  37931. * Restores the state of the stencil buffer
  37932. */
  37933. restoreStencilState(): void;
  37934. /**
  37935. * Directly set the WebGL Viewport
  37936. * @param x defines the x coordinate of the viewport (in screen space)
  37937. * @param y defines the y coordinate of the viewport (in screen space)
  37938. * @param width defines the width of the viewport (in screen space)
  37939. * @param height defines the height of the viewport (in screen space)
  37940. * @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
  37941. */
  37942. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37943. /**
  37944. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37945. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37946. * @param y defines the y-coordinate of the corner of the clear rectangle
  37947. * @param width defines the width of the clear rectangle
  37948. * @param height defines the height of the clear rectangle
  37949. * @param clearColor defines the clear color
  37950. */
  37951. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37952. /**
  37953. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37954. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37955. * @param y defines the y-coordinate of the corner of the clear rectangle
  37956. * @param width defines the width of the clear rectangle
  37957. * @param height defines the height of the clear rectangle
  37958. */
  37959. enableScissor(x: number, y: number, width: number, height: number): void;
  37960. /**
  37961. * Disable previously set scissor test rectangle
  37962. */
  37963. disableScissor(): void;
  37964. protected _reportDrawCall(): void;
  37965. /**
  37966. * Initializes a webVR display and starts listening to display change events
  37967. * The onVRDisplayChangedObservable will be notified upon these changes
  37968. * @returns The onVRDisplayChangedObservable
  37969. */
  37970. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37971. /** @hidden */
  37972. _prepareVRComponent(): void;
  37973. /** @hidden */
  37974. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37975. /** @hidden */
  37976. _submitVRFrame(): void;
  37977. /**
  37978. * Call this function to leave webVR mode
  37979. * Will do nothing if webVR is not supported or if there is no webVR device
  37980. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37981. */
  37982. disableVR(): void;
  37983. /**
  37984. * Gets a boolean indicating that the system is in VR mode and is presenting
  37985. * @returns true if VR mode is engaged
  37986. */
  37987. isVRPresenting(): boolean;
  37988. /** @hidden */
  37989. _requestVRFrame(): void;
  37990. /** @hidden */
  37991. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37992. /**
  37993. * Gets the source code of the vertex shader associated with a specific webGL program
  37994. * @param program defines the program to use
  37995. * @returns a string containing the source code of the vertex shader associated with the program
  37996. */
  37997. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37998. /**
  37999. * Gets the source code of the fragment shader associated with a specific webGL program
  38000. * @param program defines the program to use
  38001. * @returns a string containing the source code of the fragment shader associated with the program
  38002. */
  38003. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38004. /**
  38005. * Sets a depth stencil texture from a render target to the according uniform.
  38006. * @param channel The texture channel
  38007. * @param uniform The uniform to set
  38008. * @param texture The render target texture containing the depth stencil texture to apply
  38009. */
  38010. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38011. /**
  38012. * Sets a texture to the webGL context from a postprocess
  38013. * @param channel defines the channel to use
  38014. * @param postProcess defines the source postprocess
  38015. */
  38016. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38017. /**
  38018. * Binds the output of the passed in post process to the texture channel specified
  38019. * @param channel The channel the texture should be bound to
  38020. * @param postProcess The post process which's output should be bound
  38021. */
  38022. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38023. protected _rebuildBuffers(): void;
  38024. /** @hidden */
  38025. _renderFrame(): void;
  38026. _renderLoop(): void;
  38027. /** @hidden */
  38028. _renderViews(): boolean;
  38029. /**
  38030. * Toggle full screen mode
  38031. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38032. */
  38033. switchFullscreen(requestPointerLock: boolean): void;
  38034. /**
  38035. * Enters full screen mode
  38036. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38037. */
  38038. enterFullscreen(requestPointerLock: boolean): void;
  38039. /**
  38040. * Exits full screen mode
  38041. */
  38042. exitFullscreen(): void;
  38043. /**
  38044. * Enters Pointerlock mode
  38045. */
  38046. enterPointerlock(): void;
  38047. /**
  38048. * Exits Pointerlock mode
  38049. */
  38050. exitPointerlock(): void;
  38051. /**
  38052. * Begin a new frame
  38053. */
  38054. beginFrame(): void;
  38055. /**
  38056. * Enf the current frame
  38057. */
  38058. endFrame(): void;
  38059. resize(): void;
  38060. /**
  38061. * Force a specific size of the canvas
  38062. * @param width defines the new canvas' width
  38063. * @param height defines the new canvas' height
  38064. * @returns true if the size was changed
  38065. */
  38066. setSize(width: number, height: number): boolean;
  38067. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38068. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38069. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38070. _releaseTexture(texture: InternalTexture): void;
  38071. /**
  38072. * @hidden
  38073. * Rescales a texture
  38074. * @param source input texutre
  38075. * @param destination destination texture
  38076. * @param scene scene to use to render the resize
  38077. * @param internalFormat format to use when resizing
  38078. * @param onComplete callback to be called when resize has completed
  38079. */
  38080. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38081. /**
  38082. * Gets the current framerate
  38083. * @returns a number representing the framerate
  38084. */
  38085. getFps(): number;
  38086. /**
  38087. * Gets the time spent between current and previous frame
  38088. * @returns a number representing the delta time in ms
  38089. */
  38090. getDeltaTime(): number;
  38091. private _measureFps;
  38092. /** @hidden */
  38093. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38094. /**
  38095. * Updates the sample count of a render target texture
  38096. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38097. * @param texture defines the texture to update
  38098. * @param samples defines the sample count to set
  38099. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38100. */
  38101. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38102. /**
  38103. * Updates a depth texture Comparison Mode and Function.
  38104. * If the comparison Function is equal to 0, the mode will be set to none.
  38105. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38106. * @param texture The texture to set the comparison function for
  38107. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38108. */
  38109. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38110. /**
  38111. * Creates a webGL buffer to use with instanciation
  38112. * @param capacity defines the size of the buffer
  38113. * @returns the webGL buffer
  38114. */
  38115. createInstancesBuffer(capacity: number): DataBuffer;
  38116. /**
  38117. * Delete a webGL buffer used with instanciation
  38118. * @param buffer defines the webGL buffer to delete
  38119. */
  38120. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38121. private _clientWaitAsync;
  38122. /** @hidden */
  38123. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38124. dispose(): void;
  38125. private _disableTouchAction;
  38126. /**
  38127. * Display the loading screen
  38128. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38129. */
  38130. displayLoadingUI(): void;
  38131. /**
  38132. * Hide the loading screen
  38133. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38134. */
  38135. hideLoadingUI(): void;
  38136. /**
  38137. * Gets the current loading screen object
  38138. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38139. */
  38140. get loadingScreen(): ILoadingScreen;
  38141. /**
  38142. * Sets the current loading screen object
  38143. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38144. */
  38145. set loadingScreen(loadingScreen: ILoadingScreen);
  38146. /**
  38147. * Sets the current loading screen text
  38148. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38149. */
  38150. set loadingUIText(text: string);
  38151. /**
  38152. * Sets the current loading screen background color
  38153. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38154. */
  38155. set loadingUIBackgroundColor(color: string);
  38156. /** Pointerlock and fullscreen */
  38157. /**
  38158. * Ask the browser to promote the current element to pointerlock mode
  38159. * @param element defines the DOM element to promote
  38160. */
  38161. static _RequestPointerlock(element: HTMLElement): void;
  38162. /**
  38163. * Asks the browser to exit pointerlock mode
  38164. */
  38165. static _ExitPointerlock(): void;
  38166. /**
  38167. * Ask the browser to promote the current element to fullscreen rendering mode
  38168. * @param element defines the DOM element to promote
  38169. */
  38170. static _RequestFullscreen(element: HTMLElement): void;
  38171. /**
  38172. * Asks the browser to exit fullscreen mode
  38173. */
  38174. static _ExitFullscreen(): void;
  38175. }
  38176. }
  38177. declare module BABYLON {
  38178. /**
  38179. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38180. * during the life time of the application.
  38181. */
  38182. export class EngineStore {
  38183. /** Gets the list of created engines */
  38184. static Instances: Engine[];
  38185. /** @hidden */
  38186. static _LastCreatedScene: Nullable<Scene>;
  38187. /**
  38188. * Gets the latest created engine
  38189. */
  38190. static get LastCreatedEngine(): Nullable<Engine>;
  38191. /**
  38192. * Gets the latest created scene
  38193. */
  38194. static get LastCreatedScene(): Nullable<Scene>;
  38195. /**
  38196. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38197. * @ignorenaming
  38198. */
  38199. static UseFallbackTexture: boolean;
  38200. /**
  38201. * Texture content used if a texture cannot loaded
  38202. * @ignorenaming
  38203. */
  38204. static FallbackTexture: string;
  38205. }
  38206. }
  38207. declare module BABYLON {
  38208. /**
  38209. * Helper class that provides a small promise polyfill
  38210. */
  38211. export class PromisePolyfill {
  38212. /**
  38213. * Static function used to check if the polyfill is required
  38214. * If this is the case then the function will inject the polyfill to window.Promise
  38215. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38216. */
  38217. static Apply(force?: boolean): void;
  38218. }
  38219. }
  38220. declare module BABYLON {
  38221. /**
  38222. * Interface for screenshot methods with describe argument called `size` as object with options
  38223. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38224. */
  38225. export interface IScreenshotSize {
  38226. /**
  38227. * number in pixels for canvas height
  38228. */
  38229. height?: number;
  38230. /**
  38231. * multiplier allowing render at a higher or lower resolution
  38232. * If value is defined then height and width will be ignored and taken from camera
  38233. */
  38234. precision?: number;
  38235. /**
  38236. * number in pixels for canvas width
  38237. */
  38238. width?: number;
  38239. }
  38240. }
  38241. declare module BABYLON {
  38242. interface IColor4Like {
  38243. r: float;
  38244. g: float;
  38245. b: float;
  38246. a: float;
  38247. }
  38248. /**
  38249. * Class containing a set of static utilities functions
  38250. */
  38251. export class Tools {
  38252. /**
  38253. * Gets or sets the base URL to use to load assets
  38254. */
  38255. static get BaseUrl(): string;
  38256. static set BaseUrl(value: string);
  38257. /**
  38258. * Enable/Disable Custom HTTP Request Headers globally.
  38259. * default = false
  38260. * @see CustomRequestHeaders
  38261. */
  38262. static UseCustomRequestHeaders: boolean;
  38263. /**
  38264. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38265. * i.e. when loading files, where the server/service expects an Authorization header
  38266. */
  38267. static CustomRequestHeaders: {
  38268. [key: string]: string;
  38269. };
  38270. /**
  38271. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38272. */
  38273. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38274. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38275. /**
  38276. * Default behaviour for cors in the application.
  38277. * It can be a string if the expected behavior is identical in the entire app.
  38278. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38279. */
  38280. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38281. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38282. /**
  38283. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38284. * @ignorenaming
  38285. */
  38286. static get UseFallbackTexture(): boolean;
  38287. static set UseFallbackTexture(value: boolean);
  38288. /**
  38289. * Use this object to register external classes like custom textures or material
  38290. * to allow the laoders to instantiate them
  38291. */
  38292. static get RegisteredExternalClasses(): {
  38293. [key: string]: Object;
  38294. };
  38295. static set RegisteredExternalClasses(classes: {
  38296. [key: string]: Object;
  38297. });
  38298. /**
  38299. * Texture content used if a texture cannot loaded
  38300. * @ignorenaming
  38301. */
  38302. static get fallbackTexture(): string;
  38303. static set fallbackTexture(value: string);
  38304. /**
  38305. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38306. * @param u defines the coordinate on X axis
  38307. * @param v defines the coordinate on Y axis
  38308. * @param width defines the width of the source data
  38309. * @param height defines the height of the source data
  38310. * @param pixels defines the source byte array
  38311. * @param color defines the output color
  38312. */
  38313. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38314. /**
  38315. * Interpolates between a and b via alpha
  38316. * @param a The lower value (returned when alpha = 0)
  38317. * @param b The upper value (returned when alpha = 1)
  38318. * @param alpha The interpolation-factor
  38319. * @return The mixed value
  38320. */
  38321. static Mix(a: number, b: number, alpha: number): number;
  38322. /**
  38323. * Tries to instantiate a new object from a given class name
  38324. * @param className defines the class name to instantiate
  38325. * @returns the new object or null if the system was not able to do the instantiation
  38326. */
  38327. static Instantiate(className: string): any;
  38328. /**
  38329. * Provides a slice function that will work even on IE
  38330. * @param data defines the array to slice
  38331. * @param start defines the start of the data (optional)
  38332. * @param end defines the end of the data (optional)
  38333. * @returns the new sliced array
  38334. */
  38335. static Slice<T>(data: T, start?: number, end?: number): T;
  38336. /**
  38337. * Polyfill for setImmediate
  38338. * @param action defines the action to execute after the current execution block
  38339. */
  38340. static SetImmediate(action: () => void): void;
  38341. /**
  38342. * Function indicating if a number is an exponent of 2
  38343. * @param value defines the value to test
  38344. * @returns true if the value is an exponent of 2
  38345. */
  38346. static IsExponentOfTwo(value: number): boolean;
  38347. private static _tmpFloatArray;
  38348. /**
  38349. * Returns the nearest 32-bit single precision float representation of a Number
  38350. * @param value A Number. If the parameter is of a different type, it will get converted
  38351. * to a number or to NaN if it cannot be converted
  38352. * @returns number
  38353. */
  38354. static FloatRound(value: number): number;
  38355. /**
  38356. * Extracts the filename from a path
  38357. * @param path defines the path to use
  38358. * @returns the filename
  38359. */
  38360. static GetFilename(path: string): string;
  38361. /**
  38362. * Extracts the "folder" part of a path (everything before the filename).
  38363. * @param uri The URI to extract the info from
  38364. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38365. * @returns The "folder" part of the path
  38366. */
  38367. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38368. /**
  38369. * Extracts text content from a DOM element hierarchy
  38370. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38371. */
  38372. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38373. /**
  38374. * Convert an angle in radians to degrees
  38375. * @param angle defines the angle to convert
  38376. * @returns the angle in degrees
  38377. */
  38378. static ToDegrees(angle: number): number;
  38379. /**
  38380. * Convert an angle in degrees to radians
  38381. * @param angle defines the angle to convert
  38382. * @returns the angle in radians
  38383. */
  38384. static ToRadians(angle: number): number;
  38385. /**
  38386. * Returns an array if obj is not an array
  38387. * @param obj defines the object to evaluate as an array
  38388. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38389. * @returns either obj directly if obj is an array or a new array containing obj
  38390. */
  38391. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38392. /**
  38393. * Gets the pointer prefix to use
  38394. * @param engine defines the engine we are finding the prefix for
  38395. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38396. */
  38397. static GetPointerPrefix(engine: Engine): string;
  38398. /**
  38399. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38400. * @param url define the url we are trying
  38401. * @param element define the dom element where to configure the cors policy
  38402. */
  38403. static SetCorsBehavior(url: string | string[], element: {
  38404. crossOrigin: string | null;
  38405. }): void;
  38406. /**
  38407. * Removes unwanted characters from an url
  38408. * @param url defines the url to clean
  38409. * @returns the cleaned url
  38410. */
  38411. static CleanUrl(url: string): string;
  38412. /**
  38413. * Gets or sets a function used to pre-process url before using them to load assets
  38414. */
  38415. static get PreprocessUrl(): (url: string) => string;
  38416. static set PreprocessUrl(processor: (url: string) => string);
  38417. /**
  38418. * Loads an image as an HTMLImageElement.
  38419. * @param input url string, ArrayBuffer, or Blob to load
  38420. * @param onLoad callback called when the image successfully loads
  38421. * @param onError callback called when the image fails to load
  38422. * @param offlineProvider offline provider for caching
  38423. * @param mimeType optional mime type
  38424. * @returns the HTMLImageElement of the loaded image
  38425. */
  38426. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38427. /**
  38428. * Loads a file from a url
  38429. * @param url url string, ArrayBuffer, or Blob to load
  38430. * @param onSuccess callback called when the file successfully loads
  38431. * @param onProgress callback called while file is loading (if the server supports this mode)
  38432. * @param offlineProvider defines the offline provider for caching
  38433. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38434. * @param onError callback called when the file fails to load
  38435. * @returns a file request object
  38436. */
  38437. 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;
  38438. /**
  38439. * Loads a file from a url
  38440. * @param url the file url to load
  38441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38442. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38443. */
  38444. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38445. /**
  38446. * Load a script (identified by an url). When the url returns, the
  38447. * content of this file is added into a new script element, attached to the DOM (body element)
  38448. * @param scriptUrl defines the url of the script to laod
  38449. * @param onSuccess defines the callback called when the script is loaded
  38450. * @param onError defines the callback to call if an error occurs
  38451. * @param scriptId defines the id of the script element
  38452. */
  38453. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38454. /**
  38455. * Load an asynchronous script (identified by an url). When the url returns, the
  38456. * content of this file is added into a new script element, attached to the DOM (body element)
  38457. * @param scriptUrl defines the url of the script to laod
  38458. * @param scriptId defines the id of the script element
  38459. * @returns a promise request object
  38460. */
  38461. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38462. /**
  38463. * Loads a file from a blob
  38464. * @param fileToLoad defines the blob to use
  38465. * @param callback defines the callback to call when data is loaded
  38466. * @param progressCallback defines the callback to call during loading process
  38467. * @returns a file request object
  38468. */
  38469. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38470. /**
  38471. * Reads a file from a File object
  38472. * @param file defines the file to load
  38473. * @param onSuccess defines the callback to call when data is loaded
  38474. * @param onProgress defines the callback to call during loading process
  38475. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38476. * @param onError defines the callback to call when an error occurs
  38477. * @returns a file request object
  38478. */
  38479. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38480. /**
  38481. * Creates a data url from a given string content
  38482. * @param content defines the content to convert
  38483. * @returns the new data url link
  38484. */
  38485. static FileAsURL(content: string): string;
  38486. /**
  38487. * Format the given number to a specific decimal format
  38488. * @param value defines the number to format
  38489. * @param decimals defines the number of decimals to use
  38490. * @returns the formatted string
  38491. */
  38492. static Format(value: number, decimals?: number): string;
  38493. /**
  38494. * Tries to copy an object by duplicating every property
  38495. * @param source defines the source object
  38496. * @param destination defines the target object
  38497. * @param doNotCopyList defines a list of properties to avoid
  38498. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38499. */
  38500. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38501. /**
  38502. * Gets a boolean indicating if the given object has no own property
  38503. * @param obj defines the object to test
  38504. * @returns true if object has no own property
  38505. */
  38506. static IsEmpty(obj: any): boolean;
  38507. /**
  38508. * Function used to register events at window level
  38509. * @param windowElement defines the Window object to use
  38510. * @param events defines the events to register
  38511. */
  38512. static RegisterTopRootEvents(windowElement: Window, events: {
  38513. name: string;
  38514. handler: Nullable<(e: FocusEvent) => any>;
  38515. }[]): void;
  38516. /**
  38517. * Function used to unregister events from window level
  38518. * @param windowElement defines the Window object to use
  38519. * @param events defines the events to unregister
  38520. */
  38521. static UnregisterTopRootEvents(windowElement: Window, events: {
  38522. name: string;
  38523. handler: Nullable<(e: FocusEvent) => any>;
  38524. }[]): void;
  38525. /**
  38526. * @ignore
  38527. */
  38528. static _ScreenshotCanvas: HTMLCanvasElement;
  38529. /**
  38530. * Dumps the current bound framebuffer
  38531. * @param width defines the rendering width
  38532. * @param height defines the rendering height
  38533. * @param engine defines the hosting engine
  38534. * @param successCallback defines the callback triggered once the data are available
  38535. * @param mimeType defines the mime type of the result
  38536. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38537. */
  38538. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38539. /**
  38540. * Converts the canvas data to blob.
  38541. * This acts as a polyfill for browsers not supporting the to blob function.
  38542. * @param canvas Defines the canvas to extract the data from
  38543. * @param successCallback Defines the callback triggered once the data are available
  38544. * @param mimeType Defines the mime type of the result
  38545. */
  38546. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38547. /**
  38548. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38549. * @param successCallback defines the callback triggered once the data are available
  38550. * @param mimeType defines the mime type of the result
  38551. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38552. */
  38553. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38554. /**
  38555. * Downloads a blob in the browser
  38556. * @param blob defines the blob to download
  38557. * @param fileName defines the name of the downloaded file
  38558. */
  38559. static Download(blob: Blob, fileName: string): void;
  38560. /**
  38561. * Captures a screenshot of the current rendering
  38562. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38563. * @param engine defines the rendering engine
  38564. * @param camera defines the source camera
  38565. * @param size This parameter can be set to a single number or to an object with the
  38566. * following (optional) properties: precision, width, height. If a single number is passed,
  38567. * it will be used for both width and height. If an object is passed, the screenshot size
  38568. * will be derived from the parameters. The precision property is a multiplier allowing
  38569. * rendering at a higher or lower resolution
  38570. * @param successCallback defines the callback receives a single parameter which contains the
  38571. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38572. * src parameter of an <img> to display it
  38573. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38574. * Check your browser for supported MIME types
  38575. */
  38576. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38577. /**
  38578. * Captures a screenshot of the current rendering
  38579. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38580. * @param engine defines the rendering engine
  38581. * @param camera defines the source camera
  38582. * @param size This parameter can be set to a single number or to an object with the
  38583. * following (optional) properties: precision, width, height. If a single number is passed,
  38584. * it will be used for both width and height. If an object is passed, the screenshot size
  38585. * will be derived from the parameters. The precision property is a multiplier allowing
  38586. * rendering at a higher or lower resolution
  38587. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38588. * Check your browser for supported MIME types
  38589. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38590. * to the src parameter of an <img> to display it
  38591. */
  38592. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38593. /**
  38594. * Generates an image screenshot from the specified camera.
  38595. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38596. * @param engine The engine to use for rendering
  38597. * @param camera The camera to use for rendering
  38598. * @param size This parameter can be set to a single number or to an object with the
  38599. * following (optional) properties: precision, width, height. If a single number is passed,
  38600. * it will be used for both width and height. If an object is passed, the screenshot size
  38601. * will be derived from the parameters. The precision property is a multiplier allowing
  38602. * rendering at a higher or lower resolution
  38603. * @param successCallback The callback receives a single parameter which contains the
  38604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38605. * src parameter of an <img> to display it
  38606. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38607. * Check your browser for supported MIME types
  38608. * @param samples Texture samples (default: 1)
  38609. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38610. * @param fileName A name for for the downloaded file.
  38611. */
  38612. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38613. /**
  38614. * Generates an image screenshot from the specified camera.
  38615. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38616. * @param engine The engine to use for rendering
  38617. * @param camera The camera to use for rendering
  38618. * @param size This parameter can be set to a single number or to an object with the
  38619. * following (optional) properties: precision, width, height. If a single number is passed,
  38620. * it will be used for both width and height. If an object is passed, the screenshot size
  38621. * will be derived from the parameters. The precision property is a multiplier allowing
  38622. * rendering at a higher or lower resolution
  38623. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38624. * Check your browser for supported MIME types
  38625. * @param samples Texture samples (default: 1)
  38626. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38627. * @param fileName A name for for the downloaded file.
  38628. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38629. * to the src parameter of an <img> to display it
  38630. */
  38631. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38632. /**
  38633. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38634. * Be aware Math.random() could cause collisions, but:
  38635. * "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"
  38636. * @returns a pseudo random id
  38637. */
  38638. static RandomId(): string;
  38639. /**
  38640. * Test if the given uri is a base64 string
  38641. * @param uri The uri to test
  38642. * @return True if the uri is a base64 string or false otherwise
  38643. */
  38644. static IsBase64(uri: string): boolean;
  38645. /**
  38646. * Decode the given base64 uri.
  38647. * @param uri The uri to decode
  38648. * @return The decoded base64 data.
  38649. */
  38650. static DecodeBase64(uri: string): ArrayBuffer;
  38651. /**
  38652. * Gets the absolute url.
  38653. * @param url the input url
  38654. * @return the absolute url
  38655. */
  38656. static GetAbsoluteUrl(url: string): string;
  38657. /**
  38658. * No log
  38659. */
  38660. static readonly NoneLogLevel: number;
  38661. /**
  38662. * Only message logs
  38663. */
  38664. static readonly MessageLogLevel: number;
  38665. /**
  38666. * Only warning logs
  38667. */
  38668. static readonly WarningLogLevel: number;
  38669. /**
  38670. * Only error logs
  38671. */
  38672. static readonly ErrorLogLevel: number;
  38673. /**
  38674. * All logs
  38675. */
  38676. static readonly AllLogLevel: number;
  38677. /**
  38678. * Gets a value indicating the number of loading errors
  38679. * @ignorenaming
  38680. */
  38681. static get errorsCount(): number;
  38682. /**
  38683. * Callback called when a new log is added
  38684. */
  38685. static OnNewCacheEntry: (entry: string) => void;
  38686. /**
  38687. * Log a message to the console
  38688. * @param message defines the message to log
  38689. */
  38690. static Log(message: string): void;
  38691. /**
  38692. * Write a warning message to the console
  38693. * @param message defines the message to log
  38694. */
  38695. static Warn(message: string): void;
  38696. /**
  38697. * Write an error message to the console
  38698. * @param message defines the message to log
  38699. */
  38700. static Error(message: string): void;
  38701. /**
  38702. * Gets current log cache (list of logs)
  38703. */
  38704. static get LogCache(): string;
  38705. /**
  38706. * Clears the log cache
  38707. */
  38708. static ClearLogCache(): void;
  38709. /**
  38710. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38711. */
  38712. static set LogLevels(level: number);
  38713. /**
  38714. * Checks if the window object exists
  38715. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38716. */
  38717. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38718. /**
  38719. * No performance log
  38720. */
  38721. static readonly PerformanceNoneLogLevel: number;
  38722. /**
  38723. * Use user marks to log performance
  38724. */
  38725. static readonly PerformanceUserMarkLogLevel: number;
  38726. /**
  38727. * Log performance to the console
  38728. */
  38729. static readonly PerformanceConsoleLogLevel: number;
  38730. private static _performance;
  38731. /**
  38732. * Sets the current performance log level
  38733. */
  38734. static set PerformanceLogLevel(level: number);
  38735. private static _StartPerformanceCounterDisabled;
  38736. private static _EndPerformanceCounterDisabled;
  38737. private static _StartUserMark;
  38738. private static _EndUserMark;
  38739. private static _StartPerformanceConsole;
  38740. private static _EndPerformanceConsole;
  38741. /**
  38742. * Starts a performance counter
  38743. */
  38744. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38745. /**
  38746. * Ends a specific performance coutner
  38747. */
  38748. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38749. /**
  38750. * Gets either window.performance.now() if supported or Date.now() else
  38751. */
  38752. static get Now(): number;
  38753. /**
  38754. * This method will return the name of the class used to create the instance of the given object.
  38755. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38756. * @param object the object to get the class name from
  38757. * @param isType defines if the object is actually a type
  38758. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38759. */
  38760. static GetClassName(object: any, isType?: boolean): string;
  38761. /**
  38762. * Gets the first element of an array satisfying a given predicate
  38763. * @param array defines the array to browse
  38764. * @param predicate defines the predicate to use
  38765. * @returns null if not found or the element
  38766. */
  38767. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38768. /**
  38769. * This method will return the name of the full name of the class, including its owning module (if any).
  38770. * 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).
  38771. * @param object the object to get the class name from
  38772. * @param isType defines if the object is actually a type
  38773. * @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.
  38774. * @ignorenaming
  38775. */
  38776. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38777. /**
  38778. * Returns a promise that resolves after the given amount of time.
  38779. * @param delay Number of milliseconds to delay
  38780. * @returns Promise that resolves after the given amount of time
  38781. */
  38782. static DelayAsync(delay: number): Promise<void>;
  38783. /**
  38784. * Utility function to detect if the current user agent is Safari
  38785. * @returns whether or not the current user agent is safari
  38786. */
  38787. static IsSafari(): boolean;
  38788. }
  38789. /**
  38790. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38791. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38792. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38793. * @param name The name of the class, case should be preserved
  38794. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38795. */
  38796. export function className(name: string, module?: string): (target: Object) => void;
  38797. /**
  38798. * An implementation of a loop for asynchronous functions.
  38799. */
  38800. export class AsyncLoop {
  38801. /**
  38802. * Defines the number of iterations for the loop
  38803. */
  38804. iterations: number;
  38805. /**
  38806. * Defines the current index of the loop.
  38807. */
  38808. index: number;
  38809. private _done;
  38810. private _fn;
  38811. private _successCallback;
  38812. /**
  38813. * Constructor.
  38814. * @param iterations the number of iterations.
  38815. * @param func the function to run each iteration
  38816. * @param successCallback the callback that will be called upon succesful execution
  38817. * @param offset starting offset.
  38818. */
  38819. constructor(
  38820. /**
  38821. * Defines the number of iterations for the loop
  38822. */
  38823. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38824. /**
  38825. * Execute the next iteration. Must be called after the last iteration was finished.
  38826. */
  38827. executeNext(): void;
  38828. /**
  38829. * Break the loop and run the success callback.
  38830. */
  38831. breakLoop(): void;
  38832. /**
  38833. * Create and run an async loop.
  38834. * @param iterations the number of iterations.
  38835. * @param fn the function to run each iteration
  38836. * @param successCallback the callback that will be called upon succesful execution
  38837. * @param offset starting offset.
  38838. * @returns the created async loop object
  38839. */
  38840. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38841. /**
  38842. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38843. * @param iterations total number of iterations
  38844. * @param syncedIterations number of synchronous iterations in each async iteration.
  38845. * @param fn the function to call each iteration.
  38846. * @param callback a success call back that will be called when iterating stops.
  38847. * @param breakFunction a break condition (optional)
  38848. * @param timeout timeout settings for the setTimeout function. default - 0.
  38849. * @returns the created async loop object
  38850. */
  38851. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38852. }
  38853. }
  38854. declare module BABYLON {
  38855. /**
  38856. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38857. * The underlying implementation relies on an associative array to ensure the best performances.
  38858. * The value can be anything including 'null' but except 'undefined'
  38859. */
  38860. export class StringDictionary<T> {
  38861. /**
  38862. * This will clear this dictionary and copy the content from the 'source' one.
  38863. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38864. * @param source the dictionary to take the content from and copy to this dictionary
  38865. */
  38866. copyFrom(source: StringDictionary<T>): void;
  38867. /**
  38868. * Get a value based from its key
  38869. * @param key the given key to get the matching value from
  38870. * @return the value if found, otherwise undefined is returned
  38871. */
  38872. get(key: string): T | undefined;
  38873. /**
  38874. * Get a value from its key or add it if it doesn't exist.
  38875. * This method will ensure you that a given key/data will be present in the dictionary.
  38876. * @param key the given key to get the matching value from
  38877. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38878. * The factory will only be invoked if there's no data for the given key.
  38879. * @return the value corresponding to the key.
  38880. */
  38881. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38882. /**
  38883. * Get a value from its key if present in the dictionary otherwise add it
  38884. * @param key the key to get the value from
  38885. * @param val if there's no such key/value pair in the dictionary add it with this value
  38886. * @return the value corresponding to the key
  38887. */
  38888. getOrAdd(key: string, val: T): T;
  38889. /**
  38890. * Check if there's a given key in the dictionary
  38891. * @param key the key to check for
  38892. * @return true if the key is present, false otherwise
  38893. */
  38894. contains(key: string): boolean;
  38895. /**
  38896. * Add a new key and its corresponding value
  38897. * @param key the key to add
  38898. * @param value the value corresponding to the key
  38899. * @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
  38900. */
  38901. add(key: string, value: T): boolean;
  38902. /**
  38903. * Update a specific value associated to a key
  38904. * @param key defines the key to use
  38905. * @param value defines the value to store
  38906. * @returns true if the value was updated (or false if the key was not found)
  38907. */
  38908. set(key: string, value: T): boolean;
  38909. /**
  38910. * Get the element of the given key and remove it from the dictionary
  38911. * @param key defines the key to search
  38912. * @returns the value associated with the key or null if not found
  38913. */
  38914. getAndRemove(key: string): Nullable<T>;
  38915. /**
  38916. * Remove a key/value from the dictionary.
  38917. * @param key the key to remove
  38918. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38919. */
  38920. remove(key: string): boolean;
  38921. /**
  38922. * Clear the whole content of the dictionary
  38923. */
  38924. clear(): void;
  38925. /**
  38926. * Gets the current count
  38927. */
  38928. get count(): number;
  38929. /**
  38930. * Execute a callback on each key/val of the dictionary.
  38931. * Note that you can remove any element in this dictionary in the callback implementation
  38932. * @param callback the callback to execute on a given key/value pair
  38933. */
  38934. forEach(callback: (key: string, val: T) => void): void;
  38935. /**
  38936. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38937. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38938. * Note that you can remove any element in this dictionary in the callback implementation
  38939. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38940. * @returns the first item
  38941. */
  38942. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38943. private _count;
  38944. private _data;
  38945. }
  38946. }
  38947. declare module BABYLON {
  38948. /** @hidden */
  38949. export interface ICollisionCoordinator {
  38950. createCollider(): Collider;
  38951. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38952. init(scene: Scene): void;
  38953. }
  38954. /** @hidden */
  38955. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38956. private _scene;
  38957. private _scaledPosition;
  38958. private _scaledVelocity;
  38959. private _finalPosition;
  38960. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38961. createCollider(): Collider;
  38962. init(scene: Scene): void;
  38963. private _collideWithWorld;
  38964. }
  38965. }
  38966. declare module BABYLON {
  38967. /**
  38968. * Class used to manage all inputs for the scene.
  38969. */
  38970. export class InputManager {
  38971. /** The distance in pixel that you have to move to prevent some events */
  38972. static DragMovementThreshold: number;
  38973. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38974. static LongPressDelay: number;
  38975. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38976. static DoubleClickDelay: number;
  38977. /** If you need to check double click without raising a single click at first click, enable this flag */
  38978. static ExclusiveDoubleClickMode: boolean;
  38979. /** 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. */
  38980. private _alreadyAttached;
  38981. private _wheelEventName;
  38982. private _onPointerMove;
  38983. private _onPointerDown;
  38984. private _onPointerUp;
  38985. private _initClickEvent;
  38986. private _initActionManager;
  38987. private _delayedSimpleClick;
  38988. private _delayedSimpleClickTimeout;
  38989. private _previousDelayedSimpleClickTimeout;
  38990. private _meshPickProceed;
  38991. private _previousButtonPressed;
  38992. private _currentPickResult;
  38993. private _previousPickResult;
  38994. private _totalPointersPressed;
  38995. private _doubleClickOccured;
  38996. private _pointerOverMesh;
  38997. private _pickedDownMesh;
  38998. private _pickedUpMesh;
  38999. private _pointerX;
  39000. private _pointerY;
  39001. private _unTranslatedPointerX;
  39002. private _unTranslatedPointerY;
  39003. private _startingPointerPosition;
  39004. private _previousStartingPointerPosition;
  39005. private _startingPointerTime;
  39006. private _previousStartingPointerTime;
  39007. private _pointerCaptures;
  39008. private _meshUnderPointerId;
  39009. private _onKeyDown;
  39010. private _onKeyUp;
  39011. private _onCanvasFocusObserver;
  39012. private _onCanvasBlurObserver;
  39013. private _scene;
  39014. /**
  39015. * Creates a new InputManager
  39016. * @param scene defines the hosting scene
  39017. */
  39018. constructor(scene: Scene);
  39019. /**
  39020. * Gets the mesh that is currently under the pointer
  39021. */
  39022. get meshUnderPointer(): Nullable<AbstractMesh>;
  39023. /**
  39024. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  39025. * @param pointerId the pointer id to use
  39026. * @returns The mesh under this pointer id or null if not found
  39027. */
  39028. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  39029. /**
  39030. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39031. */
  39032. get unTranslatedPointer(): Vector2;
  39033. /**
  39034. * Gets or sets the current on-screen X position of the pointer
  39035. */
  39036. get pointerX(): number;
  39037. set pointerX(value: number);
  39038. /**
  39039. * Gets or sets the current on-screen Y position of the pointer
  39040. */
  39041. get pointerY(): number;
  39042. set pointerY(value: number);
  39043. private _updatePointerPosition;
  39044. private _processPointerMove;
  39045. private _setRayOnPointerInfo;
  39046. private _checkPrePointerObservable;
  39047. /**
  39048. * Use this method to simulate a pointer move on a mesh
  39049. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39050. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39051. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39052. */
  39053. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39054. /**
  39055. * Use this method to simulate a pointer down on a mesh
  39056. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39057. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39058. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39059. */
  39060. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39061. private _processPointerDown;
  39062. /** @hidden */
  39063. _isPointerSwiping(): boolean;
  39064. /**
  39065. * Use this method to simulate a pointer up on a mesh
  39066. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39067. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39068. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39069. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39070. */
  39071. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39072. private _processPointerUp;
  39073. /**
  39074. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39075. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39076. * @returns true if the pointer was captured
  39077. */
  39078. isPointerCaptured(pointerId?: number): boolean;
  39079. /**
  39080. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39081. * @param attachUp defines if you want to attach events to pointerup
  39082. * @param attachDown defines if you want to attach events to pointerdown
  39083. * @param attachMove defines if you want to attach events to pointermove
  39084. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39085. */
  39086. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39087. /**
  39088. * Detaches all event handlers
  39089. */
  39090. detachControl(): void;
  39091. /**
  39092. * Force the value of meshUnderPointer
  39093. * @param mesh defines the mesh to use
  39094. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39095. */
  39096. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39097. /**
  39098. * Gets the mesh under the pointer
  39099. * @returns a Mesh or null if no mesh is under the pointer
  39100. */
  39101. getPointerOverMesh(): Nullable<AbstractMesh>;
  39102. }
  39103. }
  39104. declare module BABYLON {
  39105. /**
  39106. * This class defines the direct association between an animation and a target
  39107. */
  39108. export class TargetedAnimation {
  39109. /**
  39110. * Animation to perform
  39111. */
  39112. animation: Animation;
  39113. /**
  39114. * Target to animate
  39115. */
  39116. target: any;
  39117. /**
  39118. * Returns the string "TargetedAnimation"
  39119. * @returns "TargetedAnimation"
  39120. */
  39121. getClassName(): string;
  39122. /**
  39123. * Serialize the object
  39124. * @returns the JSON object representing the current entity
  39125. */
  39126. serialize(): any;
  39127. }
  39128. /**
  39129. * Use this class to create coordinated animations on multiple targets
  39130. */
  39131. export class AnimationGroup implements IDisposable {
  39132. /** The name of the animation group */
  39133. name: string;
  39134. private _scene;
  39135. private _targetedAnimations;
  39136. private _animatables;
  39137. private _from;
  39138. private _to;
  39139. private _isStarted;
  39140. private _isPaused;
  39141. private _speedRatio;
  39142. private _loopAnimation;
  39143. private _isAdditive;
  39144. /**
  39145. * Gets or sets the unique id of the node
  39146. */
  39147. uniqueId: number;
  39148. /**
  39149. * This observable will notify when one animation have ended
  39150. */
  39151. onAnimationEndObservable: Observable<TargetedAnimation>;
  39152. /**
  39153. * Observer raised when one animation loops
  39154. */
  39155. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39156. /**
  39157. * Observer raised when all animations have looped
  39158. */
  39159. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39160. /**
  39161. * This observable will notify when all animations have ended.
  39162. */
  39163. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39164. /**
  39165. * This observable will notify when all animations have paused.
  39166. */
  39167. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39168. /**
  39169. * This observable will notify when all animations are playing.
  39170. */
  39171. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39172. /**
  39173. * Gets the first frame
  39174. */
  39175. get from(): number;
  39176. /**
  39177. * Gets the last frame
  39178. */
  39179. get to(): number;
  39180. /**
  39181. * Define if the animations are started
  39182. */
  39183. get isStarted(): boolean;
  39184. /**
  39185. * Gets a value indicating that the current group is playing
  39186. */
  39187. get isPlaying(): boolean;
  39188. /**
  39189. * Gets or sets the speed ratio to use for all animations
  39190. */
  39191. get speedRatio(): number;
  39192. /**
  39193. * Gets or sets the speed ratio to use for all animations
  39194. */
  39195. set speedRatio(value: number);
  39196. /**
  39197. * Gets or sets if all animations should loop or not
  39198. */
  39199. get loopAnimation(): boolean;
  39200. set loopAnimation(value: boolean);
  39201. /**
  39202. * Gets or sets if all animations should be evaluated additively
  39203. */
  39204. get isAdditive(): boolean;
  39205. set isAdditive(value: boolean);
  39206. /**
  39207. * Gets the targeted animations for this animation group
  39208. */
  39209. get targetedAnimations(): Array<TargetedAnimation>;
  39210. /**
  39211. * returning the list of animatables controlled by this animation group.
  39212. */
  39213. get animatables(): Array<Animatable>;
  39214. /**
  39215. * Gets the list of target animations
  39216. */
  39217. get children(): TargetedAnimation[];
  39218. /**
  39219. * Instantiates a new Animation Group.
  39220. * This helps managing several animations at once.
  39221. * @see https://doc.babylonjs.com/how_to/group
  39222. * @param name Defines the name of the group
  39223. * @param scene Defines the scene the group belongs to
  39224. */
  39225. constructor(
  39226. /** The name of the animation group */
  39227. name: string, scene?: Nullable<Scene>);
  39228. /**
  39229. * Add an animation (with its target) in the group
  39230. * @param animation defines the animation we want to add
  39231. * @param target defines the target of the animation
  39232. * @returns the TargetedAnimation object
  39233. */
  39234. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39235. /**
  39236. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39237. * It can add constant keys at begin or end
  39238. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39239. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39240. * @returns the animation group
  39241. */
  39242. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39243. private _animationLoopCount;
  39244. private _animationLoopFlags;
  39245. private _processLoop;
  39246. /**
  39247. * Start all animations on given targets
  39248. * @param loop defines if animations must loop
  39249. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39250. * @param from defines the from key (optional)
  39251. * @param to defines the to key (optional)
  39252. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39253. * @returns the current animation group
  39254. */
  39255. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39256. /**
  39257. * Pause all animations
  39258. * @returns the animation group
  39259. */
  39260. pause(): AnimationGroup;
  39261. /**
  39262. * Play all animations to initial state
  39263. * This function will start() the animations if they were not started or will restart() them if they were paused
  39264. * @param loop defines if animations must loop
  39265. * @returns the animation group
  39266. */
  39267. play(loop?: boolean): AnimationGroup;
  39268. /**
  39269. * Reset all animations to initial state
  39270. * @returns the animation group
  39271. */
  39272. reset(): AnimationGroup;
  39273. /**
  39274. * Restart animations from key 0
  39275. * @returns the animation group
  39276. */
  39277. restart(): AnimationGroup;
  39278. /**
  39279. * Stop all animations
  39280. * @returns the animation group
  39281. */
  39282. stop(): AnimationGroup;
  39283. /**
  39284. * Set animation weight for all animatables
  39285. * @param weight defines the weight to use
  39286. * @return the animationGroup
  39287. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39288. */
  39289. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39290. /**
  39291. * Synchronize and normalize all animatables with a source animatable
  39292. * @param root defines the root animatable to synchronize with
  39293. * @return the animationGroup
  39294. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39295. */
  39296. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39297. /**
  39298. * Goes to a specific frame in this animation group
  39299. * @param frame the frame number to go to
  39300. * @return the animationGroup
  39301. */
  39302. goToFrame(frame: number): AnimationGroup;
  39303. /**
  39304. * Dispose all associated resources
  39305. */
  39306. dispose(): void;
  39307. private _checkAnimationGroupEnded;
  39308. /**
  39309. * Clone the current animation group and returns a copy
  39310. * @param newName defines the name of the new group
  39311. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39312. * @returns the new aniamtion group
  39313. */
  39314. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39315. /**
  39316. * Serializes the animationGroup to an object
  39317. * @returns Serialized object
  39318. */
  39319. serialize(): any;
  39320. /**
  39321. * Returns a new AnimationGroup object parsed from the source provided.
  39322. * @param parsedAnimationGroup defines the source
  39323. * @param scene defines the scene that will receive the animationGroup
  39324. * @returns a new AnimationGroup
  39325. */
  39326. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39327. /**
  39328. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39329. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39330. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39331. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39332. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39333. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39334. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39335. */
  39336. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39337. /**
  39338. * Returns the string "AnimationGroup"
  39339. * @returns "AnimationGroup"
  39340. */
  39341. getClassName(): string;
  39342. /**
  39343. * Creates a detailled string about the object
  39344. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39345. * @returns a string representing the object
  39346. */
  39347. toString(fullDetails?: boolean): string;
  39348. }
  39349. }
  39350. declare module BABYLON {
  39351. /**
  39352. * Define an interface for all classes that will hold resources
  39353. */
  39354. export interface IDisposable {
  39355. /**
  39356. * Releases all held resources
  39357. */
  39358. dispose(): void;
  39359. }
  39360. /** Interface defining initialization parameters for Scene class */
  39361. export interface SceneOptions {
  39362. /**
  39363. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39364. * It will improve performance when the number of geometries becomes important.
  39365. */
  39366. useGeometryUniqueIdsMap?: boolean;
  39367. /**
  39368. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39369. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39370. */
  39371. useMaterialMeshMap?: boolean;
  39372. /**
  39373. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39374. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39375. */
  39376. useClonedMeshMap?: boolean;
  39377. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39378. virtual?: boolean;
  39379. }
  39380. /**
  39381. * Represents a scene to be rendered by the engine.
  39382. * @see https://doc.babylonjs.com/features/scene
  39383. */
  39384. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39385. /** The fog is deactivated */
  39386. static readonly FOGMODE_NONE: number;
  39387. /** The fog density is following an exponential function */
  39388. static readonly FOGMODE_EXP: number;
  39389. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39390. static readonly FOGMODE_EXP2: number;
  39391. /** The fog density is following a linear function. */
  39392. static readonly FOGMODE_LINEAR: number;
  39393. /**
  39394. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39395. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39396. */
  39397. static MinDeltaTime: number;
  39398. /**
  39399. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39400. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39401. */
  39402. static MaxDeltaTime: number;
  39403. /**
  39404. * Factory used to create the default material.
  39405. * @param name The name of the material to create
  39406. * @param scene The scene to create the material for
  39407. * @returns The default material
  39408. */
  39409. static DefaultMaterialFactory(scene: Scene): Material;
  39410. /**
  39411. * Factory used to create the a collision coordinator.
  39412. * @returns The collision coordinator
  39413. */
  39414. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39415. /** @hidden */
  39416. _inputManager: InputManager;
  39417. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39418. cameraToUseForPointers: Nullable<Camera>;
  39419. /** @hidden */
  39420. readonly _isScene: boolean;
  39421. /** @hidden */
  39422. _blockEntityCollection: boolean;
  39423. /**
  39424. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39425. */
  39426. autoClear: boolean;
  39427. /**
  39428. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39429. */
  39430. autoClearDepthAndStencil: boolean;
  39431. /**
  39432. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39433. */
  39434. clearColor: Color4;
  39435. /**
  39436. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39437. */
  39438. ambientColor: Color3;
  39439. /**
  39440. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39441. * It should only be one of the following (if not the default embedded one):
  39442. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39443. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39444. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39445. * The material properties need to be setup according to the type of texture in use.
  39446. */
  39447. environmentBRDFTexture: BaseTexture;
  39448. /**
  39449. * Texture used in all pbr material as the reflection texture.
  39450. * As in the majority of the scene they are the same (exception for multi room and so on),
  39451. * this is easier to reference from here than from all the materials.
  39452. */
  39453. get environmentTexture(): Nullable<BaseTexture>;
  39454. /**
  39455. * Texture used in all pbr material as the reflection texture.
  39456. * As in the majority of the scene they are the same (exception for multi room and so on),
  39457. * this is easier to set here than in all the materials.
  39458. */
  39459. set environmentTexture(value: Nullable<BaseTexture>);
  39460. /** @hidden */
  39461. protected _environmentIntensity: number;
  39462. /**
  39463. * Intensity of the environment in all pbr material.
  39464. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39465. * As in the majority of the scene they are the same (exception for multi room and so on),
  39466. * this is easier to reference from here than from all the materials.
  39467. */
  39468. get environmentIntensity(): number;
  39469. /**
  39470. * Intensity of the environment in all pbr material.
  39471. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39472. * As in the majority of the scene they are the same (exception for multi room and so on),
  39473. * this is easier to set here than in all the materials.
  39474. */
  39475. set environmentIntensity(value: number);
  39476. /** @hidden */
  39477. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39478. /**
  39479. * Default image processing configuration used either in the rendering
  39480. * Forward main pass or through the imageProcessingPostProcess if present.
  39481. * As in the majority of the scene they are the same (exception for multi camera),
  39482. * this is easier to reference from here than from all the materials and post process.
  39483. *
  39484. * No setter as we it is a shared configuration, you can set the values instead.
  39485. */
  39486. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39487. private _forceWireframe;
  39488. /**
  39489. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39490. */
  39491. set forceWireframe(value: boolean);
  39492. get forceWireframe(): boolean;
  39493. private _skipFrustumClipping;
  39494. /**
  39495. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39496. */
  39497. set skipFrustumClipping(value: boolean);
  39498. get skipFrustumClipping(): boolean;
  39499. private _forcePointsCloud;
  39500. /**
  39501. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39502. */
  39503. set forcePointsCloud(value: boolean);
  39504. get forcePointsCloud(): boolean;
  39505. /**
  39506. * Gets or sets the active clipplane 1
  39507. */
  39508. clipPlane: Nullable<Plane>;
  39509. /**
  39510. * Gets or sets the active clipplane 2
  39511. */
  39512. clipPlane2: Nullable<Plane>;
  39513. /**
  39514. * Gets or sets the active clipplane 3
  39515. */
  39516. clipPlane3: Nullable<Plane>;
  39517. /**
  39518. * Gets or sets the active clipplane 4
  39519. */
  39520. clipPlane4: Nullable<Plane>;
  39521. /**
  39522. * Gets or sets the active clipplane 5
  39523. */
  39524. clipPlane5: Nullable<Plane>;
  39525. /**
  39526. * Gets or sets the active clipplane 6
  39527. */
  39528. clipPlane6: Nullable<Plane>;
  39529. /**
  39530. * Gets or sets a boolean indicating if animations are enabled
  39531. */
  39532. animationsEnabled: boolean;
  39533. private _animationPropertiesOverride;
  39534. /**
  39535. * Gets or sets the animation properties override
  39536. */
  39537. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39538. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39539. /**
  39540. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39541. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39542. */
  39543. useConstantAnimationDeltaTime: boolean;
  39544. /**
  39545. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39546. * Please note that it requires to run a ray cast through the scene on every frame
  39547. */
  39548. constantlyUpdateMeshUnderPointer: boolean;
  39549. /**
  39550. * Defines the HTML cursor to use when hovering over interactive elements
  39551. */
  39552. hoverCursor: string;
  39553. /**
  39554. * Defines the HTML default cursor to use (empty by default)
  39555. */
  39556. defaultCursor: string;
  39557. /**
  39558. * Defines whether cursors are handled by the scene.
  39559. */
  39560. doNotHandleCursors: boolean;
  39561. /**
  39562. * This is used to call preventDefault() on pointer down
  39563. * in order to block unwanted artifacts like system double clicks
  39564. */
  39565. preventDefaultOnPointerDown: boolean;
  39566. /**
  39567. * This is used to call preventDefault() on pointer up
  39568. * in order to block unwanted artifacts like system double clicks
  39569. */
  39570. preventDefaultOnPointerUp: boolean;
  39571. /**
  39572. * Gets or sets user defined metadata
  39573. */
  39574. metadata: any;
  39575. /**
  39576. * For internal use only. Please do not use.
  39577. */
  39578. reservedDataStore: any;
  39579. /**
  39580. * Gets the name of the plugin used to load this scene (null by default)
  39581. */
  39582. loadingPluginName: string;
  39583. /**
  39584. * Use this array to add regular expressions used to disable offline support for specific urls
  39585. */
  39586. disableOfflineSupportExceptionRules: RegExp[];
  39587. /**
  39588. * An event triggered when the scene is disposed.
  39589. */
  39590. onDisposeObservable: Observable<Scene>;
  39591. private _onDisposeObserver;
  39592. /** Sets a function to be executed when this scene is disposed. */
  39593. set onDispose(callback: () => void);
  39594. /**
  39595. * An event triggered before rendering the scene (right after animations and physics)
  39596. */
  39597. onBeforeRenderObservable: Observable<Scene>;
  39598. private _onBeforeRenderObserver;
  39599. /** Sets a function to be executed before rendering this scene */
  39600. set beforeRender(callback: Nullable<() => void>);
  39601. /**
  39602. * An event triggered after rendering the scene
  39603. */
  39604. onAfterRenderObservable: Observable<Scene>;
  39605. /**
  39606. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39607. */
  39608. onAfterRenderCameraObservable: Observable<Camera>;
  39609. private _onAfterRenderObserver;
  39610. /** Sets a function to be executed after rendering this scene */
  39611. set afterRender(callback: Nullable<() => void>);
  39612. /**
  39613. * An event triggered before animating the scene
  39614. */
  39615. onBeforeAnimationsObservable: Observable<Scene>;
  39616. /**
  39617. * An event triggered after animations processing
  39618. */
  39619. onAfterAnimationsObservable: Observable<Scene>;
  39620. /**
  39621. * An event triggered before draw calls are ready to be sent
  39622. */
  39623. onBeforeDrawPhaseObservable: Observable<Scene>;
  39624. /**
  39625. * An event triggered after draw calls have been sent
  39626. */
  39627. onAfterDrawPhaseObservable: Observable<Scene>;
  39628. /**
  39629. * An event triggered when the scene is ready
  39630. */
  39631. onReadyObservable: Observable<Scene>;
  39632. /**
  39633. * An event triggered before rendering a camera
  39634. */
  39635. onBeforeCameraRenderObservable: Observable<Camera>;
  39636. private _onBeforeCameraRenderObserver;
  39637. /** Sets a function to be executed before rendering a camera*/
  39638. set beforeCameraRender(callback: () => void);
  39639. /**
  39640. * An event triggered after rendering a camera
  39641. */
  39642. onAfterCameraRenderObservable: Observable<Camera>;
  39643. private _onAfterCameraRenderObserver;
  39644. /** Sets a function to be executed after rendering a camera*/
  39645. set afterCameraRender(callback: () => void);
  39646. /**
  39647. * An event triggered when active meshes evaluation is about to start
  39648. */
  39649. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39650. /**
  39651. * An event triggered when active meshes evaluation is done
  39652. */
  39653. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39654. /**
  39655. * An event triggered when particles rendering is about to start
  39656. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39657. */
  39658. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39659. /**
  39660. * An event triggered when particles rendering is done
  39661. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39662. */
  39663. onAfterParticlesRenderingObservable: Observable<Scene>;
  39664. /**
  39665. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39666. */
  39667. onDataLoadedObservable: Observable<Scene>;
  39668. /**
  39669. * An event triggered when a camera is created
  39670. */
  39671. onNewCameraAddedObservable: Observable<Camera>;
  39672. /**
  39673. * An event triggered when a camera is removed
  39674. */
  39675. onCameraRemovedObservable: Observable<Camera>;
  39676. /**
  39677. * An event triggered when a light is created
  39678. */
  39679. onNewLightAddedObservable: Observable<Light>;
  39680. /**
  39681. * An event triggered when a light is removed
  39682. */
  39683. onLightRemovedObservable: Observable<Light>;
  39684. /**
  39685. * An event triggered when a geometry is created
  39686. */
  39687. onNewGeometryAddedObservable: Observable<Geometry>;
  39688. /**
  39689. * An event triggered when a geometry is removed
  39690. */
  39691. onGeometryRemovedObservable: Observable<Geometry>;
  39692. /**
  39693. * An event triggered when a transform node is created
  39694. */
  39695. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39696. /**
  39697. * An event triggered when a transform node is removed
  39698. */
  39699. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39700. /**
  39701. * An event triggered when a mesh is created
  39702. */
  39703. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39704. /**
  39705. * An event triggered when a mesh is removed
  39706. */
  39707. onMeshRemovedObservable: Observable<AbstractMesh>;
  39708. /**
  39709. * An event triggered when a skeleton is created
  39710. */
  39711. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39712. /**
  39713. * An event triggered when a skeleton is removed
  39714. */
  39715. onSkeletonRemovedObservable: Observable<Skeleton>;
  39716. /**
  39717. * An event triggered when a material is created
  39718. */
  39719. onNewMaterialAddedObservable: Observable<Material>;
  39720. /**
  39721. * An event triggered when a material is removed
  39722. */
  39723. onMaterialRemovedObservable: Observable<Material>;
  39724. /**
  39725. * An event triggered when a texture is created
  39726. */
  39727. onNewTextureAddedObservable: Observable<BaseTexture>;
  39728. /**
  39729. * An event triggered when a texture is removed
  39730. */
  39731. onTextureRemovedObservable: Observable<BaseTexture>;
  39732. /**
  39733. * An event triggered when render targets are about to be rendered
  39734. * Can happen multiple times per frame.
  39735. */
  39736. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39737. /**
  39738. * An event triggered when render targets were rendered.
  39739. * Can happen multiple times per frame.
  39740. */
  39741. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39742. /**
  39743. * An event triggered before calculating deterministic simulation step
  39744. */
  39745. onBeforeStepObservable: Observable<Scene>;
  39746. /**
  39747. * An event triggered after calculating deterministic simulation step
  39748. */
  39749. onAfterStepObservable: Observable<Scene>;
  39750. /**
  39751. * An event triggered when the activeCamera property is updated
  39752. */
  39753. onActiveCameraChanged: Observable<Scene>;
  39754. /**
  39755. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39756. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39757. * 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)
  39758. */
  39759. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39760. /**
  39761. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39762. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39763. * 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)
  39764. */
  39765. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39766. /**
  39767. * This Observable will when a mesh has been imported into the scene.
  39768. */
  39769. onMeshImportedObservable: Observable<AbstractMesh>;
  39770. /**
  39771. * This Observable will when an animation file has been imported into the scene.
  39772. */
  39773. onAnimationFileImportedObservable: Observable<Scene>;
  39774. /**
  39775. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39776. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39777. */
  39778. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39779. /** @hidden */
  39780. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39781. /**
  39782. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39783. */
  39784. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39785. /**
  39786. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39787. */
  39788. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39789. /**
  39790. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39791. */
  39792. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39793. /** Callback called when a pointer move is detected */
  39794. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39795. /** Callback called when a pointer down is detected */
  39796. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39797. /** Callback called when a pointer up is detected */
  39798. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39799. /** Callback called when a pointer pick is detected */
  39800. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39801. /**
  39802. * 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).
  39803. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39804. */
  39805. onPrePointerObservable: Observable<PointerInfoPre>;
  39806. /**
  39807. * Observable event triggered each time an input event is received from the rendering canvas
  39808. */
  39809. onPointerObservable: Observable<PointerInfo>;
  39810. /**
  39811. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39812. */
  39813. get unTranslatedPointer(): Vector2;
  39814. /**
  39815. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39816. */
  39817. static get DragMovementThreshold(): number;
  39818. static set DragMovementThreshold(value: number);
  39819. /**
  39820. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39821. */
  39822. static get LongPressDelay(): number;
  39823. static set LongPressDelay(value: number);
  39824. /**
  39825. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39826. */
  39827. static get DoubleClickDelay(): number;
  39828. static set DoubleClickDelay(value: number);
  39829. /** If you need to check double click without raising a single click at first click, enable this flag */
  39830. static get ExclusiveDoubleClickMode(): boolean;
  39831. static set ExclusiveDoubleClickMode(value: boolean);
  39832. /** @hidden */
  39833. _mirroredCameraPosition: Nullable<Vector3>;
  39834. /**
  39835. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39836. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39837. */
  39838. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39839. /**
  39840. * Observable event triggered each time an keyboard event is received from the hosting window
  39841. */
  39842. onKeyboardObservable: Observable<KeyboardInfo>;
  39843. private _useRightHandedSystem;
  39844. /**
  39845. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39846. */
  39847. set useRightHandedSystem(value: boolean);
  39848. get useRightHandedSystem(): boolean;
  39849. private _timeAccumulator;
  39850. private _currentStepId;
  39851. private _currentInternalStep;
  39852. /**
  39853. * Sets the step Id used by deterministic lock step
  39854. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39855. * @param newStepId defines the step Id
  39856. */
  39857. setStepId(newStepId: number): void;
  39858. /**
  39859. * Gets the step Id used by deterministic lock step
  39860. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39861. * @returns the step Id
  39862. */
  39863. getStepId(): number;
  39864. /**
  39865. * Gets the internal step used by deterministic lock step
  39866. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39867. * @returns the internal step
  39868. */
  39869. getInternalStep(): number;
  39870. private _fogEnabled;
  39871. /**
  39872. * Gets or sets a boolean indicating if fog is enabled on this scene
  39873. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39874. * (Default is true)
  39875. */
  39876. set fogEnabled(value: boolean);
  39877. get fogEnabled(): boolean;
  39878. private _fogMode;
  39879. /**
  39880. * Gets or sets the fog mode to use
  39881. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39882. * | mode | value |
  39883. * | --- | --- |
  39884. * | FOGMODE_NONE | 0 |
  39885. * | FOGMODE_EXP | 1 |
  39886. * | FOGMODE_EXP2 | 2 |
  39887. * | FOGMODE_LINEAR | 3 |
  39888. */
  39889. set fogMode(value: number);
  39890. get fogMode(): number;
  39891. /**
  39892. * Gets or sets the fog color to use
  39893. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39894. * (Default is Color3(0.2, 0.2, 0.3))
  39895. */
  39896. fogColor: Color3;
  39897. /**
  39898. * Gets or sets the fog density to use
  39899. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39900. * (Default is 0.1)
  39901. */
  39902. fogDensity: number;
  39903. /**
  39904. * Gets or sets the fog start distance to use
  39905. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39906. * (Default is 0)
  39907. */
  39908. fogStart: number;
  39909. /**
  39910. * Gets or sets the fog end distance to use
  39911. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39912. * (Default is 1000)
  39913. */
  39914. fogEnd: number;
  39915. /**
  39916. * Flag indicating that the frame buffer binding is handled by another component
  39917. */
  39918. prePass: boolean;
  39919. private _shadowsEnabled;
  39920. /**
  39921. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39922. */
  39923. set shadowsEnabled(value: boolean);
  39924. get shadowsEnabled(): boolean;
  39925. private _lightsEnabled;
  39926. /**
  39927. * Gets or sets a boolean indicating if lights are enabled on this scene
  39928. */
  39929. set lightsEnabled(value: boolean);
  39930. get lightsEnabled(): boolean;
  39931. /** All of the active cameras added to this scene. */
  39932. activeCameras: Camera[];
  39933. /** @hidden */
  39934. _activeCamera: Nullable<Camera>;
  39935. /** Gets or sets the current active camera */
  39936. get activeCamera(): Nullable<Camera>;
  39937. set activeCamera(value: Nullable<Camera>);
  39938. private _defaultMaterial;
  39939. /** The default material used on meshes when no material is affected */
  39940. get defaultMaterial(): Material;
  39941. /** The default material used on meshes when no material is affected */
  39942. set defaultMaterial(value: Material);
  39943. private _texturesEnabled;
  39944. /**
  39945. * Gets or sets a boolean indicating if textures are enabled on this scene
  39946. */
  39947. set texturesEnabled(value: boolean);
  39948. get texturesEnabled(): boolean;
  39949. /**
  39950. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39951. */
  39952. physicsEnabled: boolean;
  39953. /**
  39954. * Gets or sets a boolean indicating if particles are enabled on this scene
  39955. */
  39956. particlesEnabled: boolean;
  39957. /**
  39958. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39959. */
  39960. spritesEnabled: boolean;
  39961. private _skeletonsEnabled;
  39962. /**
  39963. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39964. */
  39965. set skeletonsEnabled(value: boolean);
  39966. get skeletonsEnabled(): boolean;
  39967. /**
  39968. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39969. */
  39970. lensFlaresEnabled: boolean;
  39971. /**
  39972. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39973. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39974. */
  39975. collisionsEnabled: boolean;
  39976. private _collisionCoordinator;
  39977. /** @hidden */
  39978. get collisionCoordinator(): ICollisionCoordinator;
  39979. /**
  39980. * Defines the gravity applied to this scene (used only for collisions)
  39981. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39982. */
  39983. gravity: Vector3;
  39984. /**
  39985. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39986. */
  39987. postProcessesEnabled: boolean;
  39988. /**
  39989. * Gets the current postprocess manager
  39990. */
  39991. postProcessManager: PostProcessManager;
  39992. /**
  39993. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39994. */
  39995. renderTargetsEnabled: boolean;
  39996. /**
  39997. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39998. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39999. */
  40000. dumpNextRenderTargets: boolean;
  40001. /**
  40002. * The list of user defined render targets added to the scene
  40003. */
  40004. customRenderTargets: RenderTargetTexture[];
  40005. /**
  40006. * Defines if texture loading must be delayed
  40007. * If true, textures will only be loaded when they need to be rendered
  40008. */
  40009. useDelayedTextureLoading: boolean;
  40010. /**
  40011. * Gets the list of meshes imported to the scene through SceneLoader
  40012. */
  40013. importedMeshesFiles: String[];
  40014. /**
  40015. * Gets or sets a boolean indicating if probes are enabled on this scene
  40016. */
  40017. probesEnabled: boolean;
  40018. /**
  40019. * Gets or sets the current offline provider to use to store scene data
  40020. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40021. */
  40022. offlineProvider: IOfflineProvider;
  40023. /**
  40024. * Gets or sets the action manager associated with the scene
  40025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40026. */
  40027. actionManager: AbstractActionManager;
  40028. private _meshesForIntersections;
  40029. /**
  40030. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40031. */
  40032. proceduralTexturesEnabled: boolean;
  40033. private _engine;
  40034. private _totalVertices;
  40035. /** @hidden */
  40036. _activeIndices: PerfCounter;
  40037. /** @hidden */
  40038. _activeParticles: PerfCounter;
  40039. /** @hidden */
  40040. _activeBones: PerfCounter;
  40041. private _animationRatio;
  40042. /** @hidden */
  40043. _animationTimeLast: number;
  40044. /** @hidden */
  40045. _animationTime: number;
  40046. /**
  40047. * Gets or sets a general scale for animation speed
  40048. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40049. */
  40050. animationTimeScale: number;
  40051. /** @hidden */
  40052. _cachedMaterial: Nullable<Material>;
  40053. /** @hidden */
  40054. _cachedEffect: Nullable<Effect>;
  40055. /** @hidden */
  40056. _cachedVisibility: Nullable<number>;
  40057. private _renderId;
  40058. private _frameId;
  40059. private _executeWhenReadyTimeoutId;
  40060. private _intermediateRendering;
  40061. private _viewUpdateFlag;
  40062. private _projectionUpdateFlag;
  40063. /** @hidden */
  40064. _toBeDisposed: Nullable<IDisposable>[];
  40065. private _activeRequests;
  40066. /** @hidden */
  40067. _pendingData: any[];
  40068. private _isDisposed;
  40069. /**
  40070. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40071. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40072. */
  40073. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40074. private _activeMeshes;
  40075. private _processedMaterials;
  40076. private _renderTargets;
  40077. /** @hidden */
  40078. _activeParticleSystems: SmartArray<IParticleSystem>;
  40079. private _activeSkeletons;
  40080. private _softwareSkinnedMeshes;
  40081. private _renderingManager;
  40082. /** @hidden */
  40083. _activeAnimatables: Animatable[];
  40084. private _transformMatrix;
  40085. private _sceneUbo;
  40086. /** @hidden */
  40087. _viewMatrix: Matrix;
  40088. private _projectionMatrix;
  40089. /** @hidden */
  40090. _forcedViewPosition: Nullable<Vector3>;
  40091. /** @hidden */
  40092. _frustumPlanes: Plane[];
  40093. /**
  40094. * Gets the list of frustum planes (built from the active camera)
  40095. */
  40096. get frustumPlanes(): Plane[];
  40097. /**
  40098. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40099. * This is useful if there are more lights that the maximum simulteanous authorized
  40100. */
  40101. requireLightSorting: boolean;
  40102. /** @hidden */
  40103. readonly useMaterialMeshMap: boolean;
  40104. /** @hidden */
  40105. readonly useClonedMeshMap: boolean;
  40106. private _externalData;
  40107. private _uid;
  40108. /**
  40109. * @hidden
  40110. * Backing store of defined scene components.
  40111. */
  40112. _components: ISceneComponent[];
  40113. /**
  40114. * @hidden
  40115. * Backing store of defined scene components.
  40116. */
  40117. _serializableComponents: ISceneSerializableComponent[];
  40118. /**
  40119. * List of components to register on the next registration step.
  40120. */
  40121. private _transientComponents;
  40122. /**
  40123. * Registers the transient components if needed.
  40124. */
  40125. private _registerTransientComponents;
  40126. /**
  40127. * @hidden
  40128. * Add a component to the scene.
  40129. * Note that the ccomponent could be registered on th next frame if this is called after
  40130. * the register component stage.
  40131. * @param component Defines the component to add to the scene
  40132. */
  40133. _addComponent(component: ISceneComponent): void;
  40134. /**
  40135. * @hidden
  40136. * Gets a component from the scene.
  40137. * @param name defines the name of the component to retrieve
  40138. * @returns the component or null if not present
  40139. */
  40140. _getComponent(name: string): Nullable<ISceneComponent>;
  40141. /**
  40142. * @hidden
  40143. * Defines the actions happening before camera updates.
  40144. */
  40145. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40146. /**
  40147. * @hidden
  40148. * Defines the actions happening before clear the canvas.
  40149. */
  40150. _beforeClearStage: Stage<SimpleStageAction>;
  40151. /**
  40152. * @hidden
  40153. * Defines the actions when collecting render targets for the frame.
  40154. */
  40155. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40156. /**
  40157. * @hidden
  40158. * Defines the actions happening for one camera in the frame.
  40159. */
  40160. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40161. /**
  40162. * @hidden
  40163. * Defines the actions happening during the per mesh ready checks.
  40164. */
  40165. _isReadyForMeshStage: Stage<MeshStageAction>;
  40166. /**
  40167. * @hidden
  40168. * Defines the actions happening before evaluate active mesh checks.
  40169. */
  40170. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40171. /**
  40172. * @hidden
  40173. * Defines the actions happening during the evaluate sub mesh checks.
  40174. */
  40175. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40176. /**
  40177. * @hidden
  40178. * Defines the actions happening during the active mesh stage.
  40179. */
  40180. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40181. /**
  40182. * @hidden
  40183. * Defines the actions happening during the per camera render target step.
  40184. */
  40185. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40186. /**
  40187. * @hidden
  40188. * Defines the actions happening just before the active camera is drawing.
  40189. */
  40190. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40191. /**
  40192. * @hidden
  40193. * Defines the actions happening just before a render target is drawing.
  40194. */
  40195. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40196. /**
  40197. * @hidden
  40198. * Defines the actions happening just before a rendering group is drawing.
  40199. */
  40200. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40201. /**
  40202. * @hidden
  40203. * Defines the actions happening just before a mesh is drawing.
  40204. */
  40205. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40206. /**
  40207. * @hidden
  40208. * Defines the actions happening just after a mesh has been drawn.
  40209. */
  40210. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40211. /**
  40212. * @hidden
  40213. * Defines the actions happening just after a rendering group has been drawn.
  40214. */
  40215. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40216. /**
  40217. * @hidden
  40218. * Defines the actions happening just after the active camera has been drawn.
  40219. */
  40220. _afterCameraDrawStage: Stage<CameraStageAction>;
  40221. /**
  40222. * @hidden
  40223. * Defines the actions happening just after a render target has been drawn.
  40224. */
  40225. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40226. /**
  40227. * @hidden
  40228. * Defines the actions happening just after rendering all cameras and computing intersections.
  40229. */
  40230. _afterRenderStage: Stage<SimpleStageAction>;
  40231. /**
  40232. * @hidden
  40233. * Defines the actions happening when a pointer move event happens.
  40234. */
  40235. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40236. /**
  40237. * @hidden
  40238. * Defines the actions happening when a pointer down event happens.
  40239. */
  40240. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40241. /**
  40242. * @hidden
  40243. * Defines the actions happening when a pointer up event happens.
  40244. */
  40245. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40246. /**
  40247. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40248. */
  40249. private geometriesByUniqueId;
  40250. /**
  40251. * Creates a new Scene
  40252. * @param engine defines the engine to use to render this scene
  40253. * @param options defines the scene options
  40254. */
  40255. constructor(engine: Engine, options?: SceneOptions);
  40256. /**
  40257. * Gets a string identifying the name of the class
  40258. * @returns "Scene" string
  40259. */
  40260. getClassName(): string;
  40261. private _defaultMeshCandidates;
  40262. /**
  40263. * @hidden
  40264. */
  40265. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40266. private _defaultSubMeshCandidates;
  40267. /**
  40268. * @hidden
  40269. */
  40270. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40271. /**
  40272. * Sets the default candidate providers for the scene.
  40273. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40274. * and getCollidingSubMeshCandidates to their default function
  40275. */
  40276. setDefaultCandidateProviders(): void;
  40277. /**
  40278. * Gets the mesh that is currently under the pointer
  40279. */
  40280. get meshUnderPointer(): Nullable<AbstractMesh>;
  40281. /**
  40282. * Gets or sets the current on-screen X position of the pointer
  40283. */
  40284. get pointerX(): number;
  40285. set pointerX(value: number);
  40286. /**
  40287. * Gets or sets the current on-screen Y position of the pointer
  40288. */
  40289. get pointerY(): number;
  40290. set pointerY(value: number);
  40291. /**
  40292. * Gets the cached material (ie. the latest rendered one)
  40293. * @returns the cached material
  40294. */
  40295. getCachedMaterial(): Nullable<Material>;
  40296. /**
  40297. * Gets the cached effect (ie. the latest rendered one)
  40298. * @returns the cached effect
  40299. */
  40300. getCachedEffect(): Nullable<Effect>;
  40301. /**
  40302. * Gets the cached visibility state (ie. the latest rendered one)
  40303. * @returns the cached visibility state
  40304. */
  40305. getCachedVisibility(): Nullable<number>;
  40306. /**
  40307. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40308. * @param material defines the current material
  40309. * @param effect defines the current effect
  40310. * @param visibility defines the current visibility state
  40311. * @returns true if one parameter is not cached
  40312. */
  40313. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40314. /**
  40315. * Gets the engine associated with the scene
  40316. * @returns an Engine
  40317. */
  40318. getEngine(): Engine;
  40319. /**
  40320. * Gets the total number of vertices rendered per frame
  40321. * @returns the total number of vertices rendered per frame
  40322. */
  40323. getTotalVertices(): number;
  40324. /**
  40325. * Gets the performance counter for total vertices
  40326. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40327. */
  40328. get totalVerticesPerfCounter(): PerfCounter;
  40329. /**
  40330. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40331. * @returns the total number of active indices rendered per frame
  40332. */
  40333. getActiveIndices(): number;
  40334. /**
  40335. * Gets the performance counter for active indices
  40336. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40337. */
  40338. get totalActiveIndicesPerfCounter(): PerfCounter;
  40339. /**
  40340. * Gets the total number of active particles rendered per frame
  40341. * @returns the total number of active particles rendered per frame
  40342. */
  40343. getActiveParticles(): number;
  40344. /**
  40345. * Gets the performance counter for active particles
  40346. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40347. */
  40348. get activeParticlesPerfCounter(): PerfCounter;
  40349. /**
  40350. * Gets the total number of active bones rendered per frame
  40351. * @returns the total number of active bones rendered per frame
  40352. */
  40353. getActiveBones(): number;
  40354. /**
  40355. * Gets the performance counter for active bones
  40356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40357. */
  40358. get activeBonesPerfCounter(): PerfCounter;
  40359. /**
  40360. * Gets the array of active meshes
  40361. * @returns an array of AbstractMesh
  40362. */
  40363. getActiveMeshes(): SmartArray<AbstractMesh>;
  40364. /**
  40365. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40366. * @returns a number
  40367. */
  40368. getAnimationRatio(): number;
  40369. /**
  40370. * Gets an unique Id for the current render phase
  40371. * @returns a number
  40372. */
  40373. getRenderId(): number;
  40374. /**
  40375. * Gets an unique Id for the current frame
  40376. * @returns a number
  40377. */
  40378. getFrameId(): number;
  40379. /** Call this function if you want to manually increment the render Id*/
  40380. incrementRenderId(): void;
  40381. private _createUbo;
  40382. /**
  40383. * Use this method to simulate a pointer move on a mesh
  40384. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40385. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40386. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40387. * @returns the current scene
  40388. */
  40389. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40390. /**
  40391. * Use this method to simulate a pointer down on a mesh
  40392. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40393. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40394. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40395. * @returns the current scene
  40396. */
  40397. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40398. /**
  40399. * Use this method to simulate a pointer up on a mesh
  40400. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40401. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40402. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40403. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40404. * @returns the current scene
  40405. */
  40406. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40407. /**
  40408. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40409. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40410. * @returns true if the pointer was captured
  40411. */
  40412. isPointerCaptured(pointerId?: number): boolean;
  40413. /**
  40414. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40415. * @param attachUp defines if you want to attach events to pointerup
  40416. * @param attachDown defines if you want to attach events to pointerdown
  40417. * @param attachMove defines if you want to attach events to pointermove
  40418. */
  40419. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40420. /** Detaches all event handlers*/
  40421. detachControl(): void;
  40422. /**
  40423. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40424. * Delay loaded resources are not taking in account
  40425. * @return true if all required resources are ready
  40426. */
  40427. isReady(): boolean;
  40428. /** Resets all cached information relative to material (including effect and visibility) */
  40429. resetCachedMaterial(): void;
  40430. /**
  40431. * Registers a function to be called before every frame render
  40432. * @param func defines the function to register
  40433. */
  40434. registerBeforeRender(func: () => void): void;
  40435. /**
  40436. * Unregisters a function called before every frame render
  40437. * @param func defines the function to unregister
  40438. */
  40439. unregisterBeforeRender(func: () => void): void;
  40440. /**
  40441. * Registers a function to be called after every frame render
  40442. * @param func defines the function to register
  40443. */
  40444. registerAfterRender(func: () => void): void;
  40445. /**
  40446. * Unregisters a function called after every frame render
  40447. * @param func defines the function to unregister
  40448. */
  40449. unregisterAfterRender(func: () => void): void;
  40450. private _executeOnceBeforeRender;
  40451. /**
  40452. * The provided function will run before render once and will be disposed afterwards.
  40453. * A timeout delay can be provided so that the function will be executed in N ms.
  40454. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40455. * @param func The function to be executed.
  40456. * @param timeout optional delay in ms
  40457. */
  40458. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40459. /** @hidden */
  40460. _addPendingData(data: any): void;
  40461. /** @hidden */
  40462. _removePendingData(data: any): void;
  40463. /**
  40464. * Returns the number of items waiting to be loaded
  40465. * @returns the number of items waiting to be loaded
  40466. */
  40467. getWaitingItemsCount(): number;
  40468. /**
  40469. * Returns a boolean indicating if the scene is still loading data
  40470. */
  40471. get isLoading(): boolean;
  40472. /**
  40473. * Registers a function to be executed when the scene is ready
  40474. * @param {Function} func - the function to be executed
  40475. */
  40476. executeWhenReady(func: () => void): void;
  40477. /**
  40478. * Returns a promise that resolves when the scene is ready
  40479. * @returns A promise that resolves when the scene is ready
  40480. */
  40481. whenReadyAsync(): Promise<void>;
  40482. /** @hidden */
  40483. _checkIsReady(): void;
  40484. /**
  40485. * Gets all animatable attached to the scene
  40486. */
  40487. get animatables(): Animatable[];
  40488. /**
  40489. * Resets the last animation time frame.
  40490. * Useful to override when animations start running when loading a scene for the first time.
  40491. */
  40492. resetLastAnimationTimeFrame(): void;
  40493. /**
  40494. * Gets the current view matrix
  40495. * @returns a Matrix
  40496. */
  40497. getViewMatrix(): Matrix;
  40498. /**
  40499. * Gets the current projection matrix
  40500. * @returns a Matrix
  40501. */
  40502. getProjectionMatrix(): Matrix;
  40503. /**
  40504. * Gets the current transform matrix
  40505. * @returns a Matrix made of View * Projection
  40506. */
  40507. getTransformMatrix(): Matrix;
  40508. /**
  40509. * Sets the current transform matrix
  40510. * @param viewL defines the View matrix to use
  40511. * @param projectionL defines the Projection matrix to use
  40512. * @param viewR defines the right View matrix to use (if provided)
  40513. * @param projectionR defines the right Projection matrix to use (if provided)
  40514. */
  40515. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40516. /**
  40517. * Gets the uniform buffer used to store scene data
  40518. * @returns a UniformBuffer
  40519. */
  40520. getSceneUniformBuffer(): UniformBuffer;
  40521. /**
  40522. * Gets an unique (relatively to the current scene) Id
  40523. * @returns an unique number for the scene
  40524. */
  40525. getUniqueId(): number;
  40526. /**
  40527. * Add a mesh to the list of scene's meshes
  40528. * @param newMesh defines the mesh to add
  40529. * @param recursive if all child meshes should also be added to the scene
  40530. */
  40531. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40532. /**
  40533. * Remove a mesh for the list of scene's meshes
  40534. * @param toRemove defines the mesh to remove
  40535. * @param recursive if all child meshes should also be removed from the scene
  40536. * @returns the index where the mesh was in the mesh list
  40537. */
  40538. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40539. /**
  40540. * Add a transform node to the list of scene's transform nodes
  40541. * @param newTransformNode defines the transform node to add
  40542. */
  40543. addTransformNode(newTransformNode: TransformNode): void;
  40544. /**
  40545. * Remove a transform node for the list of scene's transform nodes
  40546. * @param toRemove defines the transform node to remove
  40547. * @returns the index where the transform node was in the transform node list
  40548. */
  40549. removeTransformNode(toRemove: TransformNode): number;
  40550. /**
  40551. * Remove a skeleton for the list of scene's skeletons
  40552. * @param toRemove defines the skeleton to remove
  40553. * @returns the index where the skeleton was in the skeleton list
  40554. */
  40555. removeSkeleton(toRemove: Skeleton): number;
  40556. /**
  40557. * Remove a morph target for the list of scene's morph targets
  40558. * @param toRemove defines the morph target to remove
  40559. * @returns the index where the morph target was in the morph target list
  40560. */
  40561. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40562. /**
  40563. * Remove a light for the list of scene's lights
  40564. * @param toRemove defines the light to remove
  40565. * @returns the index where the light was in the light list
  40566. */
  40567. removeLight(toRemove: Light): number;
  40568. /**
  40569. * Remove a camera for the list of scene's cameras
  40570. * @param toRemove defines the camera to remove
  40571. * @returns the index where the camera was in the camera list
  40572. */
  40573. removeCamera(toRemove: Camera): number;
  40574. /**
  40575. * Remove a particle system for the list of scene's particle systems
  40576. * @param toRemove defines the particle system to remove
  40577. * @returns the index where the particle system was in the particle system list
  40578. */
  40579. removeParticleSystem(toRemove: IParticleSystem): number;
  40580. /**
  40581. * Remove a animation for the list of scene's animations
  40582. * @param toRemove defines the animation to remove
  40583. * @returns the index where the animation was in the animation list
  40584. */
  40585. removeAnimation(toRemove: Animation): number;
  40586. /**
  40587. * Will stop the animation of the given target
  40588. * @param target - the target
  40589. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40590. * @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)
  40591. */
  40592. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40593. /**
  40594. * Removes the given animation group from this scene.
  40595. * @param toRemove The animation group to remove
  40596. * @returns The index of the removed animation group
  40597. */
  40598. removeAnimationGroup(toRemove: AnimationGroup): number;
  40599. /**
  40600. * Removes the given multi-material from this scene.
  40601. * @param toRemove The multi-material to remove
  40602. * @returns The index of the removed multi-material
  40603. */
  40604. removeMultiMaterial(toRemove: MultiMaterial): number;
  40605. /**
  40606. * Removes the given material from this scene.
  40607. * @param toRemove The material to remove
  40608. * @returns The index of the removed material
  40609. */
  40610. removeMaterial(toRemove: Material): number;
  40611. /**
  40612. * Removes the given action manager from this scene.
  40613. * @param toRemove The action manager to remove
  40614. * @returns The index of the removed action manager
  40615. */
  40616. removeActionManager(toRemove: AbstractActionManager): number;
  40617. /**
  40618. * Removes the given texture from this scene.
  40619. * @param toRemove The texture to remove
  40620. * @returns The index of the removed texture
  40621. */
  40622. removeTexture(toRemove: BaseTexture): number;
  40623. /**
  40624. * Adds the given light to this scene
  40625. * @param newLight The light to add
  40626. */
  40627. addLight(newLight: Light): void;
  40628. /**
  40629. * Sorts the list list based on light priorities
  40630. */
  40631. sortLightsByPriority(): void;
  40632. /**
  40633. * Adds the given camera to this scene
  40634. * @param newCamera The camera to add
  40635. */
  40636. addCamera(newCamera: Camera): void;
  40637. /**
  40638. * Adds the given skeleton to this scene
  40639. * @param newSkeleton The skeleton to add
  40640. */
  40641. addSkeleton(newSkeleton: Skeleton): void;
  40642. /**
  40643. * Adds the given particle system to this scene
  40644. * @param newParticleSystem The particle system to add
  40645. */
  40646. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40647. /**
  40648. * Adds the given animation to this scene
  40649. * @param newAnimation The animation to add
  40650. */
  40651. addAnimation(newAnimation: Animation): void;
  40652. /**
  40653. * Adds the given animation group to this scene.
  40654. * @param newAnimationGroup The animation group to add
  40655. */
  40656. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40657. /**
  40658. * Adds the given multi-material to this scene
  40659. * @param newMultiMaterial The multi-material to add
  40660. */
  40661. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40662. /**
  40663. * Adds the given material to this scene
  40664. * @param newMaterial The material to add
  40665. */
  40666. addMaterial(newMaterial: Material): void;
  40667. /**
  40668. * Adds the given morph target to this scene
  40669. * @param newMorphTargetManager The morph target to add
  40670. */
  40671. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40672. /**
  40673. * Adds the given geometry to this scene
  40674. * @param newGeometry The geometry to add
  40675. */
  40676. addGeometry(newGeometry: Geometry): void;
  40677. /**
  40678. * Adds the given action manager to this scene
  40679. * @param newActionManager The action manager to add
  40680. */
  40681. addActionManager(newActionManager: AbstractActionManager): void;
  40682. /**
  40683. * Adds the given texture to this scene.
  40684. * @param newTexture The texture to add
  40685. */
  40686. addTexture(newTexture: BaseTexture): void;
  40687. /**
  40688. * Switch active camera
  40689. * @param newCamera defines the new active camera
  40690. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40691. */
  40692. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40693. /**
  40694. * sets the active camera of the scene using its ID
  40695. * @param id defines the camera's ID
  40696. * @return the new active camera or null if none found.
  40697. */
  40698. setActiveCameraByID(id: string): Nullable<Camera>;
  40699. /**
  40700. * sets the active camera of the scene using its name
  40701. * @param name defines the camera's name
  40702. * @returns the new active camera or null if none found.
  40703. */
  40704. setActiveCameraByName(name: string): Nullable<Camera>;
  40705. /**
  40706. * get an animation group using its name
  40707. * @param name defines the material's name
  40708. * @return the animation group or null if none found.
  40709. */
  40710. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40711. /**
  40712. * Get a material using its unique id
  40713. * @param uniqueId defines the material's unique id
  40714. * @return the material or null if none found.
  40715. */
  40716. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40717. /**
  40718. * get a material using its id
  40719. * @param id defines the material's ID
  40720. * @return the material or null if none found.
  40721. */
  40722. getMaterialByID(id: string): Nullable<Material>;
  40723. /**
  40724. * Gets a the last added material using a given id
  40725. * @param id defines the material's ID
  40726. * @return the last material with the given id or null if none found.
  40727. */
  40728. getLastMaterialByID(id: string): Nullable<Material>;
  40729. /**
  40730. * Gets a material using its name
  40731. * @param name defines the material's name
  40732. * @return the material or null if none found.
  40733. */
  40734. getMaterialByName(name: string): Nullable<Material>;
  40735. /**
  40736. * Get a texture using its unique id
  40737. * @param uniqueId defines the texture's unique id
  40738. * @return the texture or null if none found.
  40739. */
  40740. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40741. /**
  40742. * Gets a camera using its id
  40743. * @param id defines the id to look for
  40744. * @returns the camera or null if not found
  40745. */
  40746. getCameraByID(id: string): Nullable<Camera>;
  40747. /**
  40748. * Gets a camera using its unique id
  40749. * @param uniqueId defines the unique id to look for
  40750. * @returns the camera or null if not found
  40751. */
  40752. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40753. /**
  40754. * Gets a camera using its name
  40755. * @param name defines the camera's name
  40756. * @return the camera or null if none found.
  40757. */
  40758. getCameraByName(name: string): Nullable<Camera>;
  40759. /**
  40760. * Gets a bone using its id
  40761. * @param id defines the bone's id
  40762. * @return the bone or null if not found
  40763. */
  40764. getBoneByID(id: string): Nullable<Bone>;
  40765. /**
  40766. * Gets a bone using its id
  40767. * @param name defines the bone's name
  40768. * @return the bone or null if not found
  40769. */
  40770. getBoneByName(name: string): Nullable<Bone>;
  40771. /**
  40772. * Gets a light node using its name
  40773. * @param name defines the the light's name
  40774. * @return the light or null if none found.
  40775. */
  40776. getLightByName(name: string): Nullable<Light>;
  40777. /**
  40778. * Gets a light node using its id
  40779. * @param id defines the light's id
  40780. * @return the light or null if none found.
  40781. */
  40782. getLightByID(id: string): Nullable<Light>;
  40783. /**
  40784. * Gets a light node using its scene-generated unique ID
  40785. * @param uniqueId defines the light's unique id
  40786. * @return the light or null if none found.
  40787. */
  40788. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40789. /**
  40790. * Gets a particle system by id
  40791. * @param id defines the particle system id
  40792. * @return the corresponding system or null if none found
  40793. */
  40794. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40795. /**
  40796. * Gets a geometry using its ID
  40797. * @param id defines the geometry's id
  40798. * @return the geometry or null if none found.
  40799. */
  40800. getGeometryByID(id: string): Nullable<Geometry>;
  40801. private _getGeometryByUniqueID;
  40802. /**
  40803. * Add a new geometry to this scene
  40804. * @param geometry defines the geometry to be added to the scene.
  40805. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40806. * @return a boolean defining if the geometry was added or not
  40807. */
  40808. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40809. /**
  40810. * Removes an existing geometry
  40811. * @param geometry defines the geometry to be removed from the scene
  40812. * @return a boolean defining if the geometry was removed or not
  40813. */
  40814. removeGeometry(geometry: Geometry): boolean;
  40815. /**
  40816. * Gets the list of geometries attached to the scene
  40817. * @returns an array of Geometry
  40818. */
  40819. getGeometries(): Geometry[];
  40820. /**
  40821. * Gets the first added mesh found of a given ID
  40822. * @param id defines the id to search for
  40823. * @return the mesh found or null if not found at all
  40824. */
  40825. getMeshByID(id: string): Nullable<AbstractMesh>;
  40826. /**
  40827. * Gets a list of meshes using their id
  40828. * @param id defines the id to search for
  40829. * @returns a list of meshes
  40830. */
  40831. getMeshesByID(id: string): Array<AbstractMesh>;
  40832. /**
  40833. * Gets the first added transform node found of a given ID
  40834. * @param id defines the id to search for
  40835. * @return the found transform node or null if not found at all.
  40836. */
  40837. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40838. /**
  40839. * Gets a transform node with its auto-generated unique id
  40840. * @param uniqueId efines the unique id to search for
  40841. * @return the found transform node or null if not found at all.
  40842. */
  40843. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40844. /**
  40845. * Gets a list of transform nodes using their id
  40846. * @param id defines the id to search for
  40847. * @returns a list of transform nodes
  40848. */
  40849. getTransformNodesByID(id: string): Array<TransformNode>;
  40850. /**
  40851. * Gets a mesh with its auto-generated unique id
  40852. * @param uniqueId defines the unique id to search for
  40853. * @return the found mesh or null if not found at all.
  40854. */
  40855. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40856. /**
  40857. * Gets a the last added mesh using a given id
  40858. * @param id defines the id to search for
  40859. * @return the found mesh or null if not found at all.
  40860. */
  40861. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40862. /**
  40863. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40864. * @param id defines the id to search for
  40865. * @return the found node or null if not found at all
  40866. */
  40867. getLastEntryByID(id: string): Nullable<Node>;
  40868. /**
  40869. * Gets a node (Mesh, Camera, Light) using a given id
  40870. * @param id defines the id to search for
  40871. * @return the found node or null if not found at all
  40872. */
  40873. getNodeByID(id: string): Nullable<Node>;
  40874. /**
  40875. * Gets a node (Mesh, Camera, Light) using a given name
  40876. * @param name defines the name to search for
  40877. * @return the found node or null if not found at all.
  40878. */
  40879. getNodeByName(name: string): Nullable<Node>;
  40880. /**
  40881. * Gets a mesh using a given name
  40882. * @param name defines the name to search for
  40883. * @return the found mesh or null if not found at all.
  40884. */
  40885. getMeshByName(name: string): Nullable<AbstractMesh>;
  40886. /**
  40887. * Gets a transform node using a given name
  40888. * @param name defines the name to search for
  40889. * @return the found transform node or null if not found at all.
  40890. */
  40891. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40892. /**
  40893. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40894. * @param id defines the id to search for
  40895. * @return the found skeleton or null if not found at all.
  40896. */
  40897. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40898. /**
  40899. * Gets a skeleton using a given auto generated unique id
  40900. * @param uniqueId defines the unique id to search for
  40901. * @return the found skeleton or null if not found at all.
  40902. */
  40903. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40904. /**
  40905. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40906. * @param id defines the id to search for
  40907. * @return the found skeleton or null if not found at all.
  40908. */
  40909. getSkeletonById(id: string): Nullable<Skeleton>;
  40910. /**
  40911. * Gets a skeleton using a given name
  40912. * @param name defines the name to search for
  40913. * @return the found skeleton or null if not found at all.
  40914. */
  40915. getSkeletonByName(name: string): Nullable<Skeleton>;
  40916. /**
  40917. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40918. * @param id defines the id to search for
  40919. * @return the found morph target manager or null if not found at all.
  40920. */
  40921. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40922. /**
  40923. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40924. * @param id defines the id to search for
  40925. * @return the found morph target or null if not found at all.
  40926. */
  40927. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40928. /**
  40929. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40930. * @param name defines the name to search for
  40931. * @return the found morph target or null if not found at all.
  40932. */
  40933. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40934. /**
  40935. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40936. * @param name defines the name to search for
  40937. * @return the found post process or null if not found at all.
  40938. */
  40939. getPostProcessByName(name: string): Nullable<PostProcess>;
  40940. /**
  40941. * Gets a boolean indicating if the given mesh is active
  40942. * @param mesh defines the mesh to look for
  40943. * @returns true if the mesh is in the active list
  40944. */
  40945. isActiveMesh(mesh: AbstractMesh): boolean;
  40946. /**
  40947. * Return a unique id as a string which can serve as an identifier for the scene
  40948. */
  40949. get uid(): string;
  40950. /**
  40951. * Add an externaly attached data from its key.
  40952. * This method call will fail and return false, if such key already exists.
  40953. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40954. * @param key the unique key that identifies the data
  40955. * @param data the data object to associate to the key for this Engine instance
  40956. * @return true if no such key were already present and the data was added successfully, false otherwise
  40957. */
  40958. addExternalData<T>(key: string, data: T): boolean;
  40959. /**
  40960. * Get an externaly attached data from its key
  40961. * @param key the unique key that identifies the data
  40962. * @return the associated data, if present (can be null), or undefined if not present
  40963. */
  40964. getExternalData<T>(key: string): Nullable<T>;
  40965. /**
  40966. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40967. * @param key the unique key that identifies the data
  40968. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40969. * @return the associated data, can be null if the factory returned null.
  40970. */
  40971. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40972. /**
  40973. * Remove an externaly attached data from the Engine instance
  40974. * @param key the unique key that identifies the data
  40975. * @return true if the data was successfully removed, false if it doesn't exist
  40976. */
  40977. removeExternalData(key: string): boolean;
  40978. private _evaluateSubMesh;
  40979. /**
  40980. * Clear the processed materials smart array preventing retention point in material dispose.
  40981. */
  40982. freeProcessedMaterials(): void;
  40983. private _preventFreeActiveMeshesAndRenderingGroups;
  40984. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40985. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40986. * when disposing several meshes in a row or a hierarchy of meshes.
  40987. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40988. */
  40989. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40990. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40991. /**
  40992. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40993. */
  40994. freeActiveMeshes(): void;
  40995. /**
  40996. * Clear the info related to rendering groups preventing retention points during dispose.
  40997. */
  40998. freeRenderingGroups(): void;
  40999. /** @hidden */
  41000. _isInIntermediateRendering(): boolean;
  41001. /**
  41002. * Lambda returning the list of potentially active meshes.
  41003. */
  41004. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41005. /**
  41006. * Lambda returning the list of potentially active sub meshes.
  41007. */
  41008. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41009. /**
  41010. * Lambda returning the list of potentially intersecting sub meshes.
  41011. */
  41012. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41013. /**
  41014. * Lambda returning the list of potentially colliding sub meshes.
  41015. */
  41016. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41017. private _activeMeshesFrozen;
  41018. private _skipEvaluateActiveMeshesCompletely;
  41019. /**
  41020. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41021. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41022. * @returns the current scene
  41023. */
  41024. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41025. /**
  41026. * Use this function to restart evaluating active meshes on every frame
  41027. * @returns the current scene
  41028. */
  41029. unfreezeActiveMeshes(): Scene;
  41030. private _evaluateActiveMeshes;
  41031. private _activeMesh;
  41032. /**
  41033. * Update the transform matrix to update from the current active camera
  41034. * @param force defines a boolean used to force the update even if cache is up to date
  41035. */
  41036. updateTransformMatrix(force?: boolean): void;
  41037. private _bindFrameBuffer;
  41038. /** @hidden */
  41039. _allowPostProcessClearColor: boolean;
  41040. /** @hidden */
  41041. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41042. private _processSubCameras;
  41043. private _checkIntersections;
  41044. /** @hidden */
  41045. _advancePhysicsEngineStep(step: number): void;
  41046. /**
  41047. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41048. */
  41049. getDeterministicFrameTime: () => number;
  41050. /** @hidden */
  41051. _animate(): void;
  41052. /** Execute all animations (for a frame) */
  41053. animate(): void;
  41054. /**
  41055. * Render the scene
  41056. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41057. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41058. */
  41059. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41060. /**
  41061. * Freeze all materials
  41062. * A frozen material will not be updatable but should be faster to render
  41063. */
  41064. freezeMaterials(): void;
  41065. /**
  41066. * Unfreeze all materials
  41067. * A frozen material will not be updatable but should be faster to render
  41068. */
  41069. unfreezeMaterials(): void;
  41070. /**
  41071. * Releases all held ressources
  41072. */
  41073. dispose(): void;
  41074. /**
  41075. * Gets if the scene is already disposed
  41076. */
  41077. get isDisposed(): boolean;
  41078. /**
  41079. * Call this function to reduce memory footprint of the scene.
  41080. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41081. */
  41082. clearCachedVertexData(): void;
  41083. /**
  41084. * This function will remove the local cached buffer data from texture.
  41085. * It will save memory but will prevent the texture from being rebuilt
  41086. */
  41087. cleanCachedTextureBuffer(): void;
  41088. /**
  41089. * Get the world extend vectors with an optional filter
  41090. *
  41091. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41092. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41093. */
  41094. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41095. min: Vector3;
  41096. max: Vector3;
  41097. };
  41098. /**
  41099. * Creates a ray that can be used to pick in the scene
  41100. * @param x defines the x coordinate of the origin (on-screen)
  41101. * @param y defines the y coordinate of the origin (on-screen)
  41102. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41103. * @param camera defines the camera to use for the picking
  41104. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41105. * @returns a Ray
  41106. */
  41107. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41108. /**
  41109. * Creates a ray that can be used to pick in the scene
  41110. * @param x defines the x coordinate of the origin (on-screen)
  41111. * @param y defines the y coordinate of the origin (on-screen)
  41112. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41113. * @param result defines the ray where to store the picking ray
  41114. * @param camera defines the camera to use for the picking
  41115. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41116. * @returns the current scene
  41117. */
  41118. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41119. /**
  41120. * Creates a ray that can be used to pick in the scene
  41121. * @param x defines the x coordinate of the origin (on-screen)
  41122. * @param y defines the y coordinate of the origin (on-screen)
  41123. * @param camera defines the camera to use for the picking
  41124. * @returns a Ray
  41125. */
  41126. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41127. /**
  41128. * Creates a ray that can be used to pick in the scene
  41129. * @param x defines the x coordinate of the origin (on-screen)
  41130. * @param y defines the y coordinate of the origin (on-screen)
  41131. * @param result defines the ray where to store the picking ray
  41132. * @param camera defines the camera to use for the picking
  41133. * @returns the current scene
  41134. */
  41135. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41136. /** Launch a ray to try to pick a mesh in the scene
  41137. * @param x position on screen
  41138. * @param y position on screen
  41139. * @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
  41140. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41141. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41142. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41143. * @returns a PickingInfo
  41144. */
  41145. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41146. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41147. * @param x position on screen
  41148. * @param y position on screen
  41149. * @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
  41150. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41151. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41152. * @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)
  41153. */
  41154. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41155. /** Use the given ray to pick a mesh in the scene
  41156. * @param ray The ray to use to pick meshes
  41157. * @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
  41158. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41159. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41160. * @returns a PickingInfo
  41161. */
  41162. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41163. /**
  41164. * Launch a ray to try to pick a mesh in the scene
  41165. * @param x X position on screen
  41166. * @param y Y position on screen
  41167. * @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
  41168. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41169. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41170. * @returns an array of PickingInfo
  41171. */
  41172. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41173. /**
  41174. * Launch a ray to try to pick a mesh in the scene
  41175. * @param ray Ray to use
  41176. * @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
  41177. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41178. * @returns an array of PickingInfo
  41179. */
  41180. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41181. /**
  41182. * Force the value of meshUnderPointer
  41183. * @param mesh defines the mesh to use
  41184. * @param pointerId optional pointer id when using more than one pointer
  41185. */
  41186. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41187. /**
  41188. * Gets the mesh under the pointer
  41189. * @returns a Mesh or null if no mesh is under the pointer
  41190. */
  41191. getPointerOverMesh(): Nullable<AbstractMesh>;
  41192. /** @hidden */
  41193. _rebuildGeometries(): void;
  41194. /** @hidden */
  41195. _rebuildTextures(): void;
  41196. private _getByTags;
  41197. /**
  41198. * Get a list of meshes by tags
  41199. * @param tagsQuery defines the tags query to use
  41200. * @param forEach defines a predicate used to filter results
  41201. * @returns an array of Mesh
  41202. */
  41203. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41204. /**
  41205. * Get a list of cameras by tags
  41206. * @param tagsQuery defines the tags query to use
  41207. * @param forEach defines a predicate used to filter results
  41208. * @returns an array of Camera
  41209. */
  41210. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41211. /**
  41212. * Get a list of lights by tags
  41213. * @param tagsQuery defines the tags query to use
  41214. * @param forEach defines a predicate used to filter results
  41215. * @returns an array of Light
  41216. */
  41217. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41218. /**
  41219. * Get a list of materials by tags
  41220. * @param tagsQuery defines the tags query to use
  41221. * @param forEach defines a predicate used to filter results
  41222. * @returns an array of Material
  41223. */
  41224. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41225. /**
  41226. * Get a list of transform nodes by tags
  41227. * @param tagsQuery defines the tags query to use
  41228. * @param forEach defines a predicate used to filter results
  41229. * @returns an array of TransformNode
  41230. */
  41231. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41232. /**
  41233. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41234. * This allowed control for front to back rendering or reversly depending of the special needs.
  41235. *
  41236. * @param renderingGroupId The rendering group id corresponding to its index
  41237. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41238. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41239. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41240. */
  41241. 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;
  41242. /**
  41243. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41244. *
  41245. * @param renderingGroupId The rendering group id corresponding to its index
  41246. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41247. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41248. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41249. */
  41250. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41251. /**
  41252. * Gets the current auto clear configuration for one rendering group of the rendering
  41253. * manager.
  41254. * @param index the rendering group index to get the information for
  41255. * @returns The auto clear setup for the requested rendering group
  41256. */
  41257. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41258. private _blockMaterialDirtyMechanism;
  41259. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41260. get blockMaterialDirtyMechanism(): boolean;
  41261. set blockMaterialDirtyMechanism(value: boolean);
  41262. /**
  41263. * Will flag all materials as dirty to trigger new shader compilation
  41264. * @param flag defines the flag used to specify which material part must be marked as dirty
  41265. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41266. */
  41267. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41268. /** @hidden */
  41269. _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;
  41270. /** @hidden */
  41271. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41272. /** @hidden */
  41273. _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;
  41274. /** @hidden */
  41275. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41276. /** @hidden */
  41277. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41278. /** @hidden */
  41279. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41280. }
  41281. }
  41282. declare module BABYLON {
  41283. /**
  41284. * Set of assets to keep when moving a scene into an asset container.
  41285. */
  41286. export class KeepAssets extends AbstractScene {
  41287. }
  41288. /**
  41289. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41290. */
  41291. export class InstantiatedEntries {
  41292. /**
  41293. * List of new root nodes (eg. nodes with no parent)
  41294. */
  41295. rootNodes: TransformNode[];
  41296. /**
  41297. * List of new skeletons
  41298. */
  41299. skeletons: Skeleton[];
  41300. /**
  41301. * List of new animation groups
  41302. */
  41303. animationGroups: AnimationGroup[];
  41304. }
  41305. /**
  41306. * Container with a set of assets that can be added or removed from a scene.
  41307. */
  41308. export class AssetContainer extends AbstractScene {
  41309. private _wasAddedToScene;
  41310. /**
  41311. * The scene the AssetContainer belongs to.
  41312. */
  41313. scene: Scene;
  41314. /**
  41315. * Instantiates an AssetContainer.
  41316. * @param scene The scene the AssetContainer belongs to.
  41317. */
  41318. constructor(scene: Scene);
  41319. /**
  41320. * Instantiate or clone all meshes and add the new ones to the scene.
  41321. * Skeletons and animation groups will all be cloned
  41322. * @param nameFunction defines an optional function used to get new names for clones
  41323. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41324. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41325. */
  41326. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41327. /**
  41328. * Adds all the assets from the container to the scene.
  41329. */
  41330. addAllToScene(): void;
  41331. /**
  41332. * Removes all the assets in the container from the scene
  41333. */
  41334. removeAllFromScene(): void;
  41335. /**
  41336. * Disposes all the assets in the container
  41337. */
  41338. dispose(): void;
  41339. private _moveAssets;
  41340. /**
  41341. * Removes all the assets contained in the scene and adds them to the container.
  41342. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41343. */
  41344. moveAllFromScene(keepAssets?: KeepAssets): void;
  41345. /**
  41346. * 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.
  41347. * @returns the root mesh
  41348. */
  41349. createRootMesh(): Mesh;
  41350. /**
  41351. * Merge animations (direct and animation groups) from this asset container into a scene
  41352. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41353. * @param animatables set of animatables to retarget to a node from the scene
  41354. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41355. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41356. */
  41357. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41358. }
  41359. }
  41360. declare module BABYLON {
  41361. /**
  41362. * Defines how the parser contract is defined.
  41363. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41364. */
  41365. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41366. /**
  41367. * Defines how the individual parser contract is defined.
  41368. * These parser can parse an individual asset
  41369. */
  41370. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41371. /**
  41372. * Base class of the scene acting as a container for the different elements composing a scene.
  41373. * This class is dynamically extended by the different components of the scene increasing
  41374. * flexibility and reducing coupling
  41375. */
  41376. export abstract class AbstractScene {
  41377. /**
  41378. * Stores the list of available parsers in the application.
  41379. */
  41380. private static _BabylonFileParsers;
  41381. /**
  41382. * Stores the list of available individual parsers in the application.
  41383. */
  41384. private static _IndividualBabylonFileParsers;
  41385. /**
  41386. * Adds a parser in the list of available ones
  41387. * @param name Defines the name of the parser
  41388. * @param parser Defines the parser to add
  41389. */
  41390. static AddParser(name: string, parser: BabylonFileParser): void;
  41391. /**
  41392. * Gets a general parser from the list of avaialble ones
  41393. * @param name Defines the name of the parser
  41394. * @returns the requested parser or null
  41395. */
  41396. static GetParser(name: string): Nullable<BabylonFileParser>;
  41397. /**
  41398. * Adds n individual parser in the list of available ones
  41399. * @param name Defines the name of the parser
  41400. * @param parser Defines the parser to add
  41401. */
  41402. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41403. /**
  41404. * Gets an individual parser from the list of avaialble ones
  41405. * @param name Defines the name of the parser
  41406. * @returns the requested parser or null
  41407. */
  41408. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41409. /**
  41410. * Parser json data and populate both a scene and its associated container object
  41411. * @param jsonData Defines the data to parse
  41412. * @param scene Defines the scene to parse the data for
  41413. * @param container Defines the container attached to the parsing sequence
  41414. * @param rootUrl Defines the root url of the data
  41415. */
  41416. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41417. /**
  41418. * Gets the list of root nodes (ie. nodes with no parent)
  41419. */
  41420. rootNodes: Node[];
  41421. /** All of the cameras added to this scene
  41422. * @see https://doc.babylonjs.com/babylon101/cameras
  41423. */
  41424. cameras: Camera[];
  41425. /**
  41426. * All of the lights added to this scene
  41427. * @see https://doc.babylonjs.com/babylon101/lights
  41428. */
  41429. lights: Light[];
  41430. /**
  41431. * All of the (abstract) meshes added to this scene
  41432. */
  41433. meshes: AbstractMesh[];
  41434. /**
  41435. * The list of skeletons added to the scene
  41436. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41437. */
  41438. skeletons: Skeleton[];
  41439. /**
  41440. * All of the particle systems added to this scene
  41441. * @see https://doc.babylonjs.com/babylon101/particles
  41442. */
  41443. particleSystems: IParticleSystem[];
  41444. /**
  41445. * Gets a list of Animations associated with the scene
  41446. */
  41447. animations: Animation[];
  41448. /**
  41449. * All of the animation groups added to this scene
  41450. * @see https://doc.babylonjs.com/how_to/group
  41451. */
  41452. animationGroups: AnimationGroup[];
  41453. /**
  41454. * All of the multi-materials added to this scene
  41455. * @see https://doc.babylonjs.com/how_to/multi_materials
  41456. */
  41457. multiMaterials: MultiMaterial[];
  41458. /**
  41459. * All of the materials added to this scene
  41460. * In the context of a Scene, it is not supposed to be modified manually.
  41461. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41462. * Note also that the order of the Material within the array is not significant and might change.
  41463. * @see https://doc.babylonjs.com/babylon101/materials
  41464. */
  41465. materials: Material[];
  41466. /**
  41467. * The list of morph target managers added to the scene
  41468. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41469. */
  41470. morphTargetManagers: MorphTargetManager[];
  41471. /**
  41472. * The list of geometries used in the scene.
  41473. */
  41474. geometries: Geometry[];
  41475. /**
  41476. * All of the tranform nodes added to this scene
  41477. * In the context of a Scene, it is not supposed to be modified manually.
  41478. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41479. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41480. * @see https://doc.babylonjs.com/how_to/transformnode
  41481. */
  41482. transformNodes: TransformNode[];
  41483. /**
  41484. * ActionManagers available on the scene.
  41485. */
  41486. actionManagers: AbstractActionManager[];
  41487. /**
  41488. * Textures to keep.
  41489. */
  41490. textures: BaseTexture[];
  41491. /** @hidden */
  41492. protected _environmentTexture: Nullable<BaseTexture>;
  41493. /**
  41494. * Texture used in all pbr material as the reflection texture.
  41495. * As in the majority of the scene they are the same (exception for multi room and so on),
  41496. * this is easier to reference from here than from all the materials.
  41497. */
  41498. get environmentTexture(): Nullable<BaseTexture>;
  41499. set environmentTexture(value: Nullable<BaseTexture>);
  41500. /**
  41501. * The list of postprocesses added to the scene
  41502. */
  41503. postProcesses: PostProcess[];
  41504. /**
  41505. * @returns all meshes, lights, cameras, transformNodes and bones
  41506. */
  41507. getNodes(): Array<Node>;
  41508. }
  41509. }
  41510. declare module BABYLON {
  41511. /**
  41512. * Interface used to define options for Sound class
  41513. */
  41514. export interface ISoundOptions {
  41515. /**
  41516. * Does the sound autoplay once loaded.
  41517. */
  41518. autoplay?: boolean;
  41519. /**
  41520. * Does the sound loop after it finishes playing once.
  41521. */
  41522. loop?: boolean;
  41523. /**
  41524. * Sound's volume
  41525. */
  41526. volume?: number;
  41527. /**
  41528. * Is it a spatial sound?
  41529. */
  41530. spatialSound?: boolean;
  41531. /**
  41532. * Maximum distance to hear that sound
  41533. */
  41534. maxDistance?: number;
  41535. /**
  41536. * Uses user defined attenuation function
  41537. */
  41538. useCustomAttenuation?: boolean;
  41539. /**
  41540. * Define the roll off factor of spatial sounds.
  41541. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41542. */
  41543. rolloffFactor?: number;
  41544. /**
  41545. * Define the reference distance the sound should be heard perfectly.
  41546. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41547. */
  41548. refDistance?: number;
  41549. /**
  41550. * Define the distance attenuation model the sound will follow.
  41551. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41552. */
  41553. distanceModel?: string;
  41554. /**
  41555. * Defines the playback speed (1 by default)
  41556. */
  41557. playbackRate?: number;
  41558. /**
  41559. * Defines if the sound is from a streaming source
  41560. */
  41561. streaming?: boolean;
  41562. /**
  41563. * Defines an optional length (in seconds) inside the sound file
  41564. */
  41565. length?: number;
  41566. /**
  41567. * Defines an optional offset (in seconds) inside the sound file
  41568. */
  41569. offset?: number;
  41570. /**
  41571. * If true, URLs will not be required to state the audio file codec to use.
  41572. */
  41573. skipCodecCheck?: boolean;
  41574. }
  41575. /**
  41576. * Defines a sound that can be played in the application.
  41577. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41578. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41579. */
  41580. export class Sound {
  41581. /**
  41582. * The name of the sound in the scene.
  41583. */
  41584. name: string;
  41585. /**
  41586. * Does the sound autoplay once loaded.
  41587. */
  41588. autoplay: boolean;
  41589. /**
  41590. * Does the sound loop after it finishes playing once.
  41591. */
  41592. loop: boolean;
  41593. /**
  41594. * Does the sound use a custom attenuation curve to simulate the falloff
  41595. * happening when the source gets further away from the camera.
  41596. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41597. */
  41598. useCustomAttenuation: boolean;
  41599. /**
  41600. * The sound track id this sound belongs to.
  41601. */
  41602. soundTrackId: number;
  41603. /**
  41604. * Is this sound currently played.
  41605. */
  41606. isPlaying: boolean;
  41607. /**
  41608. * Is this sound currently paused.
  41609. */
  41610. isPaused: boolean;
  41611. /**
  41612. * Does this sound enables spatial sound.
  41613. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41614. */
  41615. spatialSound: boolean;
  41616. /**
  41617. * Define the reference distance the sound should be heard perfectly.
  41618. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41619. */
  41620. refDistance: number;
  41621. /**
  41622. * Define the roll off factor of spatial sounds.
  41623. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41624. */
  41625. rolloffFactor: number;
  41626. /**
  41627. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41628. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41629. */
  41630. maxDistance: number;
  41631. /**
  41632. * Define the distance attenuation model the sound will follow.
  41633. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41634. */
  41635. distanceModel: string;
  41636. /**
  41637. * @hidden
  41638. * Back Compat
  41639. **/
  41640. onended: () => any;
  41641. /**
  41642. * Gets or sets an object used to store user defined information for the sound.
  41643. */
  41644. metadata: any;
  41645. /**
  41646. * Observable event when the current playing sound finishes.
  41647. */
  41648. onEndedObservable: Observable<Sound>;
  41649. private _panningModel;
  41650. private _playbackRate;
  41651. private _streaming;
  41652. private _startTime;
  41653. private _startOffset;
  41654. private _position;
  41655. /** @hidden */
  41656. _positionInEmitterSpace: boolean;
  41657. private _localDirection;
  41658. private _volume;
  41659. private _isReadyToPlay;
  41660. private _isDirectional;
  41661. private _readyToPlayCallback;
  41662. private _audioBuffer;
  41663. private _soundSource;
  41664. private _streamingSource;
  41665. private _soundPanner;
  41666. private _soundGain;
  41667. private _inputAudioNode;
  41668. private _outputAudioNode;
  41669. private _coneInnerAngle;
  41670. private _coneOuterAngle;
  41671. private _coneOuterGain;
  41672. private _scene;
  41673. private _connectedTransformNode;
  41674. private _customAttenuationFunction;
  41675. private _registerFunc;
  41676. private _isOutputConnected;
  41677. private _htmlAudioElement;
  41678. private _urlType;
  41679. private _length?;
  41680. private _offset?;
  41681. /** @hidden */
  41682. static _SceneComponentInitialization: (scene: Scene) => void;
  41683. /**
  41684. * Create a sound and attach it to a scene
  41685. * @param name Name of your sound
  41686. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41687. * @param scene defines the scene the sound belongs to
  41688. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41689. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41690. */
  41691. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41692. /**
  41693. * Release the sound and its associated resources
  41694. */
  41695. dispose(): void;
  41696. /**
  41697. * Gets if the sounds is ready to be played or not.
  41698. * @returns true if ready, otherwise false
  41699. */
  41700. isReady(): boolean;
  41701. private _soundLoaded;
  41702. /**
  41703. * Sets the data of the sound from an audiobuffer
  41704. * @param audioBuffer The audioBuffer containing the data
  41705. */
  41706. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41707. /**
  41708. * Updates the current sounds options such as maxdistance, loop...
  41709. * @param options A JSON object containing values named as the object properties
  41710. */
  41711. updateOptions(options: ISoundOptions): void;
  41712. private _createSpatialParameters;
  41713. private _updateSpatialParameters;
  41714. /**
  41715. * Switch the panning model to HRTF:
  41716. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41717. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41718. */
  41719. switchPanningModelToHRTF(): void;
  41720. /**
  41721. * Switch the panning model to Equal Power:
  41722. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41723. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41724. */
  41725. switchPanningModelToEqualPower(): void;
  41726. private _switchPanningModel;
  41727. /**
  41728. * Connect this sound to a sound track audio node like gain...
  41729. * @param soundTrackAudioNode the sound track audio node to connect to
  41730. */
  41731. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41732. /**
  41733. * Transform this sound into a directional source
  41734. * @param coneInnerAngle Size of the inner cone in degree
  41735. * @param coneOuterAngle Size of the outer cone in degree
  41736. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41737. */
  41738. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41739. /**
  41740. * Gets or sets the inner angle for the directional cone.
  41741. */
  41742. get directionalConeInnerAngle(): number;
  41743. /**
  41744. * Gets or sets the inner angle for the directional cone.
  41745. */
  41746. set directionalConeInnerAngle(value: number);
  41747. /**
  41748. * Gets or sets the outer angle for the directional cone.
  41749. */
  41750. get directionalConeOuterAngle(): number;
  41751. /**
  41752. * Gets or sets the outer angle for the directional cone.
  41753. */
  41754. set directionalConeOuterAngle(value: number);
  41755. /**
  41756. * Sets the position of the emitter if spatial sound is enabled
  41757. * @param newPosition Defines the new posisiton
  41758. */
  41759. setPosition(newPosition: Vector3): void;
  41760. /**
  41761. * Sets the local direction of the emitter if spatial sound is enabled
  41762. * @param newLocalDirection Defines the new local direction
  41763. */
  41764. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41765. private _updateDirection;
  41766. /** @hidden */
  41767. updateDistanceFromListener(): void;
  41768. /**
  41769. * Sets a new custom attenuation function for the sound.
  41770. * @param callback Defines the function used for the attenuation
  41771. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41772. */
  41773. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41774. /**
  41775. * Play the sound
  41776. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41777. * @param offset (optional) Start the sound at a specific time in seconds
  41778. * @param length (optional) Sound duration (in seconds)
  41779. */
  41780. play(time?: number, offset?: number, length?: number): void;
  41781. private _onended;
  41782. /**
  41783. * Stop the sound
  41784. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41785. */
  41786. stop(time?: number): void;
  41787. /**
  41788. * Put the sound in pause
  41789. */
  41790. pause(): void;
  41791. /**
  41792. * Sets a dedicated volume for this sounds
  41793. * @param newVolume Define the new volume of the sound
  41794. * @param time Define time for gradual change to new volume
  41795. */
  41796. setVolume(newVolume: number, time?: number): void;
  41797. /**
  41798. * Set the sound play back rate
  41799. * @param newPlaybackRate Define the playback rate the sound should be played at
  41800. */
  41801. setPlaybackRate(newPlaybackRate: number): void;
  41802. /**
  41803. * Gets the volume of the sound.
  41804. * @returns the volume of the sound
  41805. */
  41806. getVolume(): number;
  41807. /**
  41808. * Attach the sound to a dedicated mesh
  41809. * @param transformNode The transform node to connect the sound with
  41810. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41811. */
  41812. attachToMesh(transformNode: TransformNode): void;
  41813. /**
  41814. * Detach the sound from the previously attached mesh
  41815. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41816. */
  41817. detachFromMesh(): void;
  41818. private _onRegisterAfterWorldMatrixUpdate;
  41819. /**
  41820. * Clone the current sound in the scene.
  41821. * @returns the new sound clone
  41822. */
  41823. clone(): Nullable<Sound>;
  41824. /**
  41825. * Gets the current underlying audio buffer containing the data
  41826. * @returns the audio buffer
  41827. */
  41828. getAudioBuffer(): Nullable<AudioBuffer>;
  41829. /**
  41830. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41831. * @returns the source node
  41832. */
  41833. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41834. /**
  41835. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41836. * @returns the gain node
  41837. */
  41838. getSoundGain(): Nullable<GainNode>;
  41839. /**
  41840. * Serializes the Sound in a JSON representation
  41841. * @returns the JSON representation of the sound
  41842. */
  41843. serialize(): any;
  41844. /**
  41845. * Parse a JSON representation of a sound to innstantiate in a given scene
  41846. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41847. * @param scene Define the scene the new parsed sound should be created in
  41848. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41849. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41850. * @returns the newly parsed sound
  41851. */
  41852. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41853. }
  41854. }
  41855. declare module BABYLON {
  41856. /**
  41857. * This defines an action helpful to play a defined sound on a triggered action.
  41858. */
  41859. export class PlaySoundAction extends Action {
  41860. private _sound;
  41861. /**
  41862. * Instantiate the action
  41863. * @param triggerOptions defines the trigger options
  41864. * @param sound defines the sound to play
  41865. * @param condition defines the trigger related conditions
  41866. */
  41867. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41868. /** @hidden */
  41869. _prepare(): void;
  41870. /**
  41871. * Execute the action and play the sound.
  41872. */
  41873. execute(): void;
  41874. /**
  41875. * Serializes the actions and its related information.
  41876. * @param parent defines the object to serialize in
  41877. * @returns the serialized object
  41878. */
  41879. serialize(parent: any): any;
  41880. }
  41881. /**
  41882. * This defines an action helpful to stop a defined sound on a triggered action.
  41883. */
  41884. export class StopSoundAction extends Action {
  41885. private _sound;
  41886. /**
  41887. * Instantiate the action
  41888. * @param triggerOptions defines the trigger options
  41889. * @param sound defines the sound to stop
  41890. * @param condition defines the trigger related conditions
  41891. */
  41892. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41893. /** @hidden */
  41894. _prepare(): void;
  41895. /**
  41896. * Execute the action and stop the sound.
  41897. */
  41898. execute(): void;
  41899. /**
  41900. * Serializes the actions and its related information.
  41901. * @param parent defines the object to serialize in
  41902. * @returns the serialized object
  41903. */
  41904. serialize(parent: any): any;
  41905. }
  41906. }
  41907. declare module BABYLON {
  41908. /**
  41909. * This defines an action responsible to change the value of a property
  41910. * by interpolating between its current value and the newly set one once triggered.
  41911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41912. */
  41913. export class InterpolateValueAction extends Action {
  41914. /**
  41915. * Defines the path of the property where the value should be interpolated
  41916. */
  41917. propertyPath: string;
  41918. /**
  41919. * Defines the target value at the end of the interpolation.
  41920. */
  41921. value: any;
  41922. /**
  41923. * Defines the time it will take for the property to interpolate to the value.
  41924. */
  41925. duration: number;
  41926. /**
  41927. * Defines if the other scene animations should be stopped when the action has been triggered
  41928. */
  41929. stopOtherAnimations?: boolean;
  41930. /**
  41931. * Defines a callback raised once the interpolation animation has been done.
  41932. */
  41933. onInterpolationDone?: () => void;
  41934. /**
  41935. * Observable triggered once the interpolation animation has been done.
  41936. */
  41937. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41938. private _target;
  41939. private _effectiveTarget;
  41940. private _property;
  41941. /**
  41942. * Instantiate the action
  41943. * @param triggerOptions defines the trigger options
  41944. * @param target defines the object containing the value to interpolate
  41945. * @param propertyPath defines the path to the property in the target object
  41946. * @param value defines the target value at the end of the interpolation
  41947. * @param duration deines the time it will take for the property to interpolate to the value.
  41948. * @param condition defines the trigger related conditions
  41949. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41950. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41951. */
  41952. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41953. /** @hidden */
  41954. _prepare(): void;
  41955. /**
  41956. * Execute the action starts the value interpolation.
  41957. */
  41958. execute(): void;
  41959. /**
  41960. * Serializes the actions and its related information.
  41961. * @param parent defines the object to serialize in
  41962. * @returns the serialized object
  41963. */
  41964. serialize(parent: any): any;
  41965. }
  41966. }
  41967. declare module BABYLON {
  41968. /**
  41969. * Options allowed during the creation of a sound track.
  41970. */
  41971. export interface ISoundTrackOptions {
  41972. /**
  41973. * The volume the sound track should take during creation
  41974. */
  41975. volume?: number;
  41976. /**
  41977. * Define if the sound track is the main sound track of the scene
  41978. */
  41979. mainTrack?: boolean;
  41980. }
  41981. /**
  41982. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41983. * It will be also used in a future release to apply effects on a specific track.
  41984. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41985. */
  41986. export class SoundTrack {
  41987. /**
  41988. * The unique identifier of the sound track in the scene.
  41989. */
  41990. id: number;
  41991. /**
  41992. * The list of sounds included in the sound track.
  41993. */
  41994. soundCollection: Array<Sound>;
  41995. private _outputAudioNode;
  41996. private _scene;
  41997. private _connectedAnalyser;
  41998. private _options;
  41999. private _isInitialized;
  42000. /**
  42001. * Creates a new sound track.
  42002. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42003. * @param scene Define the scene the sound track belongs to
  42004. * @param options
  42005. */
  42006. constructor(scene: Scene, options?: ISoundTrackOptions);
  42007. private _initializeSoundTrackAudioGraph;
  42008. /**
  42009. * Release the sound track and its associated resources
  42010. */
  42011. dispose(): void;
  42012. /**
  42013. * Adds a sound to this sound track
  42014. * @param sound define the cound to add
  42015. * @ignoreNaming
  42016. */
  42017. AddSound(sound: Sound): void;
  42018. /**
  42019. * Removes a sound to this sound track
  42020. * @param sound define the cound to remove
  42021. * @ignoreNaming
  42022. */
  42023. RemoveSound(sound: Sound): void;
  42024. /**
  42025. * Set a global volume for the full sound track.
  42026. * @param newVolume Define the new volume of the sound track
  42027. */
  42028. setVolume(newVolume: number): void;
  42029. /**
  42030. * Switch the panning model to HRTF:
  42031. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42032. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42033. */
  42034. switchPanningModelToHRTF(): void;
  42035. /**
  42036. * Switch the panning model to Equal Power:
  42037. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42038. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42039. */
  42040. switchPanningModelToEqualPower(): void;
  42041. /**
  42042. * Connect the sound track to an audio analyser allowing some amazing
  42043. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42044. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42045. * @param analyser The analyser to connect to the engine
  42046. */
  42047. connectToAnalyser(analyser: Analyser): void;
  42048. }
  42049. }
  42050. declare module BABYLON {
  42051. interface AbstractScene {
  42052. /**
  42053. * The list of sounds used in the scene.
  42054. */
  42055. sounds: Nullable<Array<Sound>>;
  42056. }
  42057. interface Scene {
  42058. /**
  42059. * @hidden
  42060. * Backing field
  42061. */
  42062. _mainSoundTrack: SoundTrack;
  42063. /**
  42064. * The main sound track played by the scene.
  42065. * It cotains your primary collection of sounds.
  42066. */
  42067. mainSoundTrack: SoundTrack;
  42068. /**
  42069. * The list of sound tracks added to the scene
  42070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42071. */
  42072. soundTracks: Nullable<Array<SoundTrack>>;
  42073. /**
  42074. * Gets a sound using a given name
  42075. * @param name defines the name to search for
  42076. * @return the found sound or null if not found at all.
  42077. */
  42078. getSoundByName(name: string): Nullable<Sound>;
  42079. /**
  42080. * Gets or sets if audio support is enabled
  42081. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42082. */
  42083. audioEnabled: boolean;
  42084. /**
  42085. * Gets or sets if audio will be output to headphones
  42086. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42087. */
  42088. headphone: boolean;
  42089. /**
  42090. * Gets or sets custom audio listener position provider
  42091. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42092. */
  42093. audioListenerPositionProvider: Nullable<() => Vector3>;
  42094. /**
  42095. * Gets or sets a refresh rate when using 3D audio positioning
  42096. */
  42097. audioPositioningRefreshRate: number;
  42098. }
  42099. /**
  42100. * Defines the sound scene component responsible to manage any sounds
  42101. * in a given scene.
  42102. */
  42103. export class AudioSceneComponent implements ISceneSerializableComponent {
  42104. private static _CameraDirectionLH;
  42105. private static _CameraDirectionRH;
  42106. /**
  42107. * The component name helpfull to identify the component in the list of scene components.
  42108. */
  42109. readonly name: string;
  42110. /**
  42111. * The scene the component belongs to.
  42112. */
  42113. scene: Scene;
  42114. private _audioEnabled;
  42115. /**
  42116. * Gets whether audio is enabled or not.
  42117. * Please use related enable/disable method to switch state.
  42118. */
  42119. get audioEnabled(): boolean;
  42120. private _headphone;
  42121. /**
  42122. * Gets whether audio is outputing to headphone or not.
  42123. * Please use the according Switch methods to change output.
  42124. */
  42125. get headphone(): boolean;
  42126. /**
  42127. * Gets or sets a refresh rate when using 3D audio positioning
  42128. */
  42129. audioPositioningRefreshRate: number;
  42130. private _audioListenerPositionProvider;
  42131. /**
  42132. * Gets the current audio listener position provider
  42133. */
  42134. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42135. /**
  42136. * Sets a custom listener position for all sounds in the scene
  42137. * By default, this is the position of the first active camera
  42138. */
  42139. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42140. /**
  42141. * Creates a new instance of the component for the given scene
  42142. * @param scene Defines the scene to register the component in
  42143. */
  42144. constructor(scene: Scene);
  42145. /**
  42146. * Registers the component in a given scene
  42147. */
  42148. register(): void;
  42149. /**
  42150. * Rebuilds the elements related to this component in case of
  42151. * context lost for instance.
  42152. */
  42153. rebuild(): void;
  42154. /**
  42155. * Serializes the component data to the specified json object
  42156. * @param serializationObject The object to serialize to
  42157. */
  42158. serialize(serializationObject: any): void;
  42159. /**
  42160. * Adds all the elements from the container to the scene
  42161. * @param container the container holding the elements
  42162. */
  42163. addFromContainer(container: AbstractScene): void;
  42164. /**
  42165. * Removes all the elements in the container from the scene
  42166. * @param container contains the elements to remove
  42167. * @param dispose if the removed element should be disposed (default: false)
  42168. */
  42169. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42170. /**
  42171. * Disposes the component and the associated ressources.
  42172. */
  42173. dispose(): void;
  42174. /**
  42175. * Disables audio in the associated scene.
  42176. */
  42177. disableAudio(): void;
  42178. /**
  42179. * Enables audio in the associated scene.
  42180. */
  42181. enableAudio(): void;
  42182. /**
  42183. * Switch audio to headphone output.
  42184. */
  42185. switchAudioModeForHeadphones(): void;
  42186. /**
  42187. * Switch audio to normal speakers.
  42188. */
  42189. switchAudioModeForNormalSpeakers(): void;
  42190. private _cachedCameraDirection;
  42191. private _cachedCameraPosition;
  42192. private _lastCheck;
  42193. private _afterRender;
  42194. }
  42195. }
  42196. declare module BABYLON {
  42197. /**
  42198. * Wraps one or more Sound objects and selects one with random weight for playback.
  42199. */
  42200. export class WeightedSound {
  42201. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42202. loop: boolean;
  42203. private _coneInnerAngle;
  42204. private _coneOuterAngle;
  42205. private _volume;
  42206. /** A Sound is currently playing. */
  42207. isPlaying: boolean;
  42208. /** A Sound is currently paused. */
  42209. isPaused: boolean;
  42210. private _sounds;
  42211. private _weights;
  42212. private _currentIndex?;
  42213. /**
  42214. * Creates a new WeightedSound from the list of sounds given.
  42215. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42216. * @param sounds Array of Sounds that will be selected from.
  42217. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42218. */
  42219. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42220. /**
  42221. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42222. */
  42223. get directionalConeInnerAngle(): number;
  42224. /**
  42225. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42226. */
  42227. set directionalConeInnerAngle(value: number);
  42228. /**
  42229. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42230. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42231. */
  42232. get directionalConeOuterAngle(): number;
  42233. /**
  42234. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42235. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42236. */
  42237. set directionalConeOuterAngle(value: number);
  42238. /**
  42239. * Playback volume.
  42240. */
  42241. get volume(): number;
  42242. /**
  42243. * Playback volume.
  42244. */
  42245. set volume(value: number);
  42246. private _onended;
  42247. /**
  42248. * Suspend playback
  42249. */
  42250. pause(): void;
  42251. /**
  42252. * Stop playback
  42253. */
  42254. stop(): void;
  42255. /**
  42256. * Start playback.
  42257. * @param startOffset Position the clip head at a specific time in seconds.
  42258. */
  42259. play(startOffset?: number): void;
  42260. }
  42261. }
  42262. declare module BABYLON {
  42263. /**
  42264. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42265. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42266. */
  42267. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42268. /**
  42269. * Gets the name of the behavior.
  42270. */
  42271. get name(): string;
  42272. /**
  42273. * The easing function used by animations
  42274. */
  42275. static EasingFunction: BackEase;
  42276. /**
  42277. * The easing mode used by animations
  42278. */
  42279. static EasingMode: number;
  42280. /**
  42281. * The duration of the animation, in milliseconds
  42282. */
  42283. transitionDuration: number;
  42284. /**
  42285. * Length of the distance animated by the transition when lower radius is reached
  42286. */
  42287. lowerRadiusTransitionRange: number;
  42288. /**
  42289. * Length of the distance animated by the transition when upper radius is reached
  42290. */
  42291. upperRadiusTransitionRange: number;
  42292. private _autoTransitionRange;
  42293. /**
  42294. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42295. */
  42296. get autoTransitionRange(): boolean;
  42297. /**
  42298. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42299. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42300. */
  42301. set autoTransitionRange(value: boolean);
  42302. private _attachedCamera;
  42303. private _onAfterCheckInputsObserver;
  42304. private _onMeshTargetChangedObserver;
  42305. /**
  42306. * Initializes the behavior.
  42307. */
  42308. init(): void;
  42309. /**
  42310. * Attaches the behavior to its arc rotate camera.
  42311. * @param camera Defines the camera to attach the behavior to
  42312. */
  42313. attach(camera: ArcRotateCamera): void;
  42314. /**
  42315. * Detaches the behavior from its current arc rotate camera.
  42316. */
  42317. detach(): void;
  42318. private _radiusIsAnimating;
  42319. private _radiusBounceTransition;
  42320. private _animatables;
  42321. private _cachedWheelPrecision;
  42322. /**
  42323. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42324. * @param radiusLimit The limit to check against.
  42325. * @return Bool to indicate if at limit.
  42326. */
  42327. private _isRadiusAtLimit;
  42328. /**
  42329. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42330. * @param radiusDelta The delta by which to animate to. Can be negative.
  42331. */
  42332. private _applyBoundRadiusAnimation;
  42333. /**
  42334. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42335. */
  42336. protected _clearAnimationLocks(): void;
  42337. /**
  42338. * Stops and removes all animations that have been applied to the camera
  42339. */
  42340. stopAllAnimations(): void;
  42341. }
  42342. }
  42343. declare module BABYLON {
  42344. /**
  42345. * 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.
  42346. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42347. */
  42348. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42349. /**
  42350. * Gets the name of the behavior.
  42351. */
  42352. get name(): string;
  42353. private _mode;
  42354. private _radiusScale;
  42355. private _positionScale;
  42356. private _defaultElevation;
  42357. private _elevationReturnTime;
  42358. private _elevationReturnWaitTime;
  42359. private _zoomStopsAnimation;
  42360. private _framingTime;
  42361. /**
  42362. * The easing function used by animations
  42363. */
  42364. static EasingFunction: ExponentialEase;
  42365. /**
  42366. * The easing mode used by animations
  42367. */
  42368. static EasingMode: number;
  42369. /**
  42370. * Sets the current mode used by the behavior
  42371. */
  42372. set mode(mode: number);
  42373. /**
  42374. * Gets current mode used by the behavior.
  42375. */
  42376. get mode(): number;
  42377. /**
  42378. * Sets the scale applied to the radius (1 by default)
  42379. */
  42380. set radiusScale(radius: number);
  42381. /**
  42382. * Gets the scale applied to the radius
  42383. */
  42384. get radiusScale(): number;
  42385. /**
  42386. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42387. */
  42388. set positionScale(scale: number);
  42389. /**
  42390. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42391. */
  42392. get positionScale(): number;
  42393. /**
  42394. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42395. * behaviour is triggered, in radians.
  42396. */
  42397. set defaultElevation(elevation: number);
  42398. /**
  42399. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42400. * behaviour is triggered, in radians.
  42401. */
  42402. get defaultElevation(): number;
  42403. /**
  42404. * Sets the time (in milliseconds) taken to return to the default beta position.
  42405. * Negative value indicates camera should not return to default.
  42406. */
  42407. set elevationReturnTime(speed: number);
  42408. /**
  42409. * Gets the time (in milliseconds) taken to return to the default beta position.
  42410. * Negative value indicates camera should not return to default.
  42411. */
  42412. get elevationReturnTime(): number;
  42413. /**
  42414. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42415. */
  42416. set elevationReturnWaitTime(time: number);
  42417. /**
  42418. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42419. */
  42420. get elevationReturnWaitTime(): number;
  42421. /**
  42422. * Sets the flag that indicates if user zooming should stop animation.
  42423. */
  42424. set zoomStopsAnimation(flag: boolean);
  42425. /**
  42426. * Gets the flag that indicates if user zooming should stop animation.
  42427. */
  42428. get zoomStopsAnimation(): boolean;
  42429. /**
  42430. * Sets the transition time when framing the mesh, in milliseconds
  42431. */
  42432. set framingTime(time: number);
  42433. /**
  42434. * Gets the transition time when framing the mesh, in milliseconds
  42435. */
  42436. get framingTime(): number;
  42437. /**
  42438. * Define if the behavior should automatically change the configured
  42439. * camera limits and sensibilities.
  42440. */
  42441. autoCorrectCameraLimitsAndSensibility: boolean;
  42442. private _onPrePointerObservableObserver;
  42443. private _onAfterCheckInputsObserver;
  42444. private _onMeshTargetChangedObserver;
  42445. private _attachedCamera;
  42446. private _isPointerDown;
  42447. private _lastInteractionTime;
  42448. /**
  42449. * Initializes the behavior.
  42450. */
  42451. init(): void;
  42452. /**
  42453. * Attaches the behavior to its arc rotate camera.
  42454. * @param camera Defines the camera to attach the behavior to
  42455. */
  42456. attach(camera: ArcRotateCamera): void;
  42457. /**
  42458. * Detaches the behavior from its current arc rotate camera.
  42459. */
  42460. detach(): void;
  42461. private _animatables;
  42462. private _betaIsAnimating;
  42463. private _betaTransition;
  42464. private _radiusTransition;
  42465. private _vectorTransition;
  42466. /**
  42467. * Targets the given mesh and updates zoom level accordingly.
  42468. * @param mesh The mesh to target.
  42469. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42470. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42471. */
  42472. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42473. /**
  42474. * Targets the given mesh with its children and updates zoom level accordingly.
  42475. * @param mesh The mesh to target.
  42476. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42477. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42478. */
  42479. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42480. /**
  42481. * Targets the given meshes with their children and updates zoom level accordingly.
  42482. * @param meshes The mesh to target.
  42483. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42484. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42485. */
  42486. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42487. /**
  42488. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42489. * @param minimumWorld Determines the smaller position of the bounding box extend
  42490. * @param maximumWorld Determines the bigger position of the bounding box extend
  42491. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42492. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42493. */
  42494. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42495. /**
  42496. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42497. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42498. * frustum width.
  42499. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42500. * to fully enclose the mesh in the viewing frustum.
  42501. */
  42502. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42503. /**
  42504. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42505. * is automatically returned to its default position (expected to be above ground plane).
  42506. */
  42507. private _maintainCameraAboveGround;
  42508. /**
  42509. * Returns the frustum slope based on the canvas ratio and camera FOV
  42510. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42511. */
  42512. private _getFrustumSlope;
  42513. /**
  42514. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42515. */
  42516. private _clearAnimationLocks;
  42517. /**
  42518. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42519. */
  42520. private _applyUserInteraction;
  42521. /**
  42522. * Stops and removes all animations that have been applied to the camera
  42523. */
  42524. stopAllAnimations(): void;
  42525. /**
  42526. * Gets a value indicating if the user is moving the camera
  42527. */
  42528. get isUserIsMoving(): boolean;
  42529. /**
  42530. * The camera can move all the way towards the mesh.
  42531. */
  42532. static IgnoreBoundsSizeMode: number;
  42533. /**
  42534. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42535. */
  42536. static FitFrustumSidesMode: number;
  42537. }
  42538. }
  42539. declare module BABYLON {
  42540. /**
  42541. * Base class for Camera Pointer Inputs.
  42542. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42543. * for example usage.
  42544. */
  42545. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42546. /**
  42547. * Defines the camera the input is attached to.
  42548. */
  42549. abstract camera: Camera;
  42550. /**
  42551. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42552. */
  42553. protected _altKey: boolean;
  42554. protected _ctrlKey: boolean;
  42555. protected _metaKey: boolean;
  42556. protected _shiftKey: boolean;
  42557. /**
  42558. * Which mouse buttons were pressed at time of last mouse event.
  42559. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42560. */
  42561. protected _buttonsPressed: number;
  42562. /**
  42563. * Defines the buttons associated with the input to handle camera move.
  42564. */
  42565. buttons: number[];
  42566. /**
  42567. * Attach the input controls to a specific dom element to get the input from.
  42568. * @param element Defines the element the controls should be listened from
  42569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42570. */
  42571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42572. /**
  42573. * Detach the current controls from the specified dom element.
  42574. * @param element Defines the element to stop listening the inputs from
  42575. */
  42576. detachControl(element: Nullable<HTMLElement>): void;
  42577. /**
  42578. * Gets the class name of the current input.
  42579. * @returns the class name
  42580. */
  42581. getClassName(): string;
  42582. /**
  42583. * Get the friendly name associated with the input class.
  42584. * @returns the input friendly name
  42585. */
  42586. getSimpleName(): string;
  42587. /**
  42588. * Called on pointer POINTERDOUBLETAP event.
  42589. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42590. */
  42591. protected onDoubleTap(type: string): void;
  42592. /**
  42593. * Called on pointer POINTERMOVE event if only a single touch is active.
  42594. * Override this method to provide functionality.
  42595. */
  42596. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42597. /**
  42598. * Called on pointer POINTERMOVE event if multiple touches are active.
  42599. * Override this method to provide functionality.
  42600. */
  42601. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42602. /**
  42603. * Called on JS contextmenu event.
  42604. * Override this method to provide functionality.
  42605. */
  42606. protected onContextMenu(evt: PointerEvent): void;
  42607. /**
  42608. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42609. * press.
  42610. * Override this method to provide functionality.
  42611. */
  42612. protected onButtonDown(evt: PointerEvent): void;
  42613. /**
  42614. * Called each time a new POINTERUP event occurs. Ie, for each button
  42615. * release.
  42616. * Override this method to provide functionality.
  42617. */
  42618. protected onButtonUp(evt: PointerEvent): void;
  42619. /**
  42620. * Called when window becomes inactive.
  42621. * Override this method to provide functionality.
  42622. */
  42623. protected onLostFocus(): void;
  42624. private _pointerInput;
  42625. private _observer;
  42626. private _onLostFocus;
  42627. private pointA;
  42628. private pointB;
  42629. }
  42630. }
  42631. declare module BABYLON {
  42632. /**
  42633. * Manage the pointers inputs to control an arc rotate camera.
  42634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42635. */
  42636. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42637. /**
  42638. * Defines the camera the input is attached to.
  42639. */
  42640. camera: ArcRotateCamera;
  42641. /**
  42642. * Gets the class name of the current input.
  42643. * @returns the class name
  42644. */
  42645. getClassName(): string;
  42646. /**
  42647. * Defines the buttons associated with the input to handle camera move.
  42648. */
  42649. buttons: number[];
  42650. /**
  42651. * Defines the pointer angular sensibility along the X axis or how fast is
  42652. * the camera rotating.
  42653. */
  42654. angularSensibilityX: number;
  42655. /**
  42656. * Defines the pointer angular sensibility along the Y axis or how fast is
  42657. * the camera rotating.
  42658. */
  42659. angularSensibilityY: number;
  42660. /**
  42661. * Defines the pointer pinch precision or how fast is the camera zooming.
  42662. */
  42663. pinchPrecision: number;
  42664. /**
  42665. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42666. * from 0.
  42667. * It defines the percentage of current camera.radius to use as delta when
  42668. * pinch zoom is used.
  42669. */
  42670. pinchDeltaPercentage: number;
  42671. /**
  42672. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42673. * that any object in the plane at the camera's target point will scale
  42674. * perfectly with finger motion.
  42675. * Overrides pinchDeltaPercentage and pinchPrecision.
  42676. */
  42677. useNaturalPinchZoom: boolean;
  42678. /**
  42679. * Defines the pointer panning sensibility or how fast is the camera moving.
  42680. */
  42681. panningSensibility: number;
  42682. /**
  42683. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42684. */
  42685. multiTouchPanning: boolean;
  42686. /**
  42687. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42688. * zoom (pinch) through multitouch.
  42689. */
  42690. multiTouchPanAndZoom: boolean;
  42691. /**
  42692. * Revers pinch action direction.
  42693. */
  42694. pinchInwards: boolean;
  42695. private _isPanClick;
  42696. private _twoFingerActivityCount;
  42697. private _isPinching;
  42698. /**
  42699. * Called on pointer POINTERMOVE event if only a single touch is active.
  42700. */
  42701. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42702. /**
  42703. * Called on pointer POINTERDOUBLETAP event.
  42704. */
  42705. protected onDoubleTap(type: string): void;
  42706. /**
  42707. * Called on pointer POINTERMOVE event if multiple touches are active.
  42708. */
  42709. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42710. /**
  42711. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42712. * press.
  42713. */
  42714. protected onButtonDown(evt: PointerEvent): void;
  42715. /**
  42716. * Called each time a new POINTERUP event occurs. Ie, for each button
  42717. * release.
  42718. */
  42719. protected onButtonUp(evt: PointerEvent): void;
  42720. /**
  42721. * Called when window becomes inactive.
  42722. */
  42723. protected onLostFocus(): void;
  42724. }
  42725. }
  42726. declare module BABYLON {
  42727. /**
  42728. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42729. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42730. */
  42731. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42732. /**
  42733. * Defines the camera the input is attached to.
  42734. */
  42735. camera: ArcRotateCamera;
  42736. /**
  42737. * Defines the list of key codes associated with the up action (increase alpha)
  42738. */
  42739. keysUp: number[];
  42740. /**
  42741. * Defines the list of key codes associated with the down action (decrease alpha)
  42742. */
  42743. keysDown: number[];
  42744. /**
  42745. * Defines the list of key codes associated with the left action (increase beta)
  42746. */
  42747. keysLeft: number[];
  42748. /**
  42749. * Defines the list of key codes associated with the right action (decrease beta)
  42750. */
  42751. keysRight: number[];
  42752. /**
  42753. * Defines the list of key codes associated with the reset action.
  42754. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42755. */
  42756. keysReset: number[];
  42757. /**
  42758. * Defines the panning sensibility of the inputs.
  42759. * (How fast is the camera panning)
  42760. */
  42761. panningSensibility: number;
  42762. /**
  42763. * Defines the zooming sensibility of the inputs.
  42764. * (How fast is the camera zooming)
  42765. */
  42766. zoomingSensibility: number;
  42767. /**
  42768. * Defines whether maintaining the alt key down switch the movement mode from
  42769. * orientation to zoom.
  42770. */
  42771. useAltToZoom: boolean;
  42772. /**
  42773. * Rotation speed of the camera
  42774. */
  42775. angularSpeed: number;
  42776. private _keys;
  42777. private _ctrlPressed;
  42778. private _altPressed;
  42779. private _onCanvasBlurObserver;
  42780. private _onKeyboardObserver;
  42781. private _engine;
  42782. private _scene;
  42783. /**
  42784. * Attach the input controls to a specific dom element to get the input from.
  42785. * @param element Defines the element the controls should be listened from
  42786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42787. */
  42788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42789. /**
  42790. * Detach the current controls from the specified dom element.
  42791. * @param element Defines the element to stop listening the inputs from
  42792. */
  42793. detachControl(element: Nullable<HTMLElement>): void;
  42794. /**
  42795. * Update the current camera state depending on the inputs that have been used this frame.
  42796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42797. */
  42798. checkInputs(): void;
  42799. /**
  42800. * Gets the class name of the current intput.
  42801. * @returns the class name
  42802. */
  42803. getClassName(): string;
  42804. /**
  42805. * Get the friendly name associated with the input class.
  42806. * @returns the input friendly name
  42807. */
  42808. getSimpleName(): string;
  42809. }
  42810. }
  42811. declare module BABYLON {
  42812. /**
  42813. * Manage the mouse wheel inputs to control an arc rotate camera.
  42814. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42815. */
  42816. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42817. /**
  42818. * Defines the camera the input is attached to.
  42819. */
  42820. camera: ArcRotateCamera;
  42821. /**
  42822. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42823. */
  42824. wheelPrecision: number;
  42825. /**
  42826. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42827. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42828. */
  42829. wheelDeltaPercentage: number;
  42830. private _wheel;
  42831. private _observer;
  42832. private computeDeltaFromMouseWheelLegacyEvent;
  42833. /**
  42834. * Attach the input controls to a specific dom element to get the input from.
  42835. * @param element Defines the element the controls should be listened from
  42836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42837. */
  42838. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42839. /**
  42840. * Detach the current controls from the specified dom element.
  42841. * @param element Defines the element to stop listening the inputs from
  42842. */
  42843. detachControl(element: Nullable<HTMLElement>): void;
  42844. /**
  42845. * Gets the class name of the current intput.
  42846. * @returns the class name
  42847. */
  42848. getClassName(): string;
  42849. /**
  42850. * Get the friendly name associated with the input class.
  42851. * @returns the input friendly name
  42852. */
  42853. getSimpleName(): string;
  42854. }
  42855. }
  42856. declare module BABYLON {
  42857. /**
  42858. * Default Inputs manager for the ArcRotateCamera.
  42859. * It groups all the default supported inputs for ease of use.
  42860. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42861. */
  42862. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42863. /**
  42864. * Instantiates a new ArcRotateCameraInputsManager.
  42865. * @param camera Defines the camera the inputs belong to
  42866. */
  42867. constructor(camera: ArcRotateCamera);
  42868. /**
  42869. * Add mouse wheel input support to the input manager.
  42870. * @returns the current input manager
  42871. */
  42872. addMouseWheel(): ArcRotateCameraInputsManager;
  42873. /**
  42874. * Add pointers input support to the input manager.
  42875. * @returns the current input manager
  42876. */
  42877. addPointers(): ArcRotateCameraInputsManager;
  42878. /**
  42879. * Add keyboard input support to the input manager.
  42880. * @returns the current input manager
  42881. */
  42882. addKeyboard(): ArcRotateCameraInputsManager;
  42883. }
  42884. }
  42885. declare module BABYLON {
  42886. /**
  42887. * This represents an orbital type of camera.
  42888. *
  42889. * 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.
  42890. * 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.
  42891. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42892. */
  42893. export class ArcRotateCamera extends TargetCamera {
  42894. /**
  42895. * Defines the rotation angle of the camera along the longitudinal axis.
  42896. */
  42897. alpha: number;
  42898. /**
  42899. * Defines the rotation angle of the camera along the latitudinal axis.
  42900. */
  42901. beta: number;
  42902. /**
  42903. * Defines the radius of the camera from it s target point.
  42904. */
  42905. radius: number;
  42906. protected _target: Vector3;
  42907. protected _targetHost: Nullable<AbstractMesh>;
  42908. /**
  42909. * Defines the target point of the camera.
  42910. * The camera looks towards it form the radius distance.
  42911. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42912. */
  42913. get target(): Vector3;
  42914. set target(value: Vector3);
  42915. /**
  42916. * Define the current local position of the camera in the scene
  42917. */
  42918. get position(): Vector3;
  42919. set position(newPosition: Vector3);
  42920. protected _upToYMatrix: Matrix;
  42921. protected _YToUpMatrix: Matrix;
  42922. /**
  42923. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42924. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42925. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42926. */
  42927. set upVector(vec: Vector3);
  42928. get upVector(): Vector3;
  42929. /**
  42930. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42931. */
  42932. setMatUp(): void;
  42933. /**
  42934. * Current inertia value on the longitudinal axis.
  42935. * The bigger this number the longer it will take for the camera to stop.
  42936. */
  42937. inertialAlphaOffset: number;
  42938. /**
  42939. * Current inertia value on the latitudinal axis.
  42940. * The bigger this number the longer it will take for the camera to stop.
  42941. */
  42942. inertialBetaOffset: number;
  42943. /**
  42944. * Current inertia value on the radius axis.
  42945. * The bigger this number the longer it will take for the camera to stop.
  42946. */
  42947. inertialRadiusOffset: number;
  42948. /**
  42949. * Minimum allowed angle on the longitudinal axis.
  42950. * This can help limiting how the Camera is able to move in the scene.
  42951. */
  42952. lowerAlphaLimit: Nullable<number>;
  42953. /**
  42954. * Maximum allowed angle on the longitudinal axis.
  42955. * This can help limiting how the Camera is able to move in the scene.
  42956. */
  42957. upperAlphaLimit: Nullable<number>;
  42958. /**
  42959. * Minimum allowed angle on the latitudinal axis.
  42960. * This can help limiting how the Camera is able to move in the scene.
  42961. */
  42962. lowerBetaLimit: number;
  42963. /**
  42964. * Maximum allowed angle on the latitudinal axis.
  42965. * This can help limiting how the Camera is able to move in the scene.
  42966. */
  42967. upperBetaLimit: number;
  42968. /**
  42969. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42970. * This can help limiting how the Camera is able to move in the scene.
  42971. */
  42972. lowerRadiusLimit: Nullable<number>;
  42973. /**
  42974. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42975. * This can help limiting how the Camera is able to move in the scene.
  42976. */
  42977. upperRadiusLimit: Nullable<number>;
  42978. /**
  42979. * Defines the current inertia value used during panning of the camera along the X axis.
  42980. */
  42981. inertialPanningX: number;
  42982. /**
  42983. * Defines the current inertia value used during panning of the camera along the Y axis.
  42984. */
  42985. inertialPanningY: number;
  42986. /**
  42987. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42988. * Basically if your fingers moves away from more than this distance you will be considered
  42989. * in pinch mode.
  42990. */
  42991. pinchToPanMaxDistance: number;
  42992. /**
  42993. * Defines the maximum distance the camera can pan.
  42994. * This could help keeping the cammera always in your scene.
  42995. */
  42996. panningDistanceLimit: Nullable<number>;
  42997. /**
  42998. * Defines the target of the camera before paning.
  42999. */
  43000. panningOriginTarget: Vector3;
  43001. /**
  43002. * Defines the value of the inertia used during panning.
  43003. * 0 would mean stop inertia and one would mean no decelleration at all.
  43004. */
  43005. panningInertia: number;
  43006. /**
  43007. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43008. */
  43009. get angularSensibilityX(): number;
  43010. set angularSensibilityX(value: number);
  43011. /**
  43012. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43013. */
  43014. get angularSensibilityY(): number;
  43015. set angularSensibilityY(value: number);
  43016. /**
  43017. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43018. */
  43019. get pinchPrecision(): number;
  43020. set pinchPrecision(value: number);
  43021. /**
  43022. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43023. * It will be used instead of pinchDeltaPrecision if different from 0.
  43024. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43025. */
  43026. get pinchDeltaPercentage(): number;
  43027. set pinchDeltaPercentage(value: number);
  43028. /**
  43029. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43030. * and pinch delta percentage.
  43031. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43032. * that any object in the plane at the camera's target point will scale
  43033. * perfectly with finger motion.
  43034. */
  43035. get useNaturalPinchZoom(): boolean;
  43036. set useNaturalPinchZoom(value: boolean);
  43037. /**
  43038. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43039. */
  43040. get panningSensibility(): number;
  43041. set panningSensibility(value: number);
  43042. /**
  43043. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43044. */
  43045. get keysUp(): number[];
  43046. set keysUp(value: number[]);
  43047. /**
  43048. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43049. */
  43050. get keysDown(): number[];
  43051. set keysDown(value: number[]);
  43052. /**
  43053. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43054. */
  43055. get keysLeft(): number[];
  43056. set keysLeft(value: number[]);
  43057. /**
  43058. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43059. */
  43060. get keysRight(): number[];
  43061. set keysRight(value: number[]);
  43062. /**
  43063. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43064. */
  43065. get wheelPrecision(): number;
  43066. set wheelPrecision(value: number);
  43067. /**
  43068. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43069. * It will be used instead of pinchDeltaPrecision if different from 0.
  43070. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43071. */
  43072. get wheelDeltaPercentage(): number;
  43073. set wheelDeltaPercentage(value: number);
  43074. /**
  43075. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43076. */
  43077. zoomOnFactor: number;
  43078. /**
  43079. * Defines a screen offset for the camera position.
  43080. */
  43081. targetScreenOffset: Vector2;
  43082. /**
  43083. * Allows the camera to be completely reversed.
  43084. * If false the camera can not arrive upside down.
  43085. */
  43086. allowUpsideDown: boolean;
  43087. /**
  43088. * Define if double tap/click is used to restore the previously saved state of the camera.
  43089. */
  43090. useInputToRestoreState: boolean;
  43091. /** @hidden */
  43092. _viewMatrix: Matrix;
  43093. /** @hidden */
  43094. _useCtrlForPanning: boolean;
  43095. /** @hidden */
  43096. _panningMouseButton: number;
  43097. /**
  43098. * Defines the input associated to the camera.
  43099. */
  43100. inputs: ArcRotateCameraInputsManager;
  43101. /** @hidden */
  43102. _reset: () => void;
  43103. /**
  43104. * Defines the allowed panning axis.
  43105. */
  43106. panningAxis: Vector3;
  43107. protected _localDirection: Vector3;
  43108. protected _transformedDirection: Vector3;
  43109. private _bouncingBehavior;
  43110. /**
  43111. * Gets the bouncing behavior of the camera if it has been enabled.
  43112. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43113. */
  43114. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43115. /**
  43116. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43117. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43118. */
  43119. get useBouncingBehavior(): boolean;
  43120. set useBouncingBehavior(value: boolean);
  43121. private _framingBehavior;
  43122. /**
  43123. * Gets the framing behavior of the camera if it has been enabled.
  43124. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43125. */
  43126. get framingBehavior(): Nullable<FramingBehavior>;
  43127. /**
  43128. * Defines if the framing behavior of the camera is enabled on the camera.
  43129. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43130. */
  43131. get useFramingBehavior(): boolean;
  43132. set useFramingBehavior(value: boolean);
  43133. private _autoRotationBehavior;
  43134. /**
  43135. * Gets the auto rotation behavior of the camera if it has been enabled.
  43136. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43137. */
  43138. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43139. /**
  43140. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43141. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43142. */
  43143. get useAutoRotationBehavior(): boolean;
  43144. set useAutoRotationBehavior(value: boolean);
  43145. /**
  43146. * Observable triggered when the mesh target has been changed on the camera.
  43147. */
  43148. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43149. /**
  43150. * Event raised when the camera is colliding with a mesh.
  43151. */
  43152. onCollide: (collidedMesh: AbstractMesh) => void;
  43153. /**
  43154. * Defines whether the camera should check collision with the objects oh the scene.
  43155. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43156. */
  43157. checkCollisions: boolean;
  43158. /**
  43159. * Defines the collision radius of the camera.
  43160. * This simulates a sphere around the camera.
  43161. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43162. */
  43163. collisionRadius: Vector3;
  43164. protected _collider: Collider;
  43165. protected _previousPosition: Vector3;
  43166. protected _collisionVelocity: Vector3;
  43167. protected _newPosition: Vector3;
  43168. protected _previousAlpha: number;
  43169. protected _previousBeta: number;
  43170. protected _previousRadius: number;
  43171. protected _collisionTriggered: boolean;
  43172. protected _targetBoundingCenter: Nullable<Vector3>;
  43173. private _computationVector;
  43174. /**
  43175. * Instantiates a new ArcRotateCamera in a given scene
  43176. * @param name Defines the name of the camera
  43177. * @param alpha Defines the camera rotation along the logitudinal axis
  43178. * @param beta Defines the camera rotation along the latitudinal axis
  43179. * @param radius Defines the camera distance from its target
  43180. * @param target Defines the camera target
  43181. * @param scene Defines the scene the camera belongs to
  43182. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43183. */
  43184. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43185. /** @hidden */
  43186. _initCache(): void;
  43187. /** @hidden */
  43188. _updateCache(ignoreParentClass?: boolean): void;
  43189. protected _getTargetPosition(): Vector3;
  43190. private _storedAlpha;
  43191. private _storedBeta;
  43192. private _storedRadius;
  43193. private _storedTarget;
  43194. private _storedTargetScreenOffset;
  43195. /**
  43196. * Stores the current state of the camera (alpha, beta, radius and target)
  43197. * @returns the camera itself
  43198. */
  43199. storeState(): Camera;
  43200. /**
  43201. * @hidden
  43202. * Restored camera state. You must call storeState() first
  43203. */
  43204. _restoreStateValues(): boolean;
  43205. /** @hidden */
  43206. _isSynchronizedViewMatrix(): boolean;
  43207. /**
  43208. * Attached controls to the current camera.
  43209. * @param element Defines the element the controls should be listened from
  43210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43211. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43212. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43213. */
  43214. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43215. /**
  43216. * Detach the current controls from the camera.
  43217. * The camera will stop reacting to inputs.
  43218. * @param element Defines the element to stop listening the inputs from
  43219. */
  43220. detachControl(element: HTMLElement): void;
  43221. /** @hidden */
  43222. _checkInputs(): void;
  43223. protected _checkLimits(): void;
  43224. /**
  43225. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43226. */
  43227. rebuildAnglesAndRadius(): void;
  43228. /**
  43229. * Use a position to define the current camera related information like alpha, beta and radius
  43230. * @param position Defines the position to set the camera at
  43231. */
  43232. setPosition(position: Vector3): void;
  43233. /**
  43234. * Defines the target the camera should look at.
  43235. * This will automatically adapt alpha beta and radius to fit within the new target.
  43236. * @param target Defines the new target as a Vector or a mesh
  43237. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43238. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43239. */
  43240. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43241. /** @hidden */
  43242. _getViewMatrix(): Matrix;
  43243. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43244. /**
  43245. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43246. * @param meshes Defines the mesh to zoom on
  43247. * @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)
  43248. */
  43249. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43250. /**
  43251. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43252. * The target will be changed but the radius
  43253. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43254. * @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)
  43255. */
  43256. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43257. min: Vector3;
  43258. max: Vector3;
  43259. distance: number;
  43260. }, doNotUpdateMaxZ?: boolean): void;
  43261. /**
  43262. * @override
  43263. * Override Camera.createRigCamera
  43264. */
  43265. createRigCamera(name: string, cameraIndex: number): Camera;
  43266. /**
  43267. * @hidden
  43268. * @override
  43269. * Override Camera._updateRigCameras
  43270. */
  43271. _updateRigCameras(): void;
  43272. /**
  43273. * Destroy the camera and release the current resources hold by it.
  43274. */
  43275. dispose(): void;
  43276. /**
  43277. * Gets the current object class name.
  43278. * @return the class name
  43279. */
  43280. getClassName(): string;
  43281. }
  43282. }
  43283. declare module BABYLON {
  43284. /**
  43285. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43286. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43287. */
  43288. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43289. /**
  43290. * Gets the name of the behavior.
  43291. */
  43292. get name(): string;
  43293. private _zoomStopsAnimation;
  43294. private _idleRotationSpeed;
  43295. private _idleRotationWaitTime;
  43296. private _idleRotationSpinupTime;
  43297. /**
  43298. * Sets the flag that indicates if user zooming should stop animation.
  43299. */
  43300. set zoomStopsAnimation(flag: boolean);
  43301. /**
  43302. * Gets the flag that indicates if user zooming should stop animation.
  43303. */
  43304. get zoomStopsAnimation(): boolean;
  43305. /**
  43306. * Sets the default speed at which the camera rotates around the model.
  43307. */
  43308. set idleRotationSpeed(speed: number);
  43309. /**
  43310. * Gets the default speed at which the camera rotates around the model.
  43311. */
  43312. get idleRotationSpeed(): number;
  43313. /**
  43314. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43315. */
  43316. set idleRotationWaitTime(time: number);
  43317. /**
  43318. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43319. */
  43320. get idleRotationWaitTime(): number;
  43321. /**
  43322. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43323. */
  43324. set idleRotationSpinupTime(time: number);
  43325. /**
  43326. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43327. */
  43328. get idleRotationSpinupTime(): number;
  43329. /**
  43330. * Gets a value indicating if the camera is currently rotating because of this behavior
  43331. */
  43332. get rotationInProgress(): boolean;
  43333. private _onPrePointerObservableObserver;
  43334. private _onAfterCheckInputsObserver;
  43335. private _attachedCamera;
  43336. private _isPointerDown;
  43337. private _lastFrameTime;
  43338. private _lastInteractionTime;
  43339. private _cameraRotationSpeed;
  43340. /**
  43341. * Initializes the behavior.
  43342. */
  43343. init(): void;
  43344. /**
  43345. * Attaches the behavior to its arc rotate camera.
  43346. * @param camera Defines the camera to attach the behavior to
  43347. */
  43348. attach(camera: ArcRotateCamera): void;
  43349. /**
  43350. * Detaches the behavior from its current arc rotate camera.
  43351. */
  43352. detach(): void;
  43353. /**
  43354. * Returns true if user is scrolling.
  43355. * @return true if user is scrolling.
  43356. */
  43357. private _userIsZooming;
  43358. private _lastFrameRadius;
  43359. private _shouldAnimationStopForInteraction;
  43360. /**
  43361. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43362. */
  43363. private _applyUserInteraction;
  43364. private _userIsMoving;
  43365. }
  43366. }
  43367. declare module BABYLON {
  43368. /**
  43369. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43370. */
  43371. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43372. private ui;
  43373. /**
  43374. * The name of the behavior
  43375. */
  43376. name: string;
  43377. /**
  43378. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43379. */
  43380. distanceAwayFromFace: number;
  43381. /**
  43382. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43383. */
  43384. distanceAwayFromBottomOfFace: number;
  43385. private _faceVectors;
  43386. private _target;
  43387. private _scene;
  43388. private _onRenderObserver;
  43389. private _tmpMatrix;
  43390. private _tmpVector;
  43391. /**
  43392. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43393. * @param ui The transform node that should be attched to the mesh
  43394. */
  43395. constructor(ui: TransformNode);
  43396. /**
  43397. * Initializes the behavior
  43398. */
  43399. init(): void;
  43400. private _closestFace;
  43401. private _zeroVector;
  43402. private _lookAtTmpMatrix;
  43403. private _lookAtToRef;
  43404. /**
  43405. * Attaches the AttachToBoxBehavior to the passed in mesh
  43406. * @param target The mesh that the specified node will be attached to
  43407. */
  43408. attach(target: Mesh): void;
  43409. /**
  43410. * Detaches the behavior from the mesh
  43411. */
  43412. detach(): void;
  43413. }
  43414. }
  43415. declare module BABYLON {
  43416. /**
  43417. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43418. */
  43419. export class FadeInOutBehavior implements Behavior<Mesh> {
  43420. /**
  43421. * Time in milliseconds to delay before fading in (Default: 0)
  43422. */
  43423. delay: number;
  43424. /**
  43425. * Time in milliseconds for the mesh to fade in (Default: 300)
  43426. */
  43427. fadeInTime: number;
  43428. private _millisecondsPerFrame;
  43429. private _hovered;
  43430. private _hoverValue;
  43431. private _ownerNode;
  43432. /**
  43433. * Instatiates the FadeInOutBehavior
  43434. */
  43435. constructor();
  43436. /**
  43437. * The name of the behavior
  43438. */
  43439. get name(): string;
  43440. /**
  43441. * Initializes the behavior
  43442. */
  43443. init(): void;
  43444. /**
  43445. * Attaches the fade behavior on the passed in mesh
  43446. * @param ownerNode The mesh that will be faded in/out once attached
  43447. */
  43448. attach(ownerNode: Mesh): void;
  43449. /**
  43450. * Detaches the behavior from the mesh
  43451. */
  43452. detach(): void;
  43453. /**
  43454. * Triggers the mesh to begin fading in or out
  43455. * @param value if the object should fade in or out (true to fade in)
  43456. */
  43457. fadeIn(value: boolean): void;
  43458. private _update;
  43459. private _setAllVisibility;
  43460. }
  43461. }
  43462. declare module BABYLON {
  43463. /**
  43464. * Class containing a set of static utilities functions for managing Pivots
  43465. * @hidden
  43466. */
  43467. export class PivotTools {
  43468. private static _PivotCached;
  43469. private static _OldPivotPoint;
  43470. private static _PivotTranslation;
  43471. private static _PivotTmpVector;
  43472. private static _PivotPostMultiplyPivotMatrix;
  43473. /** @hidden */
  43474. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43475. /** @hidden */
  43476. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43477. }
  43478. }
  43479. declare module BABYLON {
  43480. /**
  43481. * Class containing static functions to help procedurally build meshes
  43482. */
  43483. export class PlaneBuilder {
  43484. /**
  43485. * Creates a plane mesh
  43486. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43487. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43488. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43490. * * 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
  43491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43492. * @param name defines the name of the mesh
  43493. * @param options defines the options used to create the mesh
  43494. * @param scene defines the hosting scene
  43495. * @returns the plane mesh
  43496. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43497. */
  43498. static CreatePlane(name: string, options: {
  43499. size?: number;
  43500. width?: number;
  43501. height?: number;
  43502. sideOrientation?: number;
  43503. frontUVs?: Vector4;
  43504. backUVs?: Vector4;
  43505. updatable?: boolean;
  43506. sourcePlane?: Plane;
  43507. }, scene?: Nullable<Scene>): Mesh;
  43508. }
  43509. }
  43510. declare module BABYLON {
  43511. /**
  43512. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43513. */
  43514. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43515. private static _AnyMouseID;
  43516. /**
  43517. * Abstract mesh the behavior is set on
  43518. */
  43519. attachedNode: AbstractMesh;
  43520. private _dragPlane;
  43521. private _scene;
  43522. private _pointerObserver;
  43523. private _beforeRenderObserver;
  43524. private static _planeScene;
  43525. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43526. /**
  43527. * 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)
  43528. */
  43529. maxDragAngle: number;
  43530. /**
  43531. * @hidden
  43532. */
  43533. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43534. /**
  43535. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43536. */
  43537. currentDraggingPointerID: number;
  43538. /**
  43539. * The last position where the pointer hit the drag plane in world space
  43540. */
  43541. lastDragPosition: Vector3;
  43542. /**
  43543. * If the behavior is currently in a dragging state
  43544. */
  43545. dragging: boolean;
  43546. /**
  43547. * 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)
  43548. */
  43549. dragDeltaRatio: number;
  43550. /**
  43551. * If the drag plane orientation should be updated during the dragging (Default: true)
  43552. */
  43553. updateDragPlane: boolean;
  43554. private _debugMode;
  43555. private _moving;
  43556. /**
  43557. * Fires each time the attached mesh is dragged with the pointer
  43558. * * delta between last drag position and current drag position in world space
  43559. * * dragDistance along the drag axis
  43560. * * dragPlaneNormal normal of the current drag plane used during the drag
  43561. * * dragPlanePoint in world space where the drag intersects the drag plane
  43562. */
  43563. onDragObservable: Observable<{
  43564. delta: Vector3;
  43565. dragPlanePoint: Vector3;
  43566. dragPlaneNormal: Vector3;
  43567. dragDistance: number;
  43568. pointerId: number;
  43569. }>;
  43570. /**
  43571. * Fires each time a drag begins (eg. mouse down on mesh)
  43572. */
  43573. onDragStartObservable: Observable<{
  43574. dragPlanePoint: Vector3;
  43575. pointerId: number;
  43576. }>;
  43577. /**
  43578. * Fires each time a drag ends (eg. mouse release after drag)
  43579. */
  43580. onDragEndObservable: Observable<{
  43581. dragPlanePoint: Vector3;
  43582. pointerId: number;
  43583. }>;
  43584. /**
  43585. * If the attached mesh should be moved when dragged
  43586. */
  43587. moveAttached: boolean;
  43588. /**
  43589. * If the drag behavior will react to drag events (Default: true)
  43590. */
  43591. enabled: boolean;
  43592. /**
  43593. * If pointer events should start and release the drag (Default: true)
  43594. */
  43595. startAndReleaseDragOnPointerEvents: boolean;
  43596. /**
  43597. * If camera controls should be detached during the drag
  43598. */
  43599. detachCameraControls: boolean;
  43600. /**
  43601. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43602. */
  43603. useObjectOrientationForDragging: boolean;
  43604. private _options;
  43605. /**
  43606. * Gets the options used by the behavior
  43607. */
  43608. get options(): {
  43609. dragAxis?: Vector3;
  43610. dragPlaneNormal?: Vector3;
  43611. };
  43612. /**
  43613. * Sets the options used by the behavior
  43614. */
  43615. set options(options: {
  43616. dragAxis?: Vector3;
  43617. dragPlaneNormal?: Vector3;
  43618. });
  43619. /**
  43620. * Creates a pointer drag behavior that can be attached to a mesh
  43621. * @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)
  43622. */
  43623. constructor(options?: {
  43624. dragAxis?: Vector3;
  43625. dragPlaneNormal?: Vector3;
  43626. });
  43627. /**
  43628. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43629. */
  43630. validateDrag: (targetPosition: Vector3) => boolean;
  43631. /**
  43632. * The name of the behavior
  43633. */
  43634. get name(): string;
  43635. /**
  43636. * Initializes the behavior
  43637. */
  43638. init(): void;
  43639. private _tmpVector;
  43640. private _alternatePickedPoint;
  43641. private _worldDragAxis;
  43642. private _targetPosition;
  43643. private _attachedElement;
  43644. /**
  43645. * Attaches the drag behavior the passed in mesh
  43646. * @param ownerNode The mesh that will be dragged around once attached
  43647. * @param predicate Predicate to use for pick filtering
  43648. */
  43649. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43650. /**
  43651. * Force relase the drag action by code.
  43652. */
  43653. releaseDrag(): void;
  43654. private _startDragRay;
  43655. private _lastPointerRay;
  43656. /**
  43657. * Simulates the start of a pointer drag event on the behavior
  43658. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43659. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43660. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43661. */
  43662. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43663. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43664. private _dragDelta;
  43665. protected _moveDrag(ray: Ray): void;
  43666. private _pickWithRayOnDragPlane;
  43667. private _pointA;
  43668. private _pointC;
  43669. private _localAxis;
  43670. private _lookAt;
  43671. private _updateDragPlanePosition;
  43672. /**
  43673. * Detaches the behavior from the mesh
  43674. */
  43675. detach(): void;
  43676. }
  43677. }
  43678. declare module BABYLON {
  43679. /**
  43680. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43681. */
  43682. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43683. private _dragBehaviorA;
  43684. private _dragBehaviorB;
  43685. private _startDistance;
  43686. private _initialScale;
  43687. private _targetScale;
  43688. private _ownerNode;
  43689. private _sceneRenderObserver;
  43690. /**
  43691. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43692. */
  43693. constructor();
  43694. /**
  43695. * The name of the behavior
  43696. */
  43697. get name(): string;
  43698. /**
  43699. * Initializes the behavior
  43700. */
  43701. init(): void;
  43702. private _getCurrentDistance;
  43703. /**
  43704. * Attaches the scale behavior the passed in mesh
  43705. * @param ownerNode The mesh that will be scaled around once attached
  43706. */
  43707. attach(ownerNode: Mesh): void;
  43708. /**
  43709. * Detaches the behavior from the mesh
  43710. */
  43711. detach(): void;
  43712. }
  43713. }
  43714. declare module BABYLON {
  43715. /**
  43716. * 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
  43717. */
  43718. export class SixDofDragBehavior implements Behavior<Mesh> {
  43719. private static _virtualScene;
  43720. private _ownerNode;
  43721. private _sceneRenderObserver;
  43722. private _scene;
  43723. private _targetPosition;
  43724. private _virtualOriginMesh;
  43725. private _virtualDragMesh;
  43726. private _pointerObserver;
  43727. private _moving;
  43728. private _startingOrientation;
  43729. private _attachedElement;
  43730. /**
  43731. * 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)
  43732. */
  43733. private zDragFactor;
  43734. /**
  43735. * If the object should rotate to face the drag origin
  43736. */
  43737. rotateDraggedObject: boolean;
  43738. /**
  43739. * If the behavior is currently in a dragging state
  43740. */
  43741. dragging: boolean;
  43742. /**
  43743. * 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)
  43744. */
  43745. dragDeltaRatio: number;
  43746. /**
  43747. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43748. */
  43749. currentDraggingPointerID: number;
  43750. /**
  43751. * If camera controls should be detached during the drag
  43752. */
  43753. detachCameraControls: boolean;
  43754. /**
  43755. * Fires each time a drag starts
  43756. */
  43757. onDragStartObservable: Observable<{}>;
  43758. /**
  43759. * Fires each time a drag ends (eg. mouse release after drag)
  43760. */
  43761. onDragEndObservable: Observable<{}>;
  43762. /**
  43763. * 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
  43764. */
  43765. constructor();
  43766. /**
  43767. * The name of the behavior
  43768. */
  43769. get name(): string;
  43770. /**
  43771. * Initializes the behavior
  43772. */
  43773. init(): void;
  43774. /**
  43775. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43776. */
  43777. private get _pointerCamera();
  43778. /**
  43779. * Attaches the scale behavior the passed in mesh
  43780. * @param ownerNode The mesh that will be scaled around once attached
  43781. */
  43782. attach(ownerNode: Mesh): void;
  43783. /**
  43784. * Detaches the behavior from the mesh
  43785. */
  43786. detach(): void;
  43787. }
  43788. }
  43789. declare module BABYLON {
  43790. /**
  43791. * Class used to apply inverse kinematics to bones
  43792. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43793. */
  43794. export class BoneIKController {
  43795. private static _tmpVecs;
  43796. private static _tmpQuat;
  43797. private static _tmpMats;
  43798. /**
  43799. * Gets or sets the target mesh
  43800. */
  43801. targetMesh: AbstractMesh;
  43802. /** Gets or sets the mesh used as pole */
  43803. poleTargetMesh: AbstractMesh;
  43804. /**
  43805. * Gets or sets the bone used as pole
  43806. */
  43807. poleTargetBone: Nullable<Bone>;
  43808. /**
  43809. * Gets or sets the target position
  43810. */
  43811. targetPosition: Vector3;
  43812. /**
  43813. * Gets or sets the pole target position
  43814. */
  43815. poleTargetPosition: Vector3;
  43816. /**
  43817. * Gets or sets the pole target local offset
  43818. */
  43819. poleTargetLocalOffset: Vector3;
  43820. /**
  43821. * Gets or sets the pole angle
  43822. */
  43823. poleAngle: number;
  43824. /**
  43825. * Gets or sets the mesh associated with the controller
  43826. */
  43827. mesh: AbstractMesh;
  43828. /**
  43829. * 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)
  43830. */
  43831. slerpAmount: number;
  43832. private _bone1Quat;
  43833. private _bone1Mat;
  43834. private _bone2Ang;
  43835. private _bone1;
  43836. private _bone2;
  43837. private _bone1Length;
  43838. private _bone2Length;
  43839. private _maxAngle;
  43840. private _maxReach;
  43841. private _rightHandedSystem;
  43842. private _bendAxis;
  43843. private _slerping;
  43844. private _adjustRoll;
  43845. /**
  43846. * Gets or sets maximum allowed angle
  43847. */
  43848. get maxAngle(): number;
  43849. set maxAngle(value: number);
  43850. /**
  43851. * Creates a new BoneIKController
  43852. * @param mesh defines the mesh to control
  43853. * @param bone defines the bone to control
  43854. * @param options defines options to set up the controller
  43855. */
  43856. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43857. targetMesh?: AbstractMesh;
  43858. poleTargetMesh?: AbstractMesh;
  43859. poleTargetBone?: Bone;
  43860. poleTargetLocalOffset?: Vector3;
  43861. poleAngle?: number;
  43862. bendAxis?: Vector3;
  43863. maxAngle?: number;
  43864. slerpAmount?: number;
  43865. });
  43866. private _setMaxAngle;
  43867. /**
  43868. * Force the controller to update the bones
  43869. */
  43870. update(): void;
  43871. }
  43872. }
  43873. declare module BABYLON {
  43874. /**
  43875. * Class used to make a bone look toward a point in space
  43876. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43877. */
  43878. export class BoneLookController {
  43879. private static _tmpVecs;
  43880. private static _tmpQuat;
  43881. private static _tmpMats;
  43882. /**
  43883. * The target Vector3 that the bone will look at
  43884. */
  43885. target: Vector3;
  43886. /**
  43887. * The mesh that the bone is attached to
  43888. */
  43889. mesh: AbstractMesh;
  43890. /**
  43891. * The bone that will be looking to the target
  43892. */
  43893. bone: Bone;
  43894. /**
  43895. * The up axis of the coordinate system that is used when the bone is rotated
  43896. */
  43897. upAxis: Vector3;
  43898. /**
  43899. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43900. */
  43901. upAxisSpace: Space;
  43902. /**
  43903. * Used to make an adjustment to the yaw of the bone
  43904. */
  43905. adjustYaw: number;
  43906. /**
  43907. * Used to make an adjustment to the pitch of the bone
  43908. */
  43909. adjustPitch: number;
  43910. /**
  43911. * Used to make an adjustment to the roll of the bone
  43912. */
  43913. adjustRoll: number;
  43914. /**
  43915. * 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)
  43916. */
  43917. slerpAmount: number;
  43918. private _minYaw;
  43919. private _maxYaw;
  43920. private _minPitch;
  43921. private _maxPitch;
  43922. private _minYawSin;
  43923. private _minYawCos;
  43924. private _maxYawSin;
  43925. private _maxYawCos;
  43926. private _midYawConstraint;
  43927. private _minPitchTan;
  43928. private _maxPitchTan;
  43929. private _boneQuat;
  43930. private _slerping;
  43931. private _transformYawPitch;
  43932. private _transformYawPitchInv;
  43933. private _firstFrameSkipped;
  43934. private _yawRange;
  43935. private _fowardAxis;
  43936. /**
  43937. * Gets or sets the minimum yaw angle that the bone can look to
  43938. */
  43939. get minYaw(): number;
  43940. set minYaw(value: number);
  43941. /**
  43942. * Gets or sets the maximum yaw angle that the bone can look to
  43943. */
  43944. get maxYaw(): number;
  43945. set maxYaw(value: number);
  43946. /**
  43947. * Gets or sets the minimum pitch angle that the bone can look to
  43948. */
  43949. get minPitch(): number;
  43950. set minPitch(value: number);
  43951. /**
  43952. * Gets or sets the maximum pitch angle that the bone can look to
  43953. */
  43954. get maxPitch(): number;
  43955. set maxPitch(value: number);
  43956. /**
  43957. * Create a BoneLookController
  43958. * @param mesh the mesh that the bone belongs to
  43959. * @param bone the bone that will be looking to the target
  43960. * @param target the target Vector3 to look at
  43961. * @param options optional settings:
  43962. * * maxYaw: the maximum angle the bone will yaw to
  43963. * * minYaw: the minimum angle the bone will yaw to
  43964. * * maxPitch: the maximum angle the bone will pitch to
  43965. * * minPitch: the minimum angle the bone will yaw to
  43966. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43967. * * upAxis: the up axis of the coordinate system
  43968. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43969. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43970. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43971. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43972. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43973. * * adjustRoll: used to make an adjustment to the roll of the bone
  43974. **/
  43975. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43976. maxYaw?: number;
  43977. minYaw?: number;
  43978. maxPitch?: number;
  43979. minPitch?: number;
  43980. slerpAmount?: number;
  43981. upAxis?: Vector3;
  43982. upAxisSpace?: Space;
  43983. yawAxis?: Vector3;
  43984. pitchAxis?: Vector3;
  43985. adjustYaw?: number;
  43986. adjustPitch?: number;
  43987. adjustRoll?: number;
  43988. });
  43989. /**
  43990. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43991. */
  43992. update(): void;
  43993. private _getAngleDiff;
  43994. private _getAngleBetween;
  43995. private _isAngleBetween;
  43996. }
  43997. }
  43998. declare module BABYLON {
  43999. /**
  44000. * Manage the gamepad inputs to control an arc rotate camera.
  44001. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44002. */
  44003. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44004. /**
  44005. * Defines the camera the input is attached to.
  44006. */
  44007. camera: ArcRotateCamera;
  44008. /**
  44009. * Defines the gamepad the input is gathering event from.
  44010. */
  44011. gamepad: Nullable<Gamepad>;
  44012. /**
  44013. * Defines the gamepad rotation sensiblity.
  44014. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44015. */
  44016. gamepadRotationSensibility: number;
  44017. /**
  44018. * Defines the gamepad move sensiblity.
  44019. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44020. */
  44021. gamepadMoveSensibility: number;
  44022. private _yAxisScale;
  44023. /**
  44024. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44025. */
  44026. get invertYAxis(): boolean;
  44027. set invertYAxis(value: boolean);
  44028. private _onGamepadConnectedObserver;
  44029. private _onGamepadDisconnectedObserver;
  44030. /**
  44031. * Attach the input controls to a specific dom element to get the input from.
  44032. * @param element Defines the element the controls should be listened from
  44033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44034. */
  44035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44036. /**
  44037. * Detach the current controls from the specified dom element.
  44038. * @param element Defines the element to stop listening the inputs from
  44039. */
  44040. detachControl(element: Nullable<HTMLElement>): void;
  44041. /**
  44042. * Update the current camera state depending on the inputs that have been used this frame.
  44043. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44044. */
  44045. checkInputs(): void;
  44046. /**
  44047. * Gets the class name of the current intput.
  44048. * @returns the class name
  44049. */
  44050. getClassName(): string;
  44051. /**
  44052. * Get the friendly name associated with the input class.
  44053. * @returns the input friendly name
  44054. */
  44055. getSimpleName(): string;
  44056. }
  44057. }
  44058. declare module BABYLON {
  44059. interface ArcRotateCameraInputsManager {
  44060. /**
  44061. * Add orientation input support to the input manager.
  44062. * @returns the current input manager
  44063. */
  44064. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44065. }
  44066. /**
  44067. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44068. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44069. */
  44070. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44071. /**
  44072. * Defines the camera the input is attached to.
  44073. */
  44074. camera: ArcRotateCamera;
  44075. /**
  44076. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44077. */
  44078. alphaCorrection: number;
  44079. /**
  44080. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44081. */
  44082. gammaCorrection: number;
  44083. private _alpha;
  44084. private _gamma;
  44085. private _dirty;
  44086. private _deviceOrientationHandler;
  44087. /**
  44088. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44089. */
  44090. constructor();
  44091. /**
  44092. * Attach the input controls to a specific dom element to get the input from.
  44093. * @param element Defines the element the controls should be listened from
  44094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44095. */
  44096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44097. /** @hidden */
  44098. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44099. /**
  44100. * Update the current camera state depending on the inputs that have been used this frame.
  44101. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44102. */
  44103. checkInputs(): void;
  44104. /**
  44105. * Detach the current controls from the specified dom element.
  44106. * @param element Defines the element to stop listening the inputs from
  44107. */
  44108. detachControl(element: Nullable<HTMLElement>): void;
  44109. /**
  44110. * Gets the class name of the current intput.
  44111. * @returns the class name
  44112. */
  44113. getClassName(): string;
  44114. /**
  44115. * Get the friendly name associated with the input class.
  44116. * @returns the input friendly name
  44117. */
  44118. getSimpleName(): string;
  44119. }
  44120. }
  44121. declare module BABYLON {
  44122. /**
  44123. * Listen to mouse events to control the camera.
  44124. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44125. */
  44126. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44127. /**
  44128. * Defines the camera the input is attached to.
  44129. */
  44130. camera: FlyCamera;
  44131. /**
  44132. * Defines if touch is enabled. (Default is true.)
  44133. */
  44134. touchEnabled: boolean;
  44135. /**
  44136. * Defines the buttons associated with the input to handle camera rotation.
  44137. */
  44138. buttons: number[];
  44139. /**
  44140. * Assign buttons for Yaw control.
  44141. */
  44142. buttonsYaw: number[];
  44143. /**
  44144. * Assign buttons for Pitch control.
  44145. */
  44146. buttonsPitch: number[];
  44147. /**
  44148. * Assign buttons for Roll control.
  44149. */
  44150. buttonsRoll: number[];
  44151. /**
  44152. * Detect if any button is being pressed while mouse is moved.
  44153. * -1 = Mouse locked.
  44154. * 0 = Left button.
  44155. * 1 = Middle Button.
  44156. * 2 = Right Button.
  44157. */
  44158. activeButton: number;
  44159. /**
  44160. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44161. * Higher values reduce its sensitivity.
  44162. */
  44163. angularSensibility: number;
  44164. private _mousemoveCallback;
  44165. private _observer;
  44166. private _rollObserver;
  44167. private previousPosition;
  44168. private noPreventDefault;
  44169. private element;
  44170. /**
  44171. * Listen to mouse events to control the camera.
  44172. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44173. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44174. */
  44175. constructor(touchEnabled?: boolean);
  44176. /**
  44177. * Attach the mouse control to the HTML DOM element.
  44178. * @param element Defines the element that listens to the input events.
  44179. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44180. */
  44181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44182. /**
  44183. * Detach the current controls from the specified dom element.
  44184. * @param element Defines the element to stop listening the inputs from
  44185. */
  44186. detachControl(element: Nullable<HTMLElement>): void;
  44187. /**
  44188. * Gets the class name of the current input.
  44189. * @returns the class name.
  44190. */
  44191. getClassName(): string;
  44192. /**
  44193. * Get the friendly name associated with the input class.
  44194. * @returns the input's friendly name.
  44195. */
  44196. getSimpleName(): string;
  44197. private _pointerInput;
  44198. private _onMouseMove;
  44199. /**
  44200. * Rotate camera by mouse offset.
  44201. */
  44202. private rotateCamera;
  44203. }
  44204. }
  44205. declare module BABYLON {
  44206. /**
  44207. * Default Inputs manager for the FlyCamera.
  44208. * It groups all the default supported inputs for ease of use.
  44209. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44210. */
  44211. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44212. /**
  44213. * Instantiates a new FlyCameraInputsManager.
  44214. * @param camera Defines the camera the inputs belong to.
  44215. */
  44216. constructor(camera: FlyCamera);
  44217. /**
  44218. * Add keyboard input support to the input manager.
  44219. * @returns the new FlyCameraKeyboardMoveInput().
  44220. */
  44221. addKeyboard(): FlyCameraInputsManager;
  44222. /**
  44223. * Add mouse input support to the input manager.
  44224. * @param touchEnabled Enable touch screen support.
  44225. * @returns the new FlyCameraMouseInput().
  44226. */
  44227. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44228. }
  44229. }
  44230. declare module BABYLON {
  44231. /**
  44232. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44233. * such as in a 3D Space Shooter or a Flight Simulator.
  44234. */
  44235. export class FlyCamera extends TargetCamera {
  44236. /**
  44237. * Define the collision ellipsoid of the camera.
  44238. * This is helpful for simulating a camera body, like a player's body.
  44239. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44240. */
  44241. ellipsoid: Vector3;
  44242. /**
  44243. * Define an offset for the position of the ellipsoid around the camera.
  44244. * This can be helpful if the camera is attached away from the player's body center,
  44245. * such as at its head.
  44246. */
  44247. ellipsoidOffset: Vector3;
  44248. /**
  44249. * Enable or disable collisions of the camera with the rest of the scene objects.
  44250. */
  44251. checkCollisions: boolean;
  44252. /**
  44253. * Enable or disable gravity on the camera.
  44254. */
  44255. applyGravity: boolean;
  44256. /**
  44257. * Define the current direction the camera is moving to.
  44258. */
  44259. cameraDirection: Vector3;
  44260. /**
  44261. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44262. * This overrides and empties cameraRotation.
  44263. */
  44264. rotationQuaternion: Quaternion;
  44265. /**
  44266. * Track Roll to maintain the wanted Rolling when looking around.
  44267. */
  44268. _trackRoll: number;
  44269. /**
  44270. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44271. */
  44272. rollCorrect: number;
  44273. /**
  44274. * Mimic a banked turn, Rolling the camera when Yawing.
  44275. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44276. */
  44277. bankedTurn: boolean;
  44278. /**
  44279. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44280. */
  44281. bankedTurnLimit: number;
  44282. /**
  44283. * Value of 0 disables the banked Roll.
  44284. * Value of 1 is equal to the Yaw angle in radians.
  44285. */
  44286. bankedTurnMultiplier: number;
  44287. /**
  44288. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44289. */
  44290. inputs: FlyCameraInputsManager;
  44291. /**
  44292. * Gets the input sensibility for mouse input.
  44293. * Higher values reduce sensitivity.
  44294. */
  44295. get angularSensibility(): number;
  44296. /**
  44297. * Sets the input sensibility for a mouse input.
  44298. * Higher values reduce sensitivity.
  44299. */
  44300. set angularSensibility(value: number);
  44301. /**
  44302. * Get the keys for camera movement forward.
  44303. */
  44304. get keysForward(): number[];
  44305. /**
  44306. * Set the keys for camera movement forward.
  44307. */
  44308. set keysForward(value: number[]);
  44309. /**
  44310. * Get the keys for camera movement backward.
  44311. */
  44312. get keysBackward(): number[];
  44313. set keysBackward(value: number[]);
  44314. /**
  44315. * Get the keys for camera movement up.
  44316. */
  44317. get keysUp(): number[];
  44318. /**
  44319. * Set the keys for camera movement up.
  44320. */
  44321. set keysUp(value: number[]);
  44322. /**
  44323. * Get the keys for camera movement down.
  44324. */
  44325. get keysDown(): number[];
  44326. /**
  44327. * Set the keys for camera movement down.
  44328. */
  44329. set keysDown(value: number[]);
  44330. /**
  44331. * Get the keys for camera movement left.
  44332. */
  44333. get keysLeft(): number[];
  44334. /**
  44335. * Set the keys for camera movement left.
  44336. */
  44337. set keysLeft(value: number[]);
  44338. /**
  44339. * Set the keys for camera movement right.
  44340. */
  44341. get keysRight(): number[];
  44342. /**
  44343. * Set the keys for camera movement right.
  44344. */
  44345. set keysRight(value: number[]);
  44346. /**
  44347. * Event raised when the camera collides with a mesh in the scene.
  44348. */
  44349. onCollide: (collidedMesh: AbstractMesh) => void;
  44350. private _collider;
  44351. private _needMoveForGravity;
  44352. private _oldPosition;
  44353. private _diffPosition;
  44354. private _newPosition;
  44355. /** @hidden */
  44356. _localDirection: Vector3;
  44357. /** @hidden */
  44358. _transformedDirection: Vector3;
  44359. /**
  44360. * Instantiates a FlyCamera.
  44361. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44362. * such as in a 3D Space Shooter or a Flight Simulator.
  44363. * @param name Define the name of the camera in the scene.
  44364. * @param position Define the starting position of the camera in the scene.
  44365. * @param scene Define the scene the camera belongs to.
  44366. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44367. */
  44368. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44369. /**
  44370. * Attach a control to the HTML DOM element.
  44371. * @param element Defines the element that listens to the input events.
  44372. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44373. */
  44374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44375. /**
  44376. * Detach a control from the HTML DOM element.
  44377. * The camera will stop reacting to that input.
  44378. * @param element Defines the element that listens to the input events.
  44379. */
  44380. detachControl(element: HTMLElement): void;
  44381. private _collisionMask;
  44382. /**
  44383. * Get the mask that the camera ignores in collision events.
  44384. */
  44385. get collisionMask(): number;
  44386. /**
  44387. * Set the mask that the camera ignores in collision events.
  44388. */
  44389. set collisionMask(mask: number);
  44390. /** @hidden */
  44391. _collideWithWorld(displacement: Vector3): void;
  44392. /** @hidden */
  44393. private _onCollisionPositionChange;
  44394. /** @hidden */
  44395. _checkInputs(): void;
  44396. /** @hidden */
  44397. _decideIfNeedsToMove(): boolean;
  44398. /** @hidden */
  44399. _updatePosition(): void;
  44400. /**
  44401. * Restore the Roll to its target value at the rate specified.
  44402. * @param rate - Higher means slower restoring.
  44403. * @hidden
  44404. */
  44405. restoreRoll(rate: number): void;
  44406. /**
  44407. * Destroy the camera and release the current resources held by it.
  44408. */
  44409. dispose(): void;
  44410. /**
  44411. * Get the current object class name.
  44412. * @returns the class name.
  44413. */
  44414. getClassName(): string;
  44415. }
  44416. }
  44417. declare module BABYLON {
  44418. /**
  44419. * Listen to keyboard events to control the camera.
  44420. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44421. */
  44422. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44423. /**
  44424. * Defines the camera the input is attached to.
  44425. */
  44426. camera: FlyCamera;
  44427. /**
  44428. * The list of keyboard keys used to control the forward move of the camera.
  44429. */
  44430. keysForward: number[];
  44431. /**
  44432. * The list of keyboard keys used to control the backward move of the camera.
  44433. */
  44434. keysBackward: number[];
  44435. /**
  44436. * The list of keyboard keys used to control the forward move of the camera.
  44437. */
  44438. keysUp: number[];
  44439. /**
  44440. * The list of keyboard keys used to control the backward move of the camera.
  44441. */
  44442. keysDown: number[];
  44443. /**
  44444. * The list of keyboard keys used to control the right strafe move of the camera.
  44445. */
  44446. keysRight: number[];
  44447. /**
  44448. * The list of keyboard keys used to control the left strafe move of the camera.
  44449. */
  44450. keysLeft: number[];
  44451. private _keys;
  44452. private _onCanvasBlurObserver;
  44453. private _onKeyboardObserver;
  44454. private _engine;
  44455. private _scene;
  44456. /**
  44457. * Attach the input controls to a specific dom element to get the input from.
  44458. * @param element Defines the element the controls should be listened from
  44459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44460. */
  44461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44462. /**
  44463. * Detach the current controls from the specified dom element.
  44464. * @param element Defines the element to stop listening the inputs from
  44465. */
  44466. detachControl(element: Nullable<HTMLElement>): void;
  44467. /**
  44468. * Gets the class name of the current intput.
  44469. * @returns the class name
  44470. */
  44471. getClassName(): string;
  44472. /** @hidden */
  44473. _onLostFocus(e: FocusEvent): void;
  44474. /**
  44475. * Get the friendly name associated with the input class.
  44476. * @returns the input friendly name
  44477. */
  44478. getSimpleName(): string;
  44479. /**
  44480. * Update the current camera state depending on the inputs that have been used this frame.
  44481. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44482. */
  44483. checkInputs(): void;
  44484. }
  44485. }
  44486. declare module BABYLON {
  44487. /**
  44488. * Manage the mouse wheel inputs to control a follow camera.
  44489. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44490. */
  44491. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44492. /**
  44493. * Defines the camera the input is attached to.
  44494. */
  44495. camera: FollowCamera;
  44496. /**
  44497. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44498. */
  44499. axisControlRadius: boolean;
  44500. /**
  44501. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44502. */
  44503. axisControlHeight: boolean;
  44504. /**
  44505. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44506. */
  44507. axisControlRotation: boolean;
  44508. /**
  44509. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44510. * relation to mouseWheel events.
  44511. */
  44512. wheelPrecision: number;
  44513. /**
  44514. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44515. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44516. */
  44517. wheelDeltaPercentage: number;
  44518. private _wheel;
  44519. private _observer;
  44520. /**
  44521. * Attach the input controls to a specific dom element to get the input from.
  44522. * @param element Defines the element the controls should be listened from
  44523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44524. */
  44525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44526. /**
  44527. * Detach the current controls from the specified dom element.
  44528. * @param element Defines the element to stop listening the inputs from
  44529. */
  44530. detachControl(element: Nullable<HTMLElement>): void;
  44531. /**
  44532. * Gets the class name of the current intput.
  44533. * @returns the class name
  44534. */
  44535. getClassName(): string;
  44536. /**
  44537. * Get the friendly name associated with the input class.
  44538. * @returns the input friendly name
  44539. */
  44540. getSimpleName(): string;
  44541. }
  44542. }
  44543. declare module BABYLON {
  44544. /**
  44545. * Manage the pointers inputs to control an follow camera.
  44546. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44547. */
  44548. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44549. /**
  44550. * Defines the camera the input is attached to.
  44551. */
  44552. camera: FollowCamera;
  44553. /**
  44554. * Gets the class name of the current input.
  44555. * @returns the class name
  44556. */
  44557. getClassName(): string;
  44558. /**
  44559. * Defines the pointer angular sensibility along the X axis or how fast is
  44560. * the camera rotating.
  44561. * A negative number will reverse the axis direction.
  44562. */
  44563. angularSensibilityX: number;
  44564. /**
  44565. * Defines the pointer angular sensibility along the Y axis or how fast is
  44566. * the camera rotating.
  44567. * A negative number will reverse the axis direction.
  44568. */
  44569. angularSensibilityY: number;
  44570. /**
  44571. * Defines the pointer pinch precision or how fast is the camera zooming.
  44572. * A negative number will reverse the axis direction.
  44573. */
  44574. pinchPrecision: number;
  44575. /**
  44576. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44577. * from 0.
  44578. * It defines the percentage of current camera.radius to use as delta when
  44579. * pinch zoom is used.
  44580. */
  44581. pinchDeltaPercentage: number;
  44582. /**
  44583. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44584. */
  44585. axisXControlRadius: boolean;
  44586. /**
  44587. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44588. */
  44589. axisXControlHeight: boolean;
  44590. /**
  44591. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44592. */
  44593. axisXControlRotation: boolean;
  44594. /**
  44595. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44596. */
  44597. axisYControlRadius: boolean;
  44598. /**
  44599. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44600. */
  44601. axisYControlHeight: boolean;
  44602. /**
  44603. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44604. */
  44605. axisYControlRotation: boolean;
  44606. /**
  44607. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44608. */
  44609. axisPinchControlRadius: boolean;
  44610. /**
  44611. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44612. */
  44613. axisPinchControlHeight: boolean;
  44614. /**
  44615. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44616. */
  44617. axisPinchControlRotation: boolean;
  44618. /**
  44619. * Log error messages if basic misconfiguration has occurred.
  44620. */
  44621. warningEnable: boolean;
  44622. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44623. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44624. private _warningCounter;
  44625. private _warning;
  44626. }
  44627. }
  44628. declare module BABYLON {
  44629. /**
  44630. * Default Inputs manager for the FollowCamera.
  44631. * It groups all the default supported inputs for ease of use.
  44632. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44633. */
  44634. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44635. /**
  44636. * Instantiates a new FollowCameraInputsManager.
  44637. * @param camera Defines the camera the inputs belong to
  44638. */
  44639. constructor(camera: FollowCamera);
  44640. /**
  44641. * Add keyboard input support to the input manager.
  44642. * @returns the current input manager
  44643. */
  44644. addKeyboard(): FollowCameraInputsManager;
  44645. /**
  44646. * Add mouse wheel input support to the input manager.
  44647. * @returns the current input manager
  44648. */
  44649. addMouseWheel(): FollowCameraInputsManager;
  44650. /**
  44651. * Add pointers input support to the input manager.
  44652. * @returns the current input manager
  44653. */
  44654. addPointers(): FollowCameraInputsManager;
  44655. /**
  44656. * Add orientation input support to the input manager.
  44657. * @returns the current input manager
  44658. */
  44659. addVRDeviceOrientation(): FollowCameraInputsManager;
  44660. }
  44661. }
  44662. declare module BABYLON {
  44663. /**
  44664. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44665. * an arc rotate version arcFollowCamera are available.
  44666. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44667. */
  44668. export class FollowCamera extends TargetCamera {
  44669. /**
  44670. * Distance the follow camera should follow an object at
  44671. */
  44672. radius: number;
  44673. /**
  44674. * Minimum allowed distance of the camera to the axis of rotation
  44675. * (The camera can not get closer).
  44676. * This can help limiting how the Camera is able to move in the scene.
  44677. */
  44678. lowerRadiusLimit: Nullable<number>;
  44679. /**
  44680. * Maximum allowed distance of the camera to the axis of rotation
  44681. * (The camera can not get further).
  44682. * This can help limiting how the Camera is able to move in the scene.
  44683. */
  44684. upperRadiusLimit: Nullable<number>;
  44685. /**
  44686. * Define a rotation offset between the camera and the object it follows
  44687. */
  44688. rotationOffset: number;
  44689. /**
  44690. * Minimum allowed angle to camera position relative to target object.
  44691. * This can help limiting how the Camera is able to move in the scene.
  44692. */
  44693. lowerRotationOffsetLimit: Nullable<number>;
  44694. /**
  44695. * Maximum allowed angle to camera position relative to target object.
  44696. * This can help limiting how the Camera is able to move in the scene.
  44697. */
  44698. upperRotationOffsetLimit: Nullable<number>;
  44699. /**
  44700. * Define a height offset between the camera and the object it follows.
  44701. * It can help following an object from the top (like a car chaing a plane)
  44702. */
  44703. heightOffset: number;
  44704. /**
  44705. * Minimum allowed height of camera position relative to target object.
  44706. * This can help limiting how the Camera is able to move in the scene.
  44707. */
  44708. lowerHeightOffsetLimit: Nullable<number>;
  44709. /**
  44710. * Maximum allowed height of camera position relative to target object.
  44711. * This can help limiting how the Camera is able to move in the scene.
  44712. */
  44713. upperHeightOffsetLimit: Nullable<number>;
  44714. /**
  44715. * Define how fast the camera can accelerate to follow it s target.
  44716. */
  44717. cameraAcceleration: number;
  44718. /**
  44719. * Define the speed limit of the camera following an object.
  44720. */
  44721. maxCameraSpeed: number;
  44722. /**
  44723. * Define the target of the camera.
  44724. */
  44725. lockedTarget: Nullable<AbstractMesh>;
  44726. /**
  44727. * Defines the input associated with the camera.
  44728. */
  44729. inputs: FollowCameraInputsManager;
  44730. /**
  44731. * Instantiates the follow camera.
  44732. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44733. * @param name Define the name of the camera in the scene
  44734. * @param position Define the position of the camera
  44735. * @param scene Define the scene the camera belong to
  44736. * @param lockedTarget Define the target of the camera
  44737. */
  44738. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44739. private _follow;
  44740. /**
  44741. * Attached controls to the current camera.
  44742. * @param element Defines the element the controls should be listened from
  44743. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44744. */
  44745. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44746. /**
  44747. * Detach the current controls from the camera.
  44748. * The camera will stop reacting to inputs.
  44749. * @param element Defines the element to stop listening the inputs from
  44750. */
  44751. detachControl(element: HTMLElement): void;
  44752. /** @hidden */
  44753. _checkInputs(): void;
  44754. private _checkLimits;
  44755. /**
  44756. * Gets the camera class name.
  44757. * @returns the class name
  44758. */
  44759. getClassName(): string;
  44760. }
  44761. /**
  44762. * Arc Rotate version of the follow camera.
  44763. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44764. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44765. */
  44766. export class ArcFollowCamera extends TargetCamera {
  44767. /** The longitudinal angle of the camera */
  44768. alpha: number;
  44769. /** The latitudinal angle of the camera */
  44770. beta: number;
  44771. /** The radius of the camera from its target */
  44772. radius: number;
  44773. private _cartesianCoordinates;
  44774. /** Define the camera target (the mesh it should follow) */
  44775. private _meshTarget;
  44776. /**
  44777. * Instantiates a new ArcFollowCamera
  44778. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44779. * @param name Define the name of the camera
  44780. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44781. * @param beta Define the rotation angle of the camera around the elevation axis
  44782. * @param radius Define the radius of the camera from its target point
  44783. * @param target Define the target of the camera
  44784. * @param scene Define the scene the camera belongs to
  44785. */
  44786. constructor(name: string,
  44787. /** The longitudinal angle of the camera */
  44788. alpha: number,
  44789. /** The latitudinal angle of the camera */
  44790. beta: number,
  44791. /** The radius of the camera from its target */
  44792. radius: number,
  44793. /** Define the camera target (the mesh it should follow) */
  44794. target: Nullable<AbstractMesh>, scene: Scene);
  44795. private _follow;
  44796. /** @hidden */
  44797. _checkInputs(): void;
  44798. /**
  44799. * Returns the class name of the object.
  44800. * It is mostly used internally for serialization purposes.
  44801. */
  44802. getClassName(): string;
  44803. }
  44804. }
  44805. declare module BABYLON {
  44806. /**
  44807. * Manage the keyboard inputs to control the movement of a follow camera.
  44808. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44809. */
  44810. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44811. /**
  44812. * Defines the camera the input is attached to.
  44813. */
  44814. camera: FollowCamera;
  44815. /**
  44816. * Defines the list of key codes associated with the up action (increase heightOffset)
  44817. */
  44818. keysHeightOffsetIncr: number[];
  44819. /**
  44820. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44821. */
  44822. keysHeightOffsetDecr: number[];
  44823. /**
  44824. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44825. */
  44826. keysHeightOffsetModifierAlt: boolean;
  44827. /**
  44828. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44829. */
  44830. keysHeightOffsetModifierCtrl: boolean;
  44831. /**
  44832. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44833. */
  44834. keysHeightOffsetModifierShift: boolean;
  44835. /**
  44836. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44837. */
  44838. keysRotationOffsetIncr: number[];
  44839. /**
  44840. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44841. */
  44842. keysRotationOffsetDecr: number[];
  44843. /**
  44844. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44845. */
  44846. keysRotationOffsetModifierAlt: boolean;
  44847. /**
  44848. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44849. */
  44850. keysRotationOffsetModifierCtrl: boolean;
  44851. /**
  44852. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44853. */
  44854. keysRotationOffsetModifierShift: boolean;
  44855. /**
  44856. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44857. */
  44858. keysRadiusIncr: number[];
  44859. /**
  44860. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44861. */
  44862. keysRadiusDecr: number[];
  44863. /**
  44864. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44865. */
  44866. keysRadiusModifierAlt: boolean;
  44867. /**
  44868. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44869. */
  44870. keysRadiusModifierCtrl: boolean;
  44871. /**
  44872. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44873. */
  44874. keysRadiusModifierShift: boolean;
  44875. /**
  44876. * Defines the rate of change of heightOffset.
  44877. */
  44878. heightSensibility: number;
  44879. /**
  44880. * Defines the rate of change of rotationOffset.
  44881. */
  44882. rotationSensibility: number;
  44883. /**
  44884. * Defines the rate of change of radius.
  44885. */
  44886. radiusSensibility: number;
  44887. private _keys;
  44888. private _ctrlPressed;
  44889. private _altPressed;
  44890. private _shiftPressed;
  44891. private _onCanvasBlurObserver;
  44892. private _onKeyboardObserver;
  44893. private _engine;
  44894. private _scene;
  44895. /**
  44896. * Attach the input controls to a specific dom element to get the input from.
  44897. * @param element Defines the element the controls should be listened from
  44898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44899. */
  44900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44901. /**
  44902. * Detach the current controls from the specified dom element.
  44903. * @param element Defines the element to stop listening the inputs from
  44904. */
  44905. detachControl(element: Nullable<HTMLElement>): void;
  44906. /**
  44907. * Update the current camera state depending on the inputs that have been used this frame.
  44908. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44909. */
  44910. checkInputs(): void;
  44911. /**
  44912. * Gets the class name of the current input.
  44913. * @returns the class name
  44914. */
  44915. getClassName(): string;
  44916. /**
  44917. * Get the friendly name associated with the input class.
  44918. * @returns the input friendly name
  44919. */
  44920. getSimpleName(): string;
  44921. /**
  44922. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44923. * allow modification of the heightOffset value.
  44924. */
  44925. private _modifierHeightOffset;
  44926. /**
  44927. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44928. * allow modification of the rotationOffset value.
  44929. */
  44930. private _modifierRotationOffset;
  44931. /**
  44932. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44933. * allow modification of the radius value.
  44934. */
  44935. private _modifierRadius;
  44936. }
  44937. }
  44938. declare module BABYLON {
  44939. interface FreeCameraInputsManager {
  44940. /**
  44941. * @hidden
  44942. */
  44943. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44944. /**
  44945. * Add orientation input support to the input manager.
  44946. * @returns the current input manager
  44947. */
  44948. addDeviceOrientation(): FreeCameraInputsManager;
  44949. }
  44950. /**
  44951. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44952. * Screen rotation is taken into account.
  44953. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44954. */
  44955. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44956. private _camera;
  44957. private _screenOrientationAngle;
  44958. private _constantTranform;
  44959. private _screenQuaternion;
  44960. private _alpha;
  44961. private _beta;
  44962. private _gamma;
  44963. /**
  44964. * Can be used to detect if a device orientation sensor is available on a device
  44965. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44966. * @returns a promise that will resolve on orientation change
  44967. */
  44968. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44969. /**
  44970. * @hidden
  44971. */
  44972. _onDeviceOrientationChangedObservable: Observable<void>;
  44973. /**
  44974. * Instantiates a new input
  44975. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44976. */
  44977. constructor();
  44978. /**
  44979. * Define the camera controlled by the input.
  44980. */
  44981. get camera(): FreeCamera;
  44982. set camera(camera: FreeCamera);
  44983. /**
  44984. * Attach the input controls to a specific dom element to get the input from.
  44985. * @param element Defines the element the controls should be listened from
  44986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44987. */
  44988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44989. private _orientationChanged;
  44990. private _deviceOrientation;
  44991. /**
  44992. * Detach the current controls from the specified dom element.
  44993. * @param element Defines the element to stop listening the inputs from
  44994. */
  44995. detachControl(element: Nullable<HTMLElement>): void;
  44996. /**
  44997. * Update the current camera state depending on the inputs that have been used this frame.
  44998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44999. */
  45000. checkInputs(): void;
  45001. /**
  45002. * Gets the class name of the current intput.
  45003. * @returns the class name
  45004. */
  45005. getClassName(): string;
  45006. /**
  45007. * Get the friendly name associated with the input class.
  45008. * @returns the input friendly name
  45009. */
  45010. getSimpleName(): string;
  45011. }
  45012. }
  45013. declare module BABYLON {
  45014. /**
  45015. * Manage the gamepad inputs to control a free camera.
  45016. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45017. */
  45018. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45019. /**
  45020. * Define the camera the input is attached to.
  45021. */
  45022. camera: FreeCamera;
  45023. /**
  45024. * Define the Gamepad controlling the input
  45025. */
  45026. gamepad: Nullable<Gamepad>;
  45027. /**
  45028. * Defines the gamepad rotation sensiblity.
  45029. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45030. */
  45031. gamepadAngularSensibility: number;
  45032. /**
  45033. * Defines the gamepad move sensiblity.
  45034. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45035. */
  45036. gamepadMoveSensibility: number;
  45037. private _yAxisScale;
  45038. /**
  45039. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45040. */
  45041. get invertYAxis(): boolean;
  45042. set invertYAxis(value: boolean);
  45043. private _onGamepadConnectedObserver;
  45044. private _onGamepadDisconnectedObserver;
  45045. private _cameraTransform;
  45046. private _deltaTransform;
  45047. private _vector3;
  45048. private _vector2;
  45049. /**
  45050. * Attach the input controls to a specific dom element to get the input from.
  45051. * @param element Defines the element the controls should be listened from
  45052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45053. */
  45054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45055. /**
  45056. * Detach the current controls from the specified dom element.
  45057. * @param element Defines the element to stop listening the inputs from
  45058. */
  45059. detachControl(element: Nullable<HTMLElement>): void;
  45060. /**
  45061. * Update the current camera state depending on the inputs that have been used this frame.
  45062. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45063. */
  45064. checkInputs(): void;
  45065. /**
  45066. * Gets the class name of the current intput.
  45067. * @returns the class name
  45068. */
  45069. getClassName(): string;
  45070. /**
  45071. * Get the friendly name associated with the input class.
  45072. * @returns the input friendly name
  45073. */
  45074. getSimpleName(): string;
  45075. }
  45076. }
  45077. declare module BABYLON {
  45078. /**
  45079. * Defines the potential axis of a Joystick
  45080. */
  45081. export enum JoystickAxis {
  45082. /** X axis */
  45083. X = 0,
  45084. /** Y axis */
  45085. Y = 1,
  45086. /** Z axis */
  45087. Z = 2
  45088. }
  45089. /**
  45090. * Represents the different customization options available
  45091. * for VirtualJoystick
  45092. */
  45093. interface VirtualJoystickCustomizations {
  45094. /**
  45095. * Size of the joystick's puck
  45096. */
  45097. puckSize: number;
  45098. /**
  45099. * Size of the joystick's container
  45100. */
  45101. containerSize: number;
  45102. /**
  45103. * Color of the joystick && puck
  45104. */
  45105. color: string;
  45106. /**
  45107. * Image URL for the joystick's puck
  45108. */
  45109. puckImage?: string;
  45110. /**
  45111. * Image URL for the joystick's container
  45112. */
  45113. containerImage?: string;
  45114. /**
  45115. * Defines the unmoving position of the joystick container
  45116. */
  45117. position?: {
  45118. x: number;
  45119. y: number;
  45120. };
  45121. /**
  45122. * Defines whether or not the joystick container is always visible
  45123. */
  45124. alwaysVisible: boolean;
  45125. /**
  45126. * Defines whether or not to limit the movement of the puck to the joystick's container
  45127. */
  45128. limitToContainer: boolean;
  45129. }
  45130. /**
  45131. * Class used to define virtual joystick (used in touch mode)
  45132. */
  45133. export class VirtualJoystick {
  45134. /**
  45135. * Gets or sets a boolean indicating that left and right values must be inverted
  45136. */
  45137. reverseLeftRight: boolean;
  45138. /**
  45139. * Gets or sets a boolean indicating that up and down values must be inverted
  45140. */
  45141. reverseUpDown: boolean;
  45142. /**
  45143. * Gets the offset value for the position (ie. the change of the position value)
  45144. */
  45145. deltaPosition: Vector3;
  45146. /**
  45147. * Gets a boolean indicating if the virtual joystick was pressed
  45148. */
  45149. pressed: boolean;
  45150. /**
  45151. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45152. */
  45153. static Canvas: Nullable<HTMLCanvasElement>;
  45154. /**
  45155. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45156. */
  45157. limitToContainer: boolean;
  45158. private static _globalJoystickIndex;
  45159. private static _alwaysVisibleSticks;
  45160. private static vjCanvasContext;
  45161. private static vjCanvasWidth;
  45162. private static vjCanvasHeight;
  45163. private static halfWidth;
  45164. private static _GetDefaultOptions;
  45165. private _action;
  45166. private _axisTargetedByLeftAndRight;
  45167. private _axisTargetedByUpAndDown;
  45168. private _joystickSensibility;
  45169. private _inversedSensibility;
  45170. private _joystickPointerID;
  45171. private _joystickColor;
  45172. private _joystickPointerPos;
  45173. private _joystickPreviousPointerPos;
  45174. private _joystickPointerStartPos;
  45175. private _deltaJoystickVector;
  45176. private _leftJoystick;
  45177. private _touches;
  45178. private _joystickPosition;
  45179. private _alwaysVisible;
  45180. private _puckImage;
  45181. private _containerImage;
  45182. private _joystickPuckSize;
  45183. private _joystickContainerSize;
  45184. private _clearPuckSize;
  45185. private _clearContainerSize;
  45186. private _clearPuckSizeOffset;
  45187. private _clearContainerSizeOffset;
  45188. private _onPointerDownHandlerRef;
  45189. private _onPointerMoveHandlerRef;
  45190. private _onPointerUpHandlerRef;
  45191. private _onResize;
  45192. /**
  45193. * Creates a new virtual joystick
  45194. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45195. * @param customizations Defines the options we want to customize the VirtualJoystick
  45196. */
  45197. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45198. /**
  45199. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45200. * @param newJoystickSensibility defines the new sensibility
  45201. */
  45202. setJoystickSensibility(newJoystickSensibility: number): void;
  45203. private _onPointerDown;
  45204. private _onPointerMove;
  45205. private _onPointerUp;
  45206. /**
  45207. * Change the color of the virtual joystick
  45208. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45209. */
  45210. setJoystickColor(newColor: string): void;
  45211. /**
  45212. * Size of the joystick's container
  45213. */
  45214. set containerSize(newSize: number);
  45215. get containerSize(): number;
  45216. /**
  45217. * Size of the joystick's puck
  45218. */
  45219. set puckSize(newSize: number);
  45220. get puckSize(): number;
  45221. /**
  45222. * Clears the set position of the joystick
  45223. */
  45224. clearPosition(): void;
  45225. /**
  45226. * Defines whether or not the joystick container is always visible
  45227. */
  45228. set alwaysVisible(value: boolean);
  45229. get alwaysVisible(): boolean;
  45230. /**
  45231. * Sets the constant position of the Joystick container
  45232. * @param x X axis coordinate
  45233. * @param y Y axis coordinate
  45234. */
  45235. setPosition(x: number, y: number): void;
  45236. /**
  45237. * Defines a callback to call when the joystick is touched
  45238. * @param action defines the callback
  45239. */
  45240. setActionOnTouch(action: () => any): void;
  45241. /**
  45242. * Defines which axis you'd like to control for left & right
  45243. * @param axis defines the axis to use
  45244. */
  45245. setAxisForLeftRight(axis: JoystickAxis): void;
  45246. /**
  45247. * Defines which axis you'd like to control for up & down
  45248. * @param axis defines the axis to use
  45249. */
  45250. setAxisForUpDown(axis: JoystickAxis): void;
  45251. /**
  45252. * Clears the canvas from the previous puck / container draw
  45253. */
  45254. private _clearPreviousDraw;
  45255. /**
  45256. * Loads `urlPath` to be used for the container's image
  45257. * @param urlPath defines the urlPath of an image to use
  45258. */
  45259. setContainerImage(urlPath: string): void;
  45260. /**
  45261. * Loads `urlPath` to be used for the puck's image
  45262. * @param urlPath defines the urlPath of an image to use
  45263. */
  45264. setPuckImage(urlPath: string): void;
  45265. /**
  45266. * Draws the Virtual Joystick's container
  45267. */
  45268. private _drawContainer;
  45269. /**
  45270. * Draws the Virtual Joystick's puck
  45271. */
  45272. private _drawPuck;
  45273. private _drawVirtualJoystick;
  45274. /**
  45275. * Release internal HTML canvas
  45276. */
  45277. releaseCanvas(): void;
  45278. }
  45279. }
  45280. declare module BABYLON {
  45281. interface FreeCameraInputsManager {
  45282. /**
  45283. * Add virtual joystick input support to the input manager.
  45284. * @returns the current input manager
  45285. */
  45286. addVirtualJoystick(): FreeCameraInputsManager;
  45287. }
  45288. /**
  45289. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45290. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45291. */
  45292. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45293. /**
  45294. * Defines the camera the input is attached to.
  45295. */
  45296. camera: FreeCamera;
  45297. private _leftjoystick;
  45298. private _rightjoystick;
  45299. /**
  45300. * Gets the left stick of the virtual joystick.
  45301. * @returns The virtual Joystick
  45302. */
  45303. getLeftJoystick(): VirtualJoystick;
  45304. /**
  45305. * Gets the right stick of the virtual joystick.
  45306. * @returns The virtual Joystick
  45307. */
  45308. getRightJoystick(): VirtualJoystick;
  45309. /**
  45310. * Update the current camera state depending on the inputs that have been used this frame.
  45311. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45312. */
  45313. checkInputs(): void;
  45314. /**
  45315. * Attach the input controls to a specific dom element to get the input from.
  45316. * @param element Defines the element the controls should be listened from
  45317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45318. */
  45319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45320. /**
  45321. * Detach the current controls from the specified dom element.
  45322. * @param element Defines the element to stop listening the inputs from
  45323. */
  45324. detachControl(element: Nullable<HTMLElement>): void;
  45325. /**
  45326. * Gets the class name of the current intput.
  45327. * @returns the class name
  45328. */
  45329. getClassName(): string;
  45330. /**
  45331. * Get the friendly name associated with the input class.
  45332. * @returns the input friendly name
  45333. */
  45334. getSimpleName(): string;
  45335. }
  45336. }
  45337. declare module BABYLON {
  45338. /**
  45339. * This represents a FPS type of camera controlled by touch.
  45340. * This is like a universal camera minus the Gamepad controls.
  45341. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45342. */
  45343. export class TouchCamera extends FreeCamera {
  45344. /**
  45345. * Defines the touch sensibility for rotation.
  45346. * The higher the faster.
  45347. */
  45348. get touchAngularSensibility(): number;
  45349. set touchAngularSensibility(value: number);
  45350. /**
  45351. * Defines the touch sensibility for move.
  45352. * The higher the faster.
  45353. */
  45354. get touchMoveSensibility(): number;
  45355. set touchMoveSensibility(value: number);
  45356. /**
  45357. * Instantiates a new touch camera.
  45358. * This represents a FPS type of camera controlled by touch.
  45359. * This is like a universal camera minus the Gamepad controls.
  45360. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45361. * @param name Define the name of the camera in the scene
  45362. * @param position Define the start position of the camera in the scene
  45363. * @param scene Define the scene the camera belongs to
  45364. */
  45365. constructor(name: string, position: Vector3, scene: Scene);
  45366. /**
  45367. * Gets the current object class name.
  45368. * @return the class name
  45369. */
  45370. getClassName(): string;
  45371. /** @hidden */
  45372. _setupInputs(): void;
  45373. }
  45374. }
  45375. declare module BABYLON {
  45376. /**
  45377. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45378. * being tilted forward or back and left or right.
  45379. */
  45380. export class DeviceOrientationCamera extends FreeCamera {
  45381. private _initialQuaternion;
  45382. private _quaternionCache;
  45383. private _tmpDragQuaternion;
  45384. private _disablePointerInputWhenUsingDeviceOrientation;
  45385. /**
  45386. * Creates a new device orientation camera
  45387. * @param name The name of the camera
  45388. * @param position The start position camera
  45389. * @param scene The scene the camera belongs to
  45390. */
  45391. constructor(name: string, position: Vector3, scene: Scene);
  45392. /**
  45393. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45394. */
  45395. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45396. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45397. private _dragFactor;
  45398. /**
  45399. * Enabled turning on the y axis when the orientation sensor is active
  45400. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45401. */
  45402. enableHorizontalDragging(dragFactor?: number): void;
  45403. /**
  45404. * Gets the current instance class name ("DeviceOrientationCamera").
  45405. * This helps avoiding instanceof at run time.
  45406. * @returns the class name
  45407. */
  45408. getClassName(): string;
  45409. /**
  45410. * @hidden
  45411. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45412. */
  45413. _checkInputs(): void;
  45414. /**
  45415. * Reset the camera to its default orientation on the specified axis only.
  45416. * @param axis The axis to reset
  45417. */
  45418. resetToCurrentRotation(axis?: Axis): void;
  45419. }
  45420. }
  45421. declare module BABYLON {
  45422. /**
  45423. * Defines supported buttons for XBox360 compatible gamepads
  45424. */
  45425. export enum Xbox360Button {
  45426. /** A */
  45427. A = 0,
  45428. /** B */
  45429. B = 1,
  45430. /** X */
  45431. X = 2,
  45432. /** Y */
  45433. Y = 3,
  45434. /** Left button */
  45435. LB = 4,
  45436. /** Right button */
  45437. RB = 5,
  45438. /** Back */
  45439. Back = 8,
  45440. /** Start */
  45441. Start = 9,
  45442. /** Left stick */
  45443. LeftStick = 10,
  45444. /** Right stick */
  45445. RightStick = 11
  45446. }
  45447. /** Defines values for XBox360 DPad */
  45448. export enum Xbox360Dpad {
  45449. /** Up */
  45450. Up = 12,
  45451. /** Down */
  45452. Down = 13,
  45453. /** Left */
  45454. Left = 14,
  45455. /** Right */
  45456. Right = 15
  45457. }
  45458. /**
  45459. * Defines a XBox360 gamepad
  45460. */
  45461. export class Xbox360Pad extends Gamepad {
  45462. private _leftTrigger;
  45463. private _rightTrigger;
  45464. private _onlefttriggerchanged;
  45465. private _onrighttriggerchanged;
  45466. private _onbuttondown;
  45467. private _onbuttonup;
  45468. private _ondpaddown;
  45469. private _ondpadup;
  45470. /** Observable raised when a button is pressed */
  45471. onButtonDownObservable: Observable<Xbox360Button>;
  45472. /** Observable raised when a button is released */
  45473. onButtonUpObservable: Observable<Xbox360Button>;
  45474. /** Observable raised when a pad is pressed */
  45475. onPadDownObservable: Observable<Xbox360Dpad>;
  45476. /** Observable raised when a pad is released */
  45477. onPadUpObservable: Observable<Xbox360Dpad>;
  45478. private _buttonA;
  45479. private _buttonB;
  45480. private _buttonX;
  45481. private _buttonY;
  45482. private _buttonBack;
  45483. private _buttonStart;
  45484. private _buttonLB;
  45485. private _buttonRB;
  45486. private _buttonLeftStick;
  45487. private _buttonRightStick;
  45488. private _dPadUp;
  45489. private _dPadDown;
  45490. private _dPadLeft;
  45491. private _dPadRight;
  45492. private _isXboxOnePad;
  45493. /**
  45494. * Creates a new XBox360 gamepad object
  45495. * @param id defines the id of this gamepad
  45496. * @param index defines its index
  45497. * @param gamepad defines the internal HTML gamepad object
  45498. * @param xboxOne defines if it is a XBox One gamepad
  45499. */
  45500. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45501. /**
  45502. * Defines the callback to call when left trigger is pressed
  45503. * @param callback defines the callback to use
  45504. */
  45505. onlefttriggerchanged(callback: (value: number) => void): void;
  45506. /**
  45507. * Defines the callback to call when right trigger is pressed
  45508. * @param callback defines the callback to use
  45509. */
  45510. onrighttriggerchanged(callback: (value: number) => void): void;
  45511. /**
  45512. * Gets the left trigger value
  45513. */
  45514. get leftTrigger(): number;
  45515. /**
  45516. * Sets the left trigger value
  45517. */
  45518. set leftTrigger(newValue: number);
  45519. /**
  45520. * Gets the right trigger value
  45521. */
  45522. get rightTrigger(): number;
  45523. /**
  45524. * Sets the right trigger value
  45525. */
  45526. set rightTrigger(newValue: number);
  45527. /**
  45528. * Defines the callback to call when a button is pressed
  45529. * @param callback defines the callback to use
  45530. */
  45531. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45532. /**
  45533. * Defines the callback to call when a button is released
  45534. * @param callback defines the callback to use
  45535. */
  45536. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45537. /**
  45538. * Defines the callback to call when a pad is pressed
  45539. * @param callback defines the callback to use
  45540. */
  45541. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45542. /**
  45543. * Defines the callback to call when a pad is released
  45544. * @param callback defines the callback to use
  45545. */
  45546. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45547. private _setButtonValue;
  45548. private _setDPadValue;
  45549. /**
  45550. * Gets the value of the `A` button
  45551. */
  45552. get buttonA(): number;
  45553. /**
  45554. * Sets the value of the `A` button
  45555. */
  45556. set buttonA(value: number);
  45557. /**
  45558. * Gets the value of the `B` button
  45559. */
  45560. get buttonB(): number;
  45561. /**
  45562. * Sets the value of the `B` button
  45563. */
  45564. set buttonB(value: number);
  45565. /**
  45566. * Gets the value of the `X` button
  45567. */
  45568. get buttonX(): number;
  45569. /**
  45570. * Sets the value of the `X` button
  45571. */
  45572. set buttonX(value: number);
  45573. /**
  45574. * Gets the value of the `Y` button
  45575. */
  45576. get buttonY(): number;
  45577. /**
  45578. * Sets the value of the `Y` button
  45579. */
  45580. set buttonY(value: number);
  45581. /**
  45582. * Gets the value of the `Start` button
  45583. */
  45584. get buttonStart(): number;
  45585. /**
  45586. * Sets the value of the `Start` button
  45587. */
  45588. set buttonStart(value: number);
  45589. /**
  45590. * Gets the value of the `Back` button
  45591. */
  45592. get buttonBack(): number;
  45593. /**
  45594. * Sets the value of the `Back` button
  45595. */
  45596. set buttonBack(value: number);
  45597. /**
  45598. * Gets the value of the `Left` button
  45599. */
  45600. get buttonLB(): number;
  45601. /**
  45602. * Sets the value of the `Left` button
  45603. */
  45604. set buttonLB(value: number);
  45605. /**
  45606. * Gets the value of the `Right` button
  45607. */
  45608. get buttonRB(): number;
  45609. /**
  45610. * Sets the value of the `Right` button
  45611. */
  45612. set buttonRB(value: number);
  45613. /**
  45614. * Gets the value of the Left joystick
  45615. */
  45616. get buttonLeftStick(): number;
  45617. /**
  45618. * Sets the value of the Left joystick
  45619. */
  45620. set buttonLeftStick(value: number);
  45621. /**
  45622. * Gets the value of the Right joystick
  45623. */
  45624. get buttonRightStick(): number;
  45625. /**
  45626. * Sets the value of the Right joystick
  45627. */
  45628. set buttonRightStick(value: number);
  45629. /**
  45630. * Gets the value of D-pad up
  45631. */
  45632. get dPadUp(): number;
  45633. /**
  45634. * Sets the value of D-pad up
  45635. */
  45636. set dPadUp(value: number);
  45637. /**
  45638. * Gets the value of D-pad down
  45639. */
  45640. get dPadDown(): number;
  45641. /**
  45642. * Sets the value of D-pad down
  45643. */
  45644. set dPadDown(value: number);
  45645. /**
  45646. * Gets the value of D-pad left
  45647. */
  45648. get dPadLeft(): number;
  45649. /**
  45650. * Sets the value of D-pad left
  45651. */
  45652. set dPadLeft(value: number);
  45653. /**
  45654. * Gets the value of D-pad right
  45655. */
  45656. get dPadRight(): number;
  45657. /**
  45658. * Sets the value of D-pad right
  45659. */
  45660. set dPadRight(value: number);
  45661. /**
  45662. * Force the gamepad to synchronize with device values
  45663. */
  45664. update(): void;
  45665. /**
  45666. * Disposes the gamepad
  45667. */
  45668. dispose(): void;
  45669. }
  45670. }
  45671. declare module BABYLON {
  45672. /**
  45673. * Defines supported buttons for DualShock compatible gamepads
  45674. */
  45675. export enum DualShockButton {
  45676. /** Cross */
  45677. Cross = 0,
  45678. /** Circle */
  45679. Circle = 1,
  45680. /** Square */
  45681. Square = 2,
  45682. /** Triangle */
  45683. Triangle = 3,
  45684. /** L1 */
  45685. L1 = 4,
  45686. /** R1 */
  45687. R1 = 5,
  45688. /** Share */
  45689. Share = 8,
  45690. /** Options */
  45691. Options = 9,
  45692. /** Left stick */
  45693. LeftStick = 10,
  45694. /** Right stick */
  45695. RightStick = 11
  45696. }
  45697. /** Defines values for DualShock DPad */
  45698. export enum DualShockDpad {
  45699. /** Up */
  45700. Up = 12,
  45701. /** Down */
  45702. Down = 13,
  45703. /** Left */
  45704. Left = 14,
  45705. /** Right */
  45706. Right = 15
  45707. }
  45708. /**
  45709. * Defines a DualShock gamepad
  45710. */
  45711. export class DualShockPad extends Gamepad {
  45712. private _leftTrigger;
  45713. private _rightTrigger;
  45714. private _onlefttriggerchanged;
  45715. private _onrighttriggerchanged;
  45716. private _onbuttondown;
  45717. private _onbuttonup;
  45718. private _ondpaddown;
  45719. private _ondpadup;
  45720. /** Observable raised when a button is pressed */
  45721. onButtonDownObservable: Observable<DualShockButton>;
  45722. /** Observable raised when a button is released */
  45723. onButtonUpObservable: Observable<DualShockButton>;
  45724. /** Observable raised when a pad is pressed */
  45725. onPadDownObservable: Observable<DualShockDpad>;
  45726. /** Observable raised when a pad is released */
  45727. onPadUpObservable: Observable<DualShockDpad>;
  45728. private _buttonCross;
  45729. private _buttonCircle;
  45730. private _buttonSquare;
  45731. private _buttonTriangle;
  45732. private _buttonShare;
  45733. private _buttonOptions;
  45734. private _buttonL1;
  45735. private _buttonR1;
  45736. private _buttonLeftStick;
  45737. private _buttonRightStick;
  45738. private _dPadUp;
  45739. private _dPadDown;
  45740. private _dPadLeft;
  45741. private _dPadRight;
  45742. /**
  45743. * Creates a new DualShock gamepad object
  45744. * @param id defines the id of this gamepad
  45745. * @param index defines its index
  45746. * @param gamepad defines the internal HTML gamepad object
  45747. */
  45748. constructor(id: string, index: number, gamepad: any);
  45749. /**
  45750. * Defines the callback to call when left trigger is pressed
  45751. * @param callback defines the callback to use
  45752. */
  45753. onlefttriggerchanged(callback: (value: number) => void): void;
  45754. /**
  45755. * Defines the callback to call when right trigger is pressed
  45756. * @param callback defines the callback to use
  45757. */
  45758. onrighttriggerchanged(callback: (value: number) => void): void;
  45759. /**
  45760. * Gets the left trigger value
  45761. */
  45762. get leftTrigger(): number;
  45763. /**
  45764. * Sets the left trigger value
  45765. */
  45766. set leftTrigger(newValue: number);
  45767. /**
  45768. * Gets the right trigger value
  45769. */
  45770. get rightTrigger(): number;
  45771. /**
  45772. * Sets the right trigger value
  45773. */
  45774. set rightTrigger(newValue: number);
  45775. /**
  45776. * Defines the callback to call when a button is pressed
  45777. * @param callback defines the callback to use
  45778. */
  45779. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45780. /**
  45781. * Defines the callback to call when a button is released
  45782. * @param callback defines the callback to use
  45783. */
  45784. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45785. /**
  45786. * Defines the callback to call when a pad is pressed
  45787. * @param callback defines the callback to use
  45788. */
  45789. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45790. /**
  45791. * Defines the callback to call when a pad is released
  45792. * @param callback defines the callback to use
  45793. */
  45794. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45795. private _setButtonValue;
  45796. private _setDPadValue;
  45797. /**
  45798. * Gets the value of the `Cross` button
  45799. */
  45800. get buttonCross(): number;
  45801. /**
  45802. * Sets the value of the `Cross` button
  45803. */
  45804. set buttonCross(value: number);
  45805. /**
  45806. * Gets the value of the `Circle` button
  45807. */
  45808. get buttonCircle(): number;
  45809. /**
  45810. * Sets the value of the `Circle` button
  45811. */
  45812. set buttonCircle(value: number);
  45813. /**
  45814. * Gets the value of the `Square` button
  45815. */
  45816. get buttonSquare(): number;
  45817. /**
  45818. * Sets the value of the `Square` button
  45819. */
  45820. set buttonSquare(value: number);
  45821. /**
  45822. * Gets the value of the `Triangle` button
  45823. */
  45824. get buttonTriangle(): number;
  45825. /**
  45826. * Sets the value of the `Triangle` button
  45827. */
  45828. set buttonTriangle(value: number);
  45829. /**
  45830. * Gets the value of the `Options` button
  45831. */
  45832. get buttonOptions(): number;
  45833. /**
  45834. * Sets the value of the `Options` button
  45835. */
  45836. set buttonOptions(value: number);
  45837. /**
  45838. * Gets the value of the `Share` button
  45839. */
  45840. get buttonShare(): number;
  45841. /**
  45842. * Sets the value of the `Share` button
  45843. */
  45844. set buttonShare(value: number);
  45845. /**
  45846. * Gets the value of the `L1` button
  45847. */
  45848. get buttonL1(): number;
  45849. /**
  45850. * Sets the value of the `L1` button
  45851. */
  45852. set buttonL1(value: number);
  45853. /**
  45854. * Gets the value of the `R1` button
  45855. */
  45856. get buttonR1(): number;
  45857. /**
  45858. * Sets the value of the `R1` button
  45859. */
  45860. set buttonR1(value: number);
  45861. /**
  45862. * Gets the value of the Left joystick
  45863. */
  45864. get buttonLeftStick(): number;
  45865. /**
  45866. * Sets the value of the Left joystick
  45867. */
  45868. set buttonLeftStick(value: number);
  45869. /**
  45870. * Gets the value of the Right joystick
  45871. */
  45872. get buttonRightStick(): number;
  45873. /**
  45874. * Sets the value of the Right joystick
  45875. */
  45876. set buttonRightStick(value: number);
  45877. /**
  45878. * Gets the value of D-pad up
  45879. */
  45880. get dPadUp(): number;
  45881. /**
  45882. * Sets the value of D-pad up
  45883. */
  45884. set dPadUp(value: number);
  45885. /**
  45886. * Gets the value of D-pad down
  45887. */
  45888. get dPadDown(): number;
  45889. /**
  45890. * Sets the value of D-pad down
  45891. */
  45892. set dPadDown(value: number);
  45893. /**
  45894. * Gets the value of D-pad left
  45895. */
  45896. get dPadLeft(): number;
  45897. /**
  45898. * Sets the value of D-pad left
  45899. */
  45900. set dPadLeft(value: number);
  45901. /**
  45902. * Gets the value of D-pad right
  45903. */
  45904. get dPadRight(): number;
  45905. /**
  45906. * Sets the value of D-pad right
  45907. */
  45908. set dPadRight(value: number);
  45909. /**
  45910. * Force the gamepad to synchronize with device values
  45911. */
  45912. update(): void;
  45913. /**
  45914. * Disposes the gamepad
  45915. */
  45916. dispose(): void;
  45917. }
  45918. }
  45919. declare module BABYLON {
  45920. /**
  45921. * Manager for handling gamepads
  45922. */
  45923. export class GamepadManager {
  45924. private _scene?;
  45925. private _babylonGamepads;
  45926. private _oneGamepadConnected;
  45927. /** @hidden */
  45928. _isMonitoring: boolean;
  45929. private _gamepadEventSupported;
  45930. private _gamepadSupport?;
  45931. /**
  45932. * observable to be triggered when the gamepad controller has been connected
  45933. */
  45934. onGamepadConnectedObservable: Observable<Gamepad>;
  45935. /**
  45936. * observable to be triggered when the gamepad controller has been disconnected
  45937. */
  45938. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45939. private _onGamepadConnectedEvent;
  45940. private _onGamepadDisconnectedEvent;
  45941. /**
  45942. * Initializes the gamepad manager
  45943. * @param _scene BabylonJS scene
  45944. */
  45945. constructor(_scene?: Scene | undefined);
  45946. /**
  45947. * The gamepads in the game pad manager
  45948. */
  45949. get gamepads(): Gamepad[];
  45950. /**
  45951. * Get the gamepad controllers based on type
  45952. * @param type The type of gamepad controller
  45953. * @returns Nullable gamepad
  45954. */
  45955. getGamepadByType(type?: number): Nullable<Gamepad>;
  45956. /**
  45957. * Disposes the gamepad manager
  45958. */
  45959. dispose(): void;
  45960. private _addNewGamepad;
  45961. private _startMonitoringGamepads;
  45962. private _stopMonitoringGamepads;
  45963. /** @hidden */
  45964. _checkGamepadsStatus(): void;
  45965. private _updateGamepadObjects;
  45966. }
  45967. }
  45968. declare module BABYLON {
  45969. interface Scene {
  45970. /** @hidden */
  45971. _gamepadManager: Nullable<GamepadManager>;
  45972. /**
  45973. * Gets the gamepad manager associated with the scene
  45974. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45975. */
  45976. gamepadManager: GamepadManager;
  45977. }
  45978. /**
  45979. * Interface representing a free camera inputs manager
  45980. */
  45981. interface FreeCameraInputsManager {
  45982. /**
  45983. * Adds gamepad input support to the FreeCameraInputsManager.
  45984. * @returns the FreeCameraInputsManager
  45985. */
  45986. addGamepad(): FreeCameraInputsManager;
  45987. }
  45988. /**
  45989. * Interface representing an arc rotate camera inputs manager
  45990. */
  45991. interface ArcRotateCameraInputsManager {
  45992. /**
  45993. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45994. * @returns the camera inputs manager
  45995. */
  45996. addGamepad(): ArcRotateCameraInputsManager;
  45997. }
  45998. /**
  45999. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46000. */
  46001. export class GamepadSystemSceneComponent implements ISceneComponent {
  46002. /**
  46003. * The component name helpfull to identify the component in the list of scene components.
  46004. */
  46005. readonly name: string;
  46006. /**
  46007. * The scene the component belongs to.
  46008. */
  46009. scene: Scene;
  46010. /**
  46011. * Creates a new instance of the component for the given scene
  46012. * @param scene Defines the scene to register the component in
  46013. */
  46014. constructor(scene: Scene);
  46015. /**
  46016. * Registers the component in a given scene
  46017. */
  46018. register(): void;
  46019. /**
  46020. * Rebuilds the elements related to this component in case of
  46021. * context lost for instance.
  46022. */
  46023. rebuild(): void;
  46024. /**
  46025. * Disposes the component and the associated ressources
  46026. */
  46027. dispose(): void;
  46028. private _beforeCameraUpdate;
  46029. }
  46030. }
  46031. declare module BABYLON {
  46032. /**
  46033. * 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,
  46034. * which still works and will still be found in many Playgrounds.
  46035. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46036. */
  46037. export class UniversalCamera extends TouchCamera {
  46038. /**
  46039. * Defines the gamepad rotation sensiblity.
  46040. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46041. */
  46042. get gamepadAngularSensibility(): number;
  46043. set gamepadAngularSensibility(value: number);
  46044. /**
  46045. * Defines the gamepad move sensiblity.
  46046. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46047. */
  46048. get gamepadMoveSensibility(): number;
  46049. set gamepadMoveSensibility(value: number);
  46050. /**
  46051. * 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,
  46052. * which still works and will still be found in many Playgrounds.
  46053. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46054. * @param name Define the name of the camera in the scene
  46055. * @param position Define the start position of the camera in the scene
  46056. * @param scene Define the scene the camera belongs to
  46057. */
  46058. constructor(name: string, position: Vector3, scene: Scene);
  46059. /**
  46060. * Gets the current object class name.
  46061. * @return the class name
  46062. */
  46063. getClassName(): string;
  46064. }
  46065. }
  46066. declare module BABYLON {
  46067. /**
  46068. * This represents a FPS type of camera. This is only here for back compat purpose.
  46069. * Please use the UniversalCamera instead as both are identical.
  46070. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46071. */
  46072. export class GamepadCamera extends UniversalCamera {
  46073. /**
  46074. * Instantiates a new Gamepad Camera
  46075. * This represents a FPS type of camera. This is only here for back compat purpose.
  46076. * Please use the UniversalCamera instead as both are identical.
  46077. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46078. * @param name Define the name of the camera in the scene
  46079. * @param position Define the start position of the camera in the scene
  46080. * @param scene Define the scene the camera belongs to
  46081. */
  46082. constructor(name: string, position: Vector3, scene: Scene);
  46083. /**
  46084. * Gets the current object class name.
  46085. * @return the class name
  46086. */
  46087. getClassName(): string;
  46088. }
  46089. }
  46090. declare module BABYLON {
  46091. /** @hidden */
  46092. export var passPixelShader: {
  46093. name: string;
  46094. shader: string;
  46095. };
  46096. }
  46097. declare module BABYLON {
  46098. /** @hidden */
  46099. export var passCubePixelShader: {
  46100. name: string;
  46101. shader: string;
  46102. };
  46103. }
  46104. declare module BABYLON {
  46105. /**
  46106. * PassPostProcess which produces an output the same as it's input
  46107. */
  46108. export class PassPostProcess extends PostProcess {
  46109. /**
  46110. * Gets a string identifying the name of the class
  46111. * @returns "PassPostProcess" string
  46112. */
  46113. getClassName(): string;
  46114. /**
  46115. * Creates the PassPostProcess
  46116. * @param name The name of the effect.
  46117. * @param options The required width/height ratio to downsize to before computing the render pass.
  46118. * @param camera The camera to apply the render pass to.
  46119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46120. * @param engine The engine which the post process will be applied. (default: current engine)
  46121. * @param reusable If the post process can be reused on the same frame. (default: false)
  46122. * @param textureType The type of texture to be used when performing the post processing.
  46123. * @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)
  46124. */
  46125. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46126. /** @hidden */
  46127. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46128. }
  46129. /**
  46130. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46131. */
  46132. export class PassCubePostProcess extends PostProcess {
  46133. private _face;
  46134. /**
  46135. * Gets or sets the cube face to display.
  46136. * * 0 is +X
  46137. * * 1 is -X
  46138. * * 2 is +Y
  46139. * * 3 is -Y
  46140. * * 4 is +Z
  46141. * * 5 is -Z
  46142. */
  46143. get face(): number;
  46144. set face(value: number);
  46145. /**
  46146. * Gets a string identifying the name of the class
  46147. * @returns "PassCubePostProcess" string
  46148. */
  46149. getClassName(): string;
  46150. /**
  46151. * Creates the PassCubePostProcess
  46152. * @param name The name of the effect.
  46153. * @param options The required width/height ratio to downsize to before computing the render pass.
  46154. * @param camera The camera to apply the render pass to.
  46155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46156. * @param engine The engine which the post process will be applied. (default: current engine)
  46157. * @param reusable If the post process can be reused on the same frame. (default: false)
  46158. * @param textureType The type of texture to be used when performing the post processing.
  46159. * @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)
  46160. */
  46161. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46162. /** @hidden */
  46163. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46164. }
  46165. }
  46166. declare module BABYLON {
  46167. /** @hidden */
  46168. export var anaglyphPixelShader: {
  46169. name: string;
  46170. shader: string;
  46171. };
  46172. }
  46173. declare module BABYLON {
  46174. /**
  46175. * Postprocess used to generate anaglyphic rendering
  46176. */
  46177. export class AnaglyphPostProcess extends PostProcess {
  46178. private _passedProcess;
  46179. /**
  46180. * Gets a string identifying the name of the class
  46181. * @returns "AnaglyphPostProcess" string
  46182. */
  46183. getClassName(): string;
  46184. /**
  46185. * Creates a new AnaglyphPostProcess
  46186. * @param name defines postprocess name
  46187. * @param options defines creation options or target ratio scale
  46188. * @param rigCameras defines cameras using this postprocess
  46189. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46190. * @param engine defines hosting engine
  46191. * @param reusable defines if the postprocess will be reused multiple times per frame
  46192. */
  46193. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46194. }
  46195. }
  46196. declare module BABYLON {
  46197. /**
  46198. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46199. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46200. */
  46201. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46202. /**
  46203. * Creates a new AnaglyphArcRotateCamera
  46204. * @param name defines camera name
  46205. * @param alpha defines alpha angle (in radians)
  46206. * @param beta defines beta angle (in radians)
  46207. * @param radius defines radius
  46208. * @param target defines camera target
  46209. * @param interaxialDistance defines distance between each color axis
  46210. * @param scene defines the hosting scene
  46211. */
  46212. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46213. /**
  46214. * Gets camera class name
  46215. * @returns AnaglyphArcRotateCamera
  46216. */
  46217. getClassName(): string;
  46218. }
  46219. }
  46220. declare module BABYLON {
  46221. /**
  46222. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46223. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46224. */
  46225. export class AnaglyphFreeCamera extends FreeCamera {
  46226. /**
  46227. * Creates a new AnaglyphFreeCamera
  46228. * @param name defines camera name
  46229. * @param position defines initial position
  46230. * @param interaxialDistance defines distance between each color axis
  46231. * @param scene defines the hosting scene
  46232. */
  46233. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46234. /**
  46235. * Gets camera class name
  46236. * @returns AnaglyphFreeCamera
  46237. */
  46238. getClassName(): string;
  46239. }
  46240. }
  46241. declare module BABYLON {
  46242. /**
  46243. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46244. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46245. */
  46246. export class AnaglyphGamepadCamera extends GamepadCamera {
  46247. /**
  46248. * Creates a new AnaglyphGamepadCamera
  46249. * @param name defines camera name
  46250. * @param position defines initial position
  46251. * @param interaxialDistance defines distance between each color axis
  46252. * @param scene defines the hosting scene
  46253. */
  46254. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46255. /**
  46256. * Gets camera class name
  46257. * @returns AnaglyphGamepadCamera
  46258. */
  46259. getClassName(): string;
  46260. }
  46261. }
  46262. declare module BABYLON {
  46263. /**
  46264. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46265. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46266. */
  46267. export class AnaglyphUniversalCamera extends UniversalCamera {
  46268. /**
  46269. * Creates a new AnaglyphUniversalCamera
  46270. * @param name defines camera name
  46271. * @param position defines initial position
  46272. * @param interaxialDistance defines distance between each color axis
  46273. * @param scene defines the hosting scene
  46274. */
  46275. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46276. /**
  46277. * Gets camera class name
  46278. * @returns AnaglyphUniversalCamera
  46279. */
  46280. getClassName(): string;
  46281. }
  46282. }
  46283. declare module BABYLON {
  46284. /**
  46285. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46286. * @see https://doc.babylonjs.com/features/cameras
  46287. */
  46288. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46289. /**
  46290. * Creates a new StereoscopicArcRotateCamera
  46291. * @param name defines camera name
  46292. * @param alpha defines alpha angle (in radians)
  46293. * @param beta defines beta angle (in radians)
  46294. * @param radius defines radius
  46295. * @param target defines camera target
  46296. * @param interaxialDistance defines distance between each color axis
  46297. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46298. * @param scene defines the hosting scene
  46299. */
  46300. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46301. /**
  46302. * Gets camera class name
  46303. * @returns StereoscopicArcRotateCamera
  46304. */
  46305. getClassName(): string;
  46306. }
  46307. }
  46308. declare module BABYLON {
  46309. /**
  46310. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46311. * @see https://doc.babylonjs.com/features/cameras
  46312. */
  46313. export class StereoscopicFreeCamera extends FreeCamera {
  46314. /**
  46315. * Creates a new StereoscopicFreeCamera
  46316. * @param name defines camera name
  46317. * @param position defines initial position
  46318. * @param interaxialDistance defines distance between each color axis
  46319. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46320. * @param scene defines the hosting scene
  46321. */
  46322. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46323. /**
  46324. * Gets camera class name
  46325. * @returns StereoscopicFreeCamera
  46326. */
  46327. getClassName(): string;
  46328. }
  46329. }
  46330. declare module BABYLON {
  46331. /**
  46332. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46333. * @see https://doc.babylonjs.com/features/cameras
  46334. */
  46335. export class StereoscopicGamepadCamera extends GamepadCamera {
  46336. /**
  46337. * Creates a new StereoscopicGamepadCamera
  46338. * @param name defines camera name
  46339. * @param position defines initial position
  46340. * @param interaxialDistance defines distance between each color axis
  46341. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46342. * @param scene defines the hosting scene
  46343. */
  46344. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46345. /**
  46346. * Gets camera class name
  46347. * @returns StereoscopicGamepadCamera
  46348. */
  46349. getClassName(): string;
  46350. }
  46351. }
  46352. declare module BABYLON {
  46353. /**
  46354. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46355. * @see https://doc.babylonjs.com/features/cameras
  46356. */
  46357. export class StereoscopicUniversalCamera extends UniversalCamera {
  46358. /**
  46359. * Creates a new StereoscopicUniversalCamera
  46360. * @param name defines camera name
  46361. * @param position defines initial position
  46362. * @param interaxialDistance defines distance between each color axis
  46363. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46364. * @param scene defines the hosting scene
  46365. */
  46366. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46367. /**
  46368. * Gets camera class name
  46369. * @returns StereoscopicUniversalCamera
  46370. */
  46371. getClassName(): string;
  46372. }
  46373. }
  46374. declare module BABYLON {
  46375. /**
  46376. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46377. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46378. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46379. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46380. */
  46381. export class VirtualJoysticksCamera extends FreeCamera {
  46382. /**
  46383. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46384. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46385. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46386. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46387. * @param name Define the name of the camera in the scene
  46388. * @param position Define the start position of the camera in the scene
  46389. * @param scene Define the scene the camera belongs to
  46390. */
  46391. constructor(name: string, position: Vector3, scene: Scene);
  46392. /**
  46393. * Gets the current object class name.
  46394. * @return the class name
  46395. */
  46396. getClassName(): string;
  46397. }
  46398. }
  46399. declare module BABYLON {
  46400. /**
  46401. * This represents all the required metrics to create a VR camera.
  46402. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46403. */
  46404. export class VRCameraMetrics {
  46405. /**
  46406. * Define the horizontal resolution off the screen.
  46407. */
  46408. hResolution: number;
  46409. /**
  46410. * Define the vertical resolution off the screen.
  46411. */
  46412. vResolution: number;
  46413. /**
  46414. * Define the horizontal screen size.
  46415. */
  46416. hScreenSize: number;
  46417. /**
  46418. * Define the vertical screen size.
  46419. */
  46420. vScreenSize: number;
  46421. /**
  46422. * Define the vertical screen center position.
  46423. */
  46424. vScreenCenter: number;
  46425. /**
  46426. * Define the distance of the eyes to the screen.
  46427. */
  46428. eyeToScreenDistance: number;
  46429. /**
  46430. * Define the distance between both lenses
  46431. */
  46432. lensSeparationDistance: number;
  46433. /**
  46434. * Define the distance between both viewer's eyes.
  46435. */
  46436. interpupillaryDistance: number;
  46437. /**
  46438. * Define the distortion factor of the VR postprocess.
  46439. * Please, touch with care.
  46440. */
  46441. distortionK: number[];
  46442. /**
  46443. * Define the chromatic aberration correction factors for the VR post process.
  46444. */
  46445. chromaAbCorrection: number[];
  46446. /**
  46447. * Define the scale factor of the post process.
  46448. * The smaller the better but the slower.
  46449. */
  46450. postProcessScaleFactor: number;
  46451. /**
  46452. * Define an offset for the lens center.
  46453. */
  46454. lensCenterOffset: number;
  46455. /**
  46456. * Define if the current vr camera should compensate the distortion of the lense or not.
  46457. */
  46458. compensateDistortion: boolean;
  46459. /**
  46460. * Defines if multiview should be enabled when rendering (Default: false)
  46461. */
  46462. multiviewEnabled: boolean;
  46463. /**
  46464. * Gets the rendering aspect ratio based on the provided resolutions.
  46465. */
  46466. get aspectRatio(): number;
  46467. /**
  46468. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46469. */
  46470. get aspectRatioFov(): number;
  46471. /**
  46472. * @hidden
  46473. */
  46474. get leftHMatrix(): Matrix;
  46475. /**
  46476. * @hidden
  46477. */
  46478. get rightHMatrix(): Matrix;
  46479. /**
  46480. * @hidden
  46481. */
  46482. get leftPreViewMatrix(): Matrix;
  46483. /**
  46484. * @hidden
  46485. */
  46486. get rightPreViewMatrix(): Matrix;
  46487. /**
  46488. * Get the default VRMetrics based on the most generic setup.
  46489. * @returns the default vr metrics
  46490. */
  46491. static GetDefault(): VRCameraMetrics;
  46492. }
  46493. }
  46494. declare module BABYLON {
  46495. /** @hidden */
  46496. export var vrDistortionCorrectionPixelShader: {
  46497. name: string;
  46498. shader: string;
  46499. };
  46500. }
  46501. declare module BABYLON {
  46502. /**
  46503. * VRDistortionCorrectionPostProcess used for mobile VR
  46504. */
  46505. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46506. private _isRightEye;
  46507. private _distortionFactors;
  46508. private _postProcessScaleFactor;
  46509. private _lensCenterOffset;
  46510. private _scaleIn;
  46511. private _scaleFactor;
  46512. private _lensCenter;
  46513. /**
  46514. * Gets a string identifying the name of the class
  46515. * @returns "VRDistortionCorrectionPostProcess" string
  46516. */
  46517. getClassName(): string;
  46518. /**
  46519. * Initializes the VRDistortionCorrectionPostProcess
  46520. * @param name The name of the effect.
  46521. * @param camera The camera to apply the render pass to.
  46522. * @param isRightEye If this is for the right eye distortion
  46523. * @param vrMetrics All the required metrics for the VR camera
  46524. */
  46525. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46526. }
  46527. }
  46528. declare module BABYLON {
  46529. /**
  46530. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46531. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46532. */
  46533. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46534. /**
  46535. * Creates a new VRDeviceOrientationArcRotateCamera
  46536. * @param name defines camera name
  46537. * @param alpha defines the camera rotation along the logitudinal axis
  46538. * @param beta defines the camera rotation along the latitudinal axis
  46539. * @param radius defines the camera distance from its target
  46540. * @param target defines the camera target
  46541. * @param scene defines the scene the camera belongs to
  46542. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46543. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46544. */
  46545. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46546. /**
  46547. * Gets camera class name
  46548. * @returns VRDeviceOrientationArcRotateCamera
  46549. */
  46550. getClassName(): string;
  46551. }
  46552. }
  46553. declare module BABYLON {
  46554. /**
  46555. * Camera used to simulate VR rendering (based on FreeCamera)
  46556. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46557. */
  46558. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46559. /**
  46560. * Creates a new VRDeviceOrientationFreeCamera
  46561. * @param name defines camera name
  46562. * @param position defines the start position of the camera
  46563. * @param scene defines the scene the camera belongs to
  46564. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46565. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46566. */
  46567. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46568. /**
  46569. * Gets camera class name
  46570. * @returns VRDeviceOrientationFreeCamera
  46571. */
  46572. getClassName(): string;
  46573. }
  46574. }
  46575. declare module BABYLON {
  46576. /**
  46577. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46578. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46579. */
  46580. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46581. /**
  46582. * Creates a new VRDeviceOrientationGamepadCamera
  46583. * @param name defines camera name
  46584. * @param position defines the start position of the camera
  46585. * @param scene defines the scene the camera belongs to
  46586. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46587. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46588. */
  46589. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46590. /**
  46591. * Gets camera class name
  46592. * @returns VRDeviceOrientationGamepadCamera
  46593. */
  46594. getClassName(): string;
  46595. }
  46596. }
  46597. declare module BABYLON {
  46598. /**
  46599. * A class extending Texture allowing drawing on a texture
  46600. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46601. */
  46602. export class DynamicTexture extends Texture {
  46603. private _generateMipMaps;
  46604. private _canvas;
  46605. private _context;
  46606. /**
  46607. * Creates a DynamicTexture
  46608. * @param name defines the name of the texture
  46609. * @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
  46610. * @param scene defines the scene where you want the texture
  46611. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46612. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46613. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46614. */
  46615. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46616. /**
  46617. * Get the current class name of the texture useful for serialization or dynamic coding.
  46618. * @returns "DynamicTexture"
  46619. */
  46620. getClassName(): string;
  46621. /**
  46622. * Gets the current state of canRescale
  46623. */
  46624. get canRescale(): boolean;
  46625. private _recreate;
  46626. /**
  46627. * Scales the texture
  46628. * @param ratio the scale factor to apply to both width and height
  46629. */
  46630. scale(ratio: number): void;
  46631. /**
  46632. * Resizes the texture
  46633. * @param width the new width
  46634. * @param height the new height
  46635. */
  46636. scaleTo(width: number, height: number): void;
  46637. /**
  46638. * Gets the context of the canvas used by the texture
  46639. * @returns the canvas context of the dynamic texture
  46640. */
  46641. getContext(): CanvasRenderingContext2D;
  46642. /**
  46643. * Clears the texture
  46644. */
  46645. clear(): void;
  46646. /**
  46647. * Updates the texture
  46648. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46649. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46650. */
  46651. update(invertY?: boolean, premulAlpha?: boolean): void;
  46652. /**
  46653. * Draws text onto the texture
  46654. * @param text defines the text to be drawn
  46655. * @param x defines the placement of the text from the left
  46656. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46657. * @param font defines the font to be used with font-style, font-size, font-name
  46658. * @param color defines the color used for the text
  46659. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46660. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46661. * @param update defines whether texture is immediately update (default is true)
  46662. */
  46663. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46664. /**
  46665. * Clones the texture
  46666. * @returns the clone of the texture.
  46667. */
  46668. clone(): DynamicTexture;
  46669. /**
  46670. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46671. * @returns a serialized dynamic texture object
  46672. */
  46673. serialize(): any;
  46674. private _IsCanvasElement;
  46675. /** @hidden */
  46676. _rebuild(): void;
  46677. }
  46678. }
  46679. declare module BABYLON {
  46680. /**
  46681. * Class containing static functions to help procedurally build meshes
  46682. */
  46683. export class GroundBuilder {
  46684. /**
  46685. * Creates a ground mesh
  46686. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46687. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46689. * @param name defines the name of the mesh
  46690. * @param options defines the options used to create the mesh
  46691. * @param scene defines the hosting scene
  46692. * @returns the ground mesh
  46693. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46694. */
  46695. static CreateGround(name: string, options: {
  46696. width?: number;
  46697. height?: number;
  46698. subdivisions?: number;
  46699. subdivisionsX?: number;
  46700. subdivisionsY?: number;
  46701. updatable?: boolean;
  46702. }, scene: any): Mesh;
  46703. /**
  46704. * Creates a tiled ground mesh
  46705. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46706. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46707. * * 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
  46708. * * 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
  46709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46710. * @param name defines the name of the mesh
  46711. * @param options defines the options used to create the mesh
  46712. * @param scene defines the hosting scene
  46713. * @returns the tiled ground mesh
  46714. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46715. */
  46716. static CreateTiledGround(name: string, options: {
  46717. xmin: number;
  46718. zmin: number;
  46719. xmax: number;
  46720. zmax: number;
  46721. subdivisions?: {
  46722. w: number;
  46723. h: number;
  46724. };
  46725. precision?: {
  46726. w: number;
  46727. h: number;
  46728. };
  46729. updatable?: boolean;
  46730. }, scene?: Nullable<Scene>): Mesh;
  46731. /**
  46732. * Creates a ground mesh from a height map
  46733. * * The parameter `url` sets the URL of the height map image resource.
  46734. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46735. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46736. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46737. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46738. * * 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.
  46739. * * 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).
  46740. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46742. * @param name defines the name of the mesh
  46743. * @param url defines the url to the height map
  46744. * @param options defines the options used to create the mesh
  46745. * @param scene defines the hosting scene
  46746. * @returns the ground mesh
  46747. * @see https://doc.babylonjs.com/babylon101/height_map
  46748. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46749. */
  46750. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46751. width?: number;
  46752. height?: number;
  46753. subdivisions?: number;
  46754. minHeight?: number;
  46755. maxHeight?: number;
  46756. colorFilter?: Color3;
  46757. alphaFilter?: number;
  46758. updatable?: boolean;
  46759. onReady?: (mesh: GroundMesh) => void;
  46760. }, scene?: Nullable<Scene>): GroundMesh;
  46761. }
  46762. }
  46763. declare module BABYLON {
  46764. /**
  46765. * Class containing static functions to help procedurally build meshes
  46766. */
  46767. export class TorusBuilder {
  46768. /**
  46769. * Creates a torus mesh
  46770. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46771. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46772. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46774. * * 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
  46775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46776. * @param name defines the name of the mesh
  46777. * @param options defines the options used to create the mesh
  46778. * @param scene defines the hosting scene
  46779. * @returns the torus mesh
  46780. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46781. */
  46782. static CreateTorus(name: string, options: {
  46783. diameter?: number;
  46784. thickness?: number;
  46785. tessellation?: number;
  46786. updatable?: boolean;
  46787. sideOrientation?: number;
  46788. frontUVs?: Vector4;
  46789. backUVs?: Vector4;
  46790. }, scene: any): Mesh;
  46791. }
  46792. }
  46793. declare module BABYLON {
  46794. /**
  46795. * Class containing static functions to help procedurally build meshes
  46796. */
  46797. export class CylinderBuilder {
  46798. /**
  46799. * Creates a cylinder or a cone mesh
  46800. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46801. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46802. * * 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.
  46803. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46804. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46805. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46806. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46807. * * 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).
  46808. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46809. * * 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).
  46810. * * 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
  46811. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46812. * * 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
  46813. * * 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.
  46814. * * If `enclose` is false, a ring surface is one element.
  46815. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46816. * * 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
  46817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46818. * * 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
  46819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46820. * @param name defines the name of the mesh
  46821. * @param options defines the options used to create the mesh
  46822. * @param scene defines the hosting scene
  46823. * @returns the cylinder mesh
  46824. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46825. */
  46826. static CreateCylinder(name: string, options: {
  46827. height?: number;
  46828. diameterTop?: number;
  46829. diameterBottom?: number;
  46830. diameter?: number;
  46831. tessellation?: number;
  46832. subdivisions?: number;
  46833. arc?: number;
  46834. faceColors?: Color4[];
  46835. faceUV?: Vector4[];
  46836. updatable?: boolean;
  46837. hasRings?: boolean;
  46838. enclose?: boolean;
  46839. cap?: number;
  46840. sideOrientation?: number;
  46841. frontUVs?: Vector4;
  46842. backUVs?: Vector4;
  46843. }, scene: any): Mesh;
  46844. }
  46845. }
  46846. declare module BABYLON {
  46847. /**
  46848. * States of the webXR experience
  46849. */
  46850. export enum WebXRState {
  46851. /**
  46852. * Transitioning to being in XR mode
  46853. */
  46854. ENTERING_XR = 0,
  46855. /**
  46856. * Transitioning to non XR mode
  46857. */
  46858. EXITING_XR = 1,
  46859. /**
  46860. * In XR mode and presenting
  46861. */
  46862. IN_XR = 2,
  46863. /**
  46864. * Not entered XR mode
  46865. */
  46866. NOT_IN_XR = 3
  46867. }
  46868. /**
  46869. * Abstraction of the XR render target
  46870. */
  46871. export interface WebXRRenderTarget extends IDisposable {
  46872. /**
  46873. * xrpresent context of the canvas which can be used to display/mirror xr content
  46874. */
  46875. canvasContext: WebGLRenderingContext;
  46876. /**
  46877. * xr layer for the canvas
  46878. */
  46879. xrLayer: Nullable<XRWebGLLayer>;
  46880. /**
  46881. * Initializes the xr layer for the session
  46882. * @param xrSession xr session
  46883. * @returns a promise that will resolve once the XR Layer has been created
  46884. */
  46885. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46886. }
  46887. }
  46888. declare module BABYLON {
  46889. /**
  46890. * COnfiguration object for WebXR output canvas
  46891. */
  46892. export class WebXRManagedOutputCanvasOptions {
  46893. /**
  46894. * An optional canvas in case you wish to create it yourself and provide it here.
  46895. * If not provided, a new canvas will be created
  46896. */
  46897. canvasElement?: HTMLCanvasElement;
  46898. /**
  46899. * Options for this XR Layer output
  46900. */
  46901. canvasOptions?: XRWebGLLayerOptions;
  46902. /**
  46903. * CSS styling for a newly created canvas (if not provided)
  46904. */
  46905. newCanvasCssStyle?: string;
  46906. /**
  46907. * Get the default values of the configuration object
  46908. * @param engine defines the engine to use (can be null)
  46909. * @returns default values of this configuration object
  46910. */
  46911. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46912. }
  46913. /**
  46914. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46915. */
  46916. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46917. private _options;
  46918. private _canvas;
  46919. private _engine;
  46920. private _originalCanvasSize;
  46921. /**
  46922. * Rendering context of the canvas which can be used to display/mirror xr content
  46923. */
  46924. canvasContext: WebGLRenderingContext;
  46925. /**
  46926. * xr layer for the canvas
  46927. */
  46928. xrLayer: Nullable<XRWebGLLayer>;
  46929. /**
  46930. * Obseervers registered here will be triggered when the xr layer was initialized
  46931. */
  46932. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46933. /**
  46934. * Initializes the canvas to be added/removed upon entering/exiting xr
  46935. * @param _xrSessionManager The XR Session manager
  46936. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46937. */
  46938. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46939. /**
  46940. * Disposes of the object
  46941. */
  46942. dispose(): void;
  46943. /**
  46944. * Initializes the xr layer for the session
  46945. * @param xrSession xr session
  46946. * @returns a promise that will resolve once the XR Layer has been created
  46947. */
  46948. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46949. private _addCanvas;
  46950. private _removeCanvas;
  46951. private _setCanvasSize;
  46952. private _setManagedOutputCanvas;
  46953. }
  46954. }
  46955. declare module BABYLON {
  46956. /**
  46957. * Manages an XRSession to work with Babylon's engine
  46958. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46959. */
  46960. export class WebXRSessionManager implements IDisposable {
  46961. /** The scene which the session should be created for */
  46962. scene: Scene;
  46963. private _referenceSpace;
  46964. private _rttProvider;
  46965. private _sessionEnded;
  46966. private _xrNavigator;
  46967. private baseLayer;
  46968. /**
  46969. * The base reference space from which the session started. good if you want to reset your
  46970. * reference space
  46971. */
  46972. baseReferenceSpace: XRReferenceSpace;
  46973. /**
  46974. * Current XR frame
  46975. */
  46976. currentFrame: Nullable<XRFrame>;
  46977. /** WebXR timestamp updated every frame */
  46978. currentTimestamp: number;
  46979. /**
  46980. * Used just in case of a failure to initialize an immersive session.
  46981. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46982. */
  46983. defaultHeightCompensation: number;
  46984. /**
  46985. * Fires every time a new xrFrame arrives which can be used to update the camera
  46986. */
  46987. onXRFrameObservable: Observable<XRFrame>;
  46988. /**
  46989. * Fires when the reference space changed
  46990. */
  46991. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46992. /**
  46993. * Fires when the xr session is ended either by the device or manually done
  46994. */
  46995. onXRSessionEnded: Observable<any>;
  46996. /**
  46997. * Fires when the xr session is ended either by the device or manually done
  46998. */
  46999. onXRSessionInit: Observable<XRSession>;
  47000. /**
  47001. * Underlying xr session
  47002. */
  47003. session: XRSession;
  47004. /**
  47005. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47006. * or get the offset the player is currently at.
  47007. */
  47008. viewerReferenceSpace: XRReferenceSpace;
  47009. /**
  47010. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47011. * @param scene The scene which the session should be created for
  47012. */
  47013. constructor(
  47014. /** The scene which the session should be created for */
  47015. scene: Scene);
  47016. /**
  47017. * The current reference space used in this session. This reference space can constantly change!
  47018. * It is mainly used to offset the camera's position.
  47019. */
  47020. get referenceSpace(): XRReferenceSpace;
  47021. /**
  47022. * Set a new reference space and triggers the observable
  47023. */
  47024. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47025. /**
  47026. * Disposes of the session manager
  47027. */
  47028. dispose(): void;
  47029. /**
  47030. * Stops the xrSession and restores the render loop
  47031. * @returns Promise which resolves after it exits XR
  47032. */
  47033. exitXRAsync(): Promise<void>;
  47034. /**
  47035. * Gets the correct render target texture to be rendered this frame for this eye
  47036. * @param eye the eye for which to get the render target
  47037. * @returns the render target for the specified eye
  47038. */
  47039. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47040. /**
  47041. * Creates a WebXRRenderTarget object for the XR session
  47042. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47043. * @param options optional options to provide when creating a new render target
  47044. * @returns a WebXR render target to which the session can render
  47045. */
  47046. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47047. /**
  47048. * Initializes the manager
  47049. * After initialization enterXR can be called to start an XR session
  47050. * @returns Promise which resolves after it is initialized
  47051. */
  47052. initializeAsync(): Promise<void>;
  47053. /**
  47054. * Initializes an xr session
  47055. * @param xrSessionMode mode to initialize
  47056. * @param xrSessionInit defines optional and required values to pass to the session builder
  47057. * @returns a promise which will resolve once the session has been initialized
  47058. */
  47059. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47060. /**
  47061. * Checks if a session would be supported for the creation options specified
  47062. * @param sessionMode session mode to check if supported eg. immersive-vr
  47063. * @returns A Promise that resolves to true if supported and false if not
  47064. */
  47065. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47066. /**
  47067. * Resets the reference space to the one started the session
  47068. */
  47069. resetReferenceSpace(): void;
  47070. /**
  47071. * Starts rendering to the xr layer
  47072. */
  47073. runXRRenderLoop(): void;
  47074. /**
  47075. * Sets the reference space on the xr session
  47076. * @param referenceSpaceType space to set
  47077. * @returns a promise that will resolve once the reference space has been set
  47078. */
  47079. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47080. /**
  47081. * Updates the render state of the session
  47082. * @param state state to set
  47083. * @returns a promise that resolves once the render state has been updated
  47084. */
  47085. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47086. /**
  47087. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47088. * @param sessionMode defines the session to test
  47089. * @returns a promise with boolean as final value
  47090. */
  47091. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47092. private _createRenderTargetTexture;
  47093. }
  47094. }
  47095. declare module BABYLON {
  47096. /**
  47097. * WebXR Camera which holds the views for the xrSession
  47098. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47099. */
  47100. export class WebXRCamera extends FreeCamera {
  47101. private _xrSessionManager;
  47102. private _firstFrame;
  47103. private _referenceQuaternion;
  47104. private _referencedPosition;
  47105. private _xrInvPositionCache;
  47106. private _xrInvQuaternionCache;
  47107. /**
  47108. * Observable raised before camera teleportation
  47109. */
  47110. onBeforeCameraTeleport: Observable<Vector3>;
  47111. /**
  47112. * Observable raised after camera teleportation
  47113. */
  47114. onAfterCameraTeleport: Observable<Vector3>;
  47115. /**
  47116. * Should position compensation execute on first frame.
  47117. * This is used when copying the position from a native (non XR) camera
  47118. */
  47119. compensateOnFirstFrame: boolean;
  47120. /**
  47121. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47122. * @param name the name of the camera
  47123. * @param scene the scene to add the camera to
  47124. * @param _xrSessionManager a constructed xr session manager
  47125. */
  47126. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47127. /**
  47128. * Return the user's height, unrelated to the current ground.
  47129. * This will be the y position of this camera, when ground level is 0.
  47130. */
  47131. get realWorldHeight(): number;
  47132. /** @hidden */
  47133. _updateForDualEyeDebugging(): void;
  47134. /**
  47135. * Sets this camera's transformation based on a non-vr camera
  47136. * @param otherCamera the non-vr camera to copy the transformation from
  47137. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47138. */
  47139. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47140. /**
  47141. * Gets the current instance class name ("WebXRCamera").
  47142. * @returns the class name
  47143. */
  47144. getClassName(): string;
  47145. private _rotate180;
  47146. private _updateFromXRSession;
  47147. private _updateNumberOfRigCameras;
  47148. private _updateReferenceSpace;
  47149. private _updateReferenceSpaceOffset;
  47150. }
  47151. }
  47152. declare module BABYLON {
  47153. /**
  47154. * Defining the interface required for a (webxr) feature
  47155. */
  47156. export interface IWebXRFeature extends IDisposable {
  47157. /**
  47158. * Is this feature attached
  47159. */
  47160. attached: boolean;
  47161. /**
  47162. * Should auto-attach be disabled?
  47163. */
  47164. disableAutoAttach: boolean;
  47165. /**
  47166. * Attach the feature to the session
  47167. * Will usually be called by the features manager
  47168. *
  47169. * @param force should attachment be forced (even when already attached)
  47170. * @returns true if successful.
  47171. */
  47172. attach(force?: boolean): boolean;
  47173. /**
  47174. * Detach the feature from the session
  47175. * Will usually be called by the features manager
  47176. *
  47177. * @returns true if successful.
  47178. */
  47179. detach(): boolean;
  47180. /**
  47181. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47182. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47183. *
  47184. * @returns whether or not the feature is compatible in this environment
  47185. */
  47186. isCompatible(): boolean;
  47187. /**
  47188. * Was this feature disposed;
  47189. */
  47190. isDisposed: boolean;
  47191. /**
  47192. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47193. */
  47194. xrNativeFeatureName?: string;
  47195. /**
  47196. * A list of (Babylon WebXR) features this feature depends on
  47197. */
  47198. dependsOn?: string[];
  47199. }
  47200. /**
  47201. * A list of the currently available features without referencing them
  47202. */
  47203. export class WebXRFeatureName {
  47204. /**
  47205. * The name of the anchor system feature
  47206. */
  47207. static readonly ANCHOR_SYSTEM: string;
  47208. /**
  47209. * The name of the background remover feature
  47210. */
  47211. static readonly BACKGROUND_REMOVER: string;
  47212. /**
  47213. * The name of the hit test feature
  47214. */
  47215. static readonly HIT_TEST: string;
  47216. /**
  47217. * physics impostors for xr controllers feature
  47218. */
  47219. static readonly PHYSICS_CONTROLLERS: string;
  47220. /**
  47221. * The name of the plane detection feature
  47222. */
  47223. static readonly PLANE_DETECTION: string;
  47224. /**
  47225. * The name of the pointer selection feature
  47226. */
  47227. static readonly POINTER_SELECTION: string;
  47228. /**
  47229. * The name of the teleportation feature
  47230. */
  47231. static readonly TELEPORTATION: string;
  47232. /**
  47233. * The name of the feature points feature.
  47234. */
  47235. static readonly FEATURE_POINTS: string;
  47236. /**
  47237. * The name of the hand tracking feature.
  47238. */
  47239. static readonly HAND_TRACKING: string;
  47240. }
  47241. /**
  47242. * Defining the constructor of a feature. Used to register the modules.
  47243. */
  47244. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47245. /**
  47246. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47247. * It is mainly used in AR sessions.
  47248. *
  47249. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47250. */
  47251. export class WebXRFeaturesManager implements IDisposable {
  47252. private _xrSessionManager;
  47253. private static readonly _AvailableFeatures;
  47254. private _features;
  47255. /**
  47256. * constructs a new features manages.
  47257. *
  47258. * @param _xrSessionManager an instance of WebXRSessionManager
  47259. */
  47260. constructor(_xrSessionManager: WebXRSessionManager);
  47261. /**
  47262. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47263. * Mainly used internally.
  47264. *
  47265. * @param featureName the name of the feature to register
  47266. * @param constructorFunction the function used to construct the module
  47267. * @param version the (babylon) version of the module
  47268. * @param stable is that a stable version of this module
  47269. */
  47270. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47271. /**
  47272. * Returns a constructor of a specific feature.
  47273. *
  47274. * @param featureName the name of the feature to construct
  47275. * @param version the version of the feature to load
  47276. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47277. * @param options optional options provided to the module.
  47278. * @returns a function that, when called, will return a new instance of this feature
  47279. */
  47280. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47281. /**
  47282. * Can be used to return the list of features currently registered
  47283. *
  47284. * @returns an Array of available features
  47285. */
  47286. static GetAvailableFeatures(): string[];
  47287. /**
  47288. * Gets the versions available for a specific feature
  47289. * @param featureName the name of the feature
  47290. * @returns an array with the available versions
  47291. */
  47292. static GetAvailableVersions(featureName: string): string[];
  47293. /**
  47294. * Return the latest unstable version of this feature
  47295. * @param featureName the name of the feature to search
  47296. * @returns the version number. if not found will return -1
  47297. */
  47298. static GetLatestVersionOfFeature(featureName: string): number;
  47299. /**
  47300. * Return the latest stable version of this feature
  47301. * @param featureName the name of the feature to search
  47302. * @returns the version number. if not found will return -1
  47303. */
  47304. static GetStableVersionOfFeature(featureName: string): number;
  47305. /**
  47306. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47307. * Can be used during a session to start a feature
  47308. * @param featureName the name of feature to attach
  47309. */
  47310. attachFeature(featureName: string): void;
  47311. /**
  47312. * Can be used inside a session or when the session ends to detach a specific feature
  47313. * @param featureName the name of the feature to detach
  47314. */
  47315. detachFeature(featureName: string): void;
  47316. /**
  47317. * Used to disable an already-enabled feature
  47318. * The feature will be disposed and will be recreated once enabled.
  47319. * @param featureName the feature to disable
  47320. * @returns true if disable was successful
  47321. */
  47322. disableFeature(featureName: string | {
  47323. Name: string;
  47324. }): boolean;
  47325. /**
  47326. * dispose this features manager
  47327. */
  47328. dispose(): void;
  47329. /**
  47330. * 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.
  47331. * 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.
  47332. *
  47333. * @param featureName the name of the feature to load or the class of the feature
  47334. * @param version optional version to load. if not provided the latest version will be enabled
  47335. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47336. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47337. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47338. * @returns a new constructed feature or throws an error if feature not found.
  47339. */
  47340. enableFeature(featureName: string | {
  47341. Name: string;
  47342. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47343. /**
  47344. * get the implementation of an enabled feature.
  47345. * @param featureName the name of the feature to load
  47346. * @returns the feature class, if found
  47347. */
  47348. getEnabledFeature(featureName: string): IWebXRFeature;
  47349. /**
  47350. * Get the list of enabled features
  47351. * @returns an array of enabled features
  47352. */
  47353. getEnabledFeatures(): string[];
  47354. /**
  47355. * This function will exten the session creation configuration object with enabled features.
  47356. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47357. * according to the defined "required" variable, provided during enableFeature call
  47358. * @param xrSessionInit the xr Session init object to extend
  47359. *
  47360. * @returns an extended XRSessionInit object
  47361. */
  47362. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47363. }
  47364. }
  47365. declare module BABYLON {
  47366. /**
  47367. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47368. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47369. */
  47370. export class WebXRExperienceHelper implements IDisposable {
  47371. private scene;
  47372. private _nonVRCamera;
  47373. private _originalSceneAutoClear;
  47374. private _supported;
  47375. /**
  47376. * Camera used to render xr content
  47377. */
  47378. camera: WebXRCamera;
  47379. /** A features manager for this xr session */
  47380. featuresManager: WebXRFeaturesManager;
  47381. /**
  47382. * Observers registered here will be triggered after the camera's initial transformation is set
  47383. * This can be used to set a different ground level or an extra rotation.
  47384. *
  47385. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47386. * to the position set after this observable is done executing.
  47387. */
  47388. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47389. /**
  47390. * Fires when the state of the experience helper has changed
  47391. */
  47392. onStateChangedObservable: Observable<WebXRState>;
  47393. /** Session manager used to keep track of xr session */
  47394. sessionManager: WebXRSessionManager;
  47395. /**
  47396. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47397. */
  47398. state: WebXRState;
  47399. /**
  47400. * Creates a WebXRExperienceHelper
  47401. * @param scene The scene the helper should be created in
  47402. */
  47403. private constructor();
  47404. /**
  47405. * Creates the experience helper
  47406. * @param scene the scene to attach the experience helper to
  47407. * @returns a promise for the experience helper
  47408. */
  47409. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47410. /**
  47411. * Disposes of the experience helper
  47412. */
  47413. dispose(): void;
  47414. /**
  47415. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47416. * @param sessionMode options for the XR session
  47417. * @param referenceSpaceType frame of reference of the XR session
  47418. * @param renderTarget the output canvas that will be used to enter XR mode
  47419. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47420. * @returns promise that resolves after xr mode has entered
  47421. */
  47422. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47423. /**
  47424. * Exits XR mode and returns the scene to its original state
  47425. * @returns promise that resolves after xr mode has exited
  47426. */
  47427. exitXRAsync(): Promise<void>;
  47428. private _nonXRToXRCamera;
  47429. private _setState;
  47430. }
  47431. }
  47432. declare module BABYLON {
  47433. /**
  47434. * X-Y values for axes in WebXR
  47435. */
  47436. export interface IWebXRMotionControllerAxesValue {
  47437. /**
  47438. * The value of the x axis
  47439. */
  47440. x: number;
  47441. /**
  47442. * The value of the y-axis
  47443. */
  47444. y: number;
  47445. }
  47446. /**
  47447. * changed / previous values for the values of this component
  47448. */
  47449. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47450. /**
  47451. * current (this frame) value
  47452. */
  47453. current: T;
  47454. /**
  47455. * previous (last change) value
  47456. */
  47457. previous: T;
  47458. }
  47459. /**
  47460. * Represents changes in the component between current frame and last values recorded
  47461. */
  47462. export interface IWebXRMotionControllerComponentChanges {
  47463. /**
  47464. * will be populated with previous and current values if axes changed
  47465. */
  47466. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47467. /**
  47468. * will be populated with previous and current values if pressed changed
  47469. */
  47470. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47471. /**
  47472. * will be populated with previous and current values if touched changed
  47473. */
  47474. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47475. /**
  47476. * will be populated with previous and current values if value changed
  47477. */
  47478. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47479. }
  47480. /**
  47481. * This class represents a single component (for example button or thumbstick) of a motion controller
  47482. */
  47483. export class WebXRControllerComponent implements IDisposable {
  47484. /**
  47485. * the id of this component
  47486. */
  47487. id: string;
  47488. /**
  47489. * the type of the component
  47490. */
  47491. type: MotionControllerComponentType;
  47492. private _buttonIndex;
  47493. private _axesIndices;
  47494. private _axes;
  47495. private _changes;
  47496. private _currentValue;
  47497. private _hasChanges;
  47498. private _pressed;
  47499. private _touched;
  47500. /**
  47501. * button component type
  47502. */
  47503. static BUTTON_TYPE: MotionControllerComponentType;
  47504. /**
  47505. * squeeze component type
  47506. */
  47507. static SQUEEZE_TYPE: MotionControllerComponentType;
  47508. /**
  47509. * Thumbstick component type
  47510. */
  47511. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47512. /**
  47513. * Touchpad component type
  47514. */
  47515. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47516. /**
  47517. * trigger component type
  47518. */
  47519. static TRIGGER_TYPE: MotionControllerComponentType;
  47520. /**
  47521. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47522. * the axes data changes
  47523. */
  47524. onAxisValueChangedObservable: Observable<{
  47525. x: number;
  47526. y: number;
  47527. }>;
  47528. /**
  47529. * Observers registered here will be triggered when the state of a button changes
  47530. * State change is either pressed / touched / value
  47531. */
  47532. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47533. /**
  47534. * Creates a new component for a motion controller.
  47535. * It is created by the motion controller itself
  47536. *
  47537. * @param id the id of this component
  47538. * @param type the type of the component
  47539. * @param _buttonIndex index in the buttons array of the gamepad
  47540. * @param _axesIndices indices of the values in the axes array of the gamepad
  47541. */
  47542. constructor(
  47543. /**
  47544. * the id of this component
  47545. */
  47546. id: string,
  47547. /**
  47548. * the type of the component
  47549. */
  47550. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47551. /**
  47552. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47553. */
  47554. get axes(): IWebXRMotionControllerAxesValue;
  47555. /**
  47556. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47557. */
  47558. get changes(): IWebXRMotionControllerComponentChanges;
  47559. /**
  47560. * Return whether or not the component changed the last frame
  47561. */
  47562. get hasChanges(): boolean;
  47563. /**
  47564. * is the button currently pressed
  47565. */
  47566. get pressed(): boolean;
  47567. /**
  47568. * is the button currently touched
  47569. */
  47570. get touched(): boolean;
  47571. /**
  47572. * Get the current value of this component
  47573. */
  47574. get value(): number;
  47575. /**
  47576. * Dispose this component
  47577. */
  47578. dispose(): void;
  47579. /**
  47580. * Are there axes correlating to this component
  47581. * @return true is axes data is available
  47582. */
  47583. isAxes(): boolean;
  47584. /**
  47585. * Is this component a button (hence - pressable)
  47586. * @returns true if can be pressed
  47587. */
  47588. isButton(): boolean;
  47589. /**
  47590. * update this component using the gamepad object it is in. Called on every frame
  47591. * @param nativeController the native gamepad controller object
  47592. */
  47593. update(nativeController: IMinimalMotionControllerObject): void;
  47594. }
  47595. }
  47596. declare module BABYLON {
  47597. /**
  47598. * Interface used to represent data loading progression
  47599. */
  47600. export interface ISceneLoaderProgressEvent {
  47601. /**
  47602. * Defines if data length to load can be evaluated
  47603. */
  47604. readonly lengthComputable: boolean;
  47605. /**
  47606. * Defines the loaded data length
  47607. */
  47608. readonly loaded: number;
  47609. /**
  47610. * Defines the data length to load
  47611. */
  47612. readonly total: number;
  47613. }
  47614. /**
  47615. * Interface used by SceneLoader plugins to define supported file extensions
  47616. */
  47617. export interface ISceneLoaderPluginExtensions {
  47618. /**
  47619. * Defines the list of supported extensions
  47620. */
  47621. [extension: string]: {
  47622. isBinary: boolean;
  47623. };
  47624. }
  47625. /**
  47626. * Interface used by SceneLoader plugin factory
  47627. */
  47628. export interface ISceneLoaderPluginFactory {
  47629. /**
  47630. * Defines the name of the factory
  47631. */
  47632. name: string;
  47633. /**
  47634. * Function called to create a new plugin
  47635. * @return the new plugin
  47636. */
  47637. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47638. /**
  47639. * The callback that returns true if the data can be directly loaded.
  47640. * @param data string containing the file data
  47641. * @returns if the data can be loaded directly
  47642. */
  47643. canDirectLoad?(data: string): boolean;
  47644. }
  47645. /**
  47646. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47647. */
  47648. export interface ISceneLoaderPluginBase {
  47649. /**
  47650. * The friendly name of this plugin.
  47651. */
  47652. name: string;
  47653. /**
  47654. * The file extensions supported by this plugin.
  47655. */
  47656. extensions: string | ISceneLoaderPluginExtensions;
  47657. /**
  47658. * The callback called when loading from a url.
  47659. * @param scene scene loading this url
  47660. * @param url url to load
  47661. * @param onSuccess callback called when the file successfully loads
  47662. * @param onProgress callback called while file is loading (if the server supports this mode)
  47663. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47664. * @param onError callback called when the file fails to load
  47665. * @returns a file request object
  47666. */
  47667. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47668. /**
  47669. * The callback called when loading from a file object.
  47670. * @param scene scene loading this file
  47671. * @param file defines the file to load
  47672. * @param onSuccess defines the callback to call when data is loaded
  47673. * @param onProgress defines the callback to call during loading process
  47674. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47675. * @param onError defines the callback to call when an error occurs
  47676. * @returns a file request object
  47677. */
  47678. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47679. /**
  47680. * The callback that returns true if the data can be directly loaded.
  47681. * @param data string containing the file data
  47682. * @returns if the data can be loaded directly
  47683. */
  47684. canDirectLoad?(data: string): boolean;
  47685. /**
  47686. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47687. * @param scene scene loading this data
  47688. * @param data string containing the data
  47689. * @returns data to pass to the plugin
  47690. */
  47691. directLoad?(scene: Scene, data: string): any;
  47692. /**
  47693. * The callback that allows custom handling of the root url based on the response url.
  47694. * @param rootUrl the original root url
  47695. * @param responseURL the response url if available
  47696. * @returns the new root url
  47697. */
  47698. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47699. }
  47700. /**
  47701. * Interface used to define a SceneLoader plugin
  47702. */
  47703. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47704. /**
  47705. * Import meshes into a scene.
  47706. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47707. * @param scene The scene to import into
  47708. * @param data The data to import
  47709. * @param rootUrl The root url for scene and resources
  47710. * @param meshes The meshes array to import into
  47711. * @param particleSystems The particle systems array to import into
  47712. * @param skeletons The skeletons array to import into
  47713. * @param onError The callback when import fails
  47714. * @returns True if successful or false otherwise
  47715. */
  47716. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47717. /**
  47718. * Load into a scene.
  47719. * @param scene The scene to load into
  47720. * @param data The data to import
  47721. * @param rootUrl The root url for scene and resources
  47722. * @param onError The callback when import fails
  47723. * @returns True if successful or false otherwise
  47724. */
  47725. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47726. /**
  47727. * Load into an asset container.
  47728. * @param scene The scene to load into
  47729. * @param data The data to import
  47730. * @param rootUrl The root url for scene and resources
  47731. * @param onError The callback when import fails
  47732. * @returns The loaded asset container
  47733. */
  47734. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47735. }
  47736. /**
  47737. * Interface used to define an async SceneLoader plugin
  47738. */
  47739. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47740. /**
  47741. * Import meshes into a scene.
  47742. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47743. * @param scene The scene to import into
  47744. * @param data The data to import
  47745. * @param rootUrl The root url for scene and resources
  47746. * @param onProgress The callback when the load progresses
  47747. * @param fileName Defines the name of the file to load
  47748. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47749. */
  47750. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47751. meshes: AbstractMesh[];
  47752. particleSystems: IParticleSystem[];
  47753. skeletons: Skeleton[];
  47754. animationGroups: AnimationGroup[];
  47755. }>;
  47756. /**
  47757. * Load into a scene.
  47758. * @param scene The scene to load into
  47759. * @param data The data to import
  47760. * @param rootUrl The root url for scene and resources
  47761. * @param onProgress The callback when the load progresses
  47762. * @param fileName Defines the name of the file to load
  47763. * @returns Nothing
  47764. */
  47765. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47766. /**
  47767. * Load into an asset container.
  47768. * @param scene The scene to load into
  47769. * @param data The data to import
  47770. * @param rootUrl The root url for scene and resources
  47771. * @param onProgress The callback when the load progresses
  47772. * @param fileName Defines the name of the file to load
  47773. * @returns The loaded asset container
  47774. */
  47775. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47776. }
  47777. /**
  47778. * Mode that determines how to handle old animation groups before loading new ones.
  47779. */
  47780. export enum SceneLoaderAnimationGroupLoadingMode {
  47781. /**
  47782. * Reset all old animations to initial state then dispose them.
  47783. */
  47784. Clean = 0,
  47785. /**
  47786. * Stop all old animations.
  47787. */
  47788. Stop = 1,
  47789. /**
  47790. * Restart old animations from first frame.
  47791. */
  47792. Sync = 2,
  47793. /**
  47794. * Old animations remains untouched.
  47795. */
  47796. NoSync = 3
  47797. }
  47798. /**
  47799. * Defines a plugin registered by the SceneLoader
  47800. */
  47801. interface IRegisteredPlugin {
  47802. /**
  47803. * Defines the plugin to use
  47804. */
  47805. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47806. /**
  47807. * Defines if the plugin supports binary data
  47808. */
  47809. isBinary: boolean;
  47810. }
  47811. /**
  47812. * Class used to load scene from various file formats using registered plugins
  47813. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47814. */
  47815. export class SceneLoader {
  47816. /**
  47817. * No logging while loading
  47818. */
  47819. static readonly NO_LOGGING: number;
  47820. /**
  47821. * Minimal logging while loading
  47822. */
  47823. static readonly MINIMAL_LOGGING: number;
  47824. /**
  47825. * Summary logging while loading
  47826. */
  47827. static readonly SUMMARY_LOGGING: number;
  47828. /**
  47829. * Detailled logging while loading
  47830. */
  47831. static readonly DETAILED_LOGGING: number;
  47832. /**
  47833. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47834. */
  47835. static get ForceFullSceneLoadingForIncremental(): boolean;
  47836. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47837. /**
  47838. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47839. */
  47840. static get ShowLoadingScreen(): boolean;
  47841. static set ShowLoadingScreen(value: boolean);
  47842. /**
  47843. * Defines the current logging level (while loading the scene)
  47844. * @ignorenaming
  47845. */
  47846. static get loggingLevel(): number;
  47847. static set loggingLevel(value: number);
  47848. /**
  47849. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47850. */
  47851. static get CleanBoneMatrixWeights(): boolean;
  47852. static set CleanBoneMatrixWeights(value: boolean);
  47853. /**
  47854. * Event raised when a plugin is used to load a scene
  47855. */
  47856. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47857. private static _registeredPlugins;
  47858. private static _showingLoadingScreen;
  47859. /**
  47860. * Gets the default plugin (used to load Babylon files)
  47861. * @returns the .babylon plugin
  47862. */
  47863. static GetDefaultPlugin(): IRegisteredPlugin;
  47864. private static _GetPluginForExtension;
  47865. private static _GetPluginForDirectLoad;
  47866. private static _GetPluginForFilename;
  47867. private static _GetDirectLoad;
  47868. private static _LoadData;
  47869. private static _GetFileInfo;
  47870. /**
  47871. * Gets a plugin that can load the given extension
  47872. * @param extension defines the extension to load
  47873. * @returns a plugin or null if none works
  47874. */
  47875. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47876. /**
  47877. * Gets a boolean indicating that the given extension can be loaded
  47878. * @param extension defines the extension to load
  47879. * @returns true if the extension is supported
  47880. */
  47881. static IsPluginForExtensionAvailable(extension: string): boolean;
  47882. /**
  47883. * Adds a new plugin to the list of registered plugins
  47884. * @param plugin defines the plugin to add
  47885. */
  47886. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47887. /**
  47888. * Import meshes into a scene
  47889. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47890. * @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)
  47891. * @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)
  47892. * @param scene the instance of BABYLON.Scene to append to
  47893. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47894. * @param onProgress a callback with a progress event for each file being loaded
  47895. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47896. * @param pluginExtension the extension used to determine the plugin
  47897. * @returns The loaded plugin
  47898. */
  47899. 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>;
  47900. /**
  47901. * Import meshes into a scene
  47902. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47903. * @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)
  47904. * @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)
  47905. * @param scene the instance of BABYLON.Scene to append to
  47906. * @param onProgress a callback with a progress event for each file being loaded
  47907. * @param pluginExtension the extension used to determine the plugin
  47908. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47909. */
  47910. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47911. meshes: AbstractMesh[];
  47912. particleSystems: IParticleSystem[];
  47913. skeletons: Skeleton[];
  47914. animationGroups: AnimationGroup[];
  47915. }>;
  47916. /**
  47917. * Load a scene
  47918. * @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)
  47919. * @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)
  47920. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47921. * @param onSuccess a callback with the scene when import succeeds
  47922. * @param onProgress a callback with a progress event for each file being loaded
  47923. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47924. * @param pluginExtension the extension used to determine the plugin
  47925. * @returns The loaded plugin
  47926. */
  47927. 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>;
  47928. /**
  47929. * Load a scene
  47930. * @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)
  47931. * @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)
  47932. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47933. * @param onProgress a callback with a progress event for each file being loaded
  47934. * @param pluginExtension the extension used to determine the plugin
  47935. * @returns The loaded scene
  47936. */
  47937. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47938. /**
  47939. * Append a scene
  47940. * @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)
  47941. * @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)
  47942. * @param scene is the instance of BABYLON.Scene to append to
  47943. * @param onSuccess a callback with the scene when import succeeds
  47944. * @param onProgress a callback with a progress event for each file being loaded
  47945. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47946. * @param pluginExtension the extension used to determine the plugin
  47947. * @returns The loaded plugin
  47948. */
  47949. 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>;
  47950. /**
  47951. * Append a scene
  47952. * @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)
  47953. * @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)
  47954. * @param scene is the instance of BABYLON.Scene to append to
  47955. * @param onProgress a callback with a progress event for each file being loaded
  47956. * @param pluginExtension the extension used to determine the plugin
  47957. * @returns The given scene
  47958. */
  47959. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47960. /**
  47961. * Load a scene into an asset container
  47962. * @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)
  47963. * @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)
  47964. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47965. * @param onSuccess a callback with the scene when import succeeds
  47966. * @param onProgress a callback with a progress event for each file being loaded
  47967. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47968. * @param pluginExtension the extension used to determine the plugin
  47969. * @returns The loaded plugin
  47970. */
  47971. 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>;
  47972. /**
  47973. * Load a scene into an asset container
  47974. * @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)
  47975. * @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)
  47976. * @param scene is the instance of Scene to append to
  47977. * @param onProgress a callback with a progress event for each file being loaded
  47978. * @param pluginExtension the extension used to determine the plugin
  47979. * @returns The loaded asset container
  47980. */
  47981. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47982. /**
  47983. * Import animations from a file into a scene
  47984. * @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)
  47985. * @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)
  47986. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47987. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47988. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47989. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47990. * @param onSuccess a callback with the scene when import succeeds
  47991. * @param onProgress a callback with a progress event for each file being loaded
  47992. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47993. * @param pluginExtension the extension used to determine the plugin
  47994. */
  47995. 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;
  47996. /**
  47997. * Import animations from a file into a scene
  47998. * @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)
  47999. * @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)
  48000. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48001. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48002. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48003. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48004. * @param onSuccess a callback with the scene when import succeeds
  48005. * @param onProgress a callback with a progress event for each file being loaded
  48006. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48007. * @param pluginExtension the extension used to determine the plugin
  48008. * @returns the updated scene with imported animations
  48009. */
  48010. 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>;
  48011. }
  48012. }
  48013. declare module BABYLON {
  48014. /**
  48015. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48016. */
  48017. export type MotionControllerHandedness = "none" | "left" | "right";
  48018. /**
  48019. * The type of components available in motion controllers.
  48020. * This is not the name of the component.
  48021. */
  48022. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48023. /**
  48024. * The state of a controller component
  48025. */
  48026. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48027. /**
  48028. * The schema of motion controller layout.
  48029. * No object will be initialized using this interface
  48030. * This is used just to define the profile.
  48031. */
  48032. export interface IMotionControllerLayout {
  48033. /**
  48034. * Path to load the assets. Usually relative to the base path
  48035. */
  48036. assetPath: string;
  48037. /**
  48038. * Available components (unsorted)
  48039. */
  48040. components: {
  48041. /**
  48042. * A map of component Ids
  48043. */
  48044. [componentId: string]: {
  48045. /**
  48046. * The type of input the component outputs
  48047. */
  48048. type: MotionControllerComponentType;
  48049. /**
  48050. * The indices of this component in the gamepad object
  48051. */
  48052. gamepadIndices: {
  48053. /**
  48054. * Index of button
  48055. */
  48056. button?: number;
  48057. /**
  48058. * If available, index of x-axis
  48059. */
  48060. xAxis?: number;
  48061. /**
  48062. * If available, index of y-axis
  48063. */
  48064. yAxis?: number;
  48065. };
  48066. /**
  48067. * The mesh's root node name
  48068. */
  48069. rootNodeName: string;
  48070. /**
  48071. * Animation definitions for this model
  48072. */
  48073. visualResponses: {
  48074. [stateKey: string]: {
  48075. /**
  48076. * What property will be animated
  48077. */
  48078. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48079. /**
  48080. * What states influence this visual response
  48081. */
  48082. states: MotionControllerComponentStateType[];
  48083. /**
  48084. * Type of animation - movement or visibility
  48085. */
  48086. valueNodeProperty: "transform" | "visibility";
  48087. /**
  48088. * Base node name to move. Its position will be calculated according to the min and max nodes
  48089. */
  48090. valueNodeName?: string;
  48091. /**
  48092. * Minimum movement node
  48093. */
  48094. minNodeName?: string;
  48095. /**
  48096. * Max movement node
  48097. */
  48098. maxNodeName?: string;
  48099. };
  48100. };
  48101. /**
  48102. * If touch enabled, what is the name of node to display user feedback
  48103. */
  48104. touchPointNodeName?: string;
  48105. };
  48106. };
  48107. /**
  48108. * Is it xr standard mapping or not
  48109. */
  48110. gamepadMapping: "" | "xr-standard";
  48111. /**
  48112. * Base root node of this entire model
  48113. */
  48114. rootNodeName: string;
  48115. /**
  48116. * Defines the main button component id
  48117. */
  48118. selectComponentId: string;
  48119. }
  48120. /**
  48121. * A definition for the layout map in the input profile
  48122. */
  48123. export interface IMotionControllerLayoutMap {
  48124. /**
  48125. * Layouts with handedness type as a key
  48126. */
  48127. [handedness: string]: IMotionControllerLayout;
  48128. }
  48129. /**
  48130. * The XR Input profile schema
  48131. * Profiles can be found here:
  48132. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48133. */
  48134. export interface IMotionControllerProfile {
  48135. /**
  48136. * fallback profiles for this profileId
  48137. */
  48138. fallbackProfileIds: string[];
  48139. /**
  48140. * The layout map, with handedness as key
  48141. */
  48142. layouts: IMotionControllerLayoutMap;
  48143. /**
  48144. * The id of this profile
  48145. * correlates to the profile(s) in the xrInput.profiles array
  48146. */
  48147. profileId: string;
  48148. }
  48149. /**
  48150. * A helper-interface for the 3 meshes needed for controller button animation
  48151. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48152. */
  48153. export interface IMotionControllerButtonMeshMap {
  48154. /**
  48155. * the mesh that defines the pressed value mesh position.
  48156. * This is used to find the max-position of this button
  48157. */
  48158. pressedMesh: AbstractMesh;
  48159. /**
  48160. * the mesh that defines the unpressed value mesh position.
  48161. * This is used to find the min (or initial) position of this button
  48162. */
  48163. unpressedMesh: AbstractMesh;
  48164. /**
  48165. * The mesh that will be changed when value changes
  48166. */
  48167. valueMesh: AbstractMesh;
  48168. }
  48169. /**
  48170. * A helper-interface for the 3 meshes needed for controller axis animation.
  48171. * This will be expanded when touchpad animations are fully supported
  48172. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48173. */
  48174. export interface IMotionControllerMeshMap {
  48175. /**
  48176. * the mesh that defines the maximum value mesh position.
  48177. */
  48178. maxMesh?: AbstractMesh;
  48179. /**
  48180. * the mesh that defines the minimum value mesh position.
  48181. */
  48182. minMesh?: AbstractMesh;
  48183. /**
  48184. * The mesh that will be changed when axis value changes
  48185. */
  48186. valueMesh?: AbstractMesh;
  48187. }
  48188. /**
  48189. * The elements needed for change-detection of the gamepad objects in motion controllers
  48190. */
  48191. export interface IMinimalMotionControllerObject {
  48192. /**
  48193. * Available axes of this controller
  48194. */
  48195. axes: number[];
  48196. /**
  48197. * An array of available buttons
  48198. */
  48199. buttons: Array<{
  48200. /**
  48201. * Value of the button/trigger
  48202. */
  48203. value: number;
  48204. /**
  48205. * If the button/trigger is currently touched
  48206. */
  48207. touched: boolean;
  48208. /**
  48209. * If the button/trigger is currently pressed
  48210. */
  48211. pressed: boolean;
  48212. }>;
  48213. /**
  48214. * EXPERIMENTAL haptic support.
  48215. */
  48216. hapticActuators?: Array<{
  48217. pulse: (value: number, duration: number) => Promise<boolean>;
  48218. }>;
  48219. }
  48220. /**
  48221. * An Abstract Motion controller
  48222. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48223. * Each component has an observable to check for changes in value and state
  48224. */
  48225. export abstract class WebXRAbstractMotionController implements IDisposable {
  48226. protected scene: Scene;
  48227. protected layout: IMotionControllerLayout;
  48228. /**
  48229. * The gamepad object correlating to this controller
  48230. */
  48231. gamepadObject: IMinimalMotionControllerObject;
  48232. /**
  48233. * handedness (left/right/none) of this controller
  48234. */
  48235. handedness: MotionControllerHandedness;
  48236. private _initComponent;
  48237. private _modelReady;
  48238. /**
  48239. * A map of components (WebXRControllerComponent) in this motion controller
  48240. * Components have a ComponentType and can also have both button and axis definitions
  48241. */
  48242. readonly components: {
  48243. [id: string]: WebXRControllerComponent;
  48244. };
  48245. /**
  48246. * Disable the model's animation. Can be set at any time.
  48247. */
  48248. disableAnimation: boolean;
  48249. /**
  48250. * Observers registered here will be triggered when the model of this controller is done loading
  48251. */
  48252. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48253. /**
  48254. * The profile id of this motion controller
  48255. */
  48256. abstract profileId: string;
  48257. /**
  48258. * The root mesh of the model. It is null if the model was not yet initialized
  48259. */
  48260. rootMesh: Nullable<AbstractMesh>;
  48261. /**
  48262. * constructs a new abstract motion controller
  48263. * @param scene the scene to which the model of the controller will be added
  48264. * @param layout The profile layout to load
  48265. * @param gamepadObject The gamepad object correlating to this controller
  48266. * @param handedness handedness (left/right/none) of this controller
  48267. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48268. */
  48269. constructor(scene: Scene, layout: IMotionControllerLayout,
  48270. /**
  48271. * The gamepad object correlating to this controller
  48272. */
  48273. gamepadObject: IMinimalMotionControllerObject,
  48274. /**
  48275. * handedness (left/right/none) of this controller
  48276. */
  48277. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48278. /**
  48279. * Dispose this controller, the model mesh and all its components
  48280. */
  48281. dispose(): void;
  48282. /**
  48283. * Returns all components of specific type
  48284. * @param type the type to search for
  48285. * @return an array of components with this type
  48286. */
  48287. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48288. /**
  48289. * get a component based an its component id as defined in layout.components
  48290. * @param id the id of the component
  48291. * @returns the component correlates to the id or undefined if not found
  48292. */
  48293. getComponent(id: string): WebXRControllerComponent;
  48294. /**
  48295. * Get the list of components available in this motion controller
  48296. * @returns an array of strings correlating to available components
  48297. */
  48298. getComponentIds(): string[];
  48299. /**
  48300. * Get the first component of specific type
  48301. * @param type type of component to find
  48302. * @return a controller component or null if not found
  48303. */
  48304. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48305. /**
  48306. * Get the main (Select) component of this controller as defined in the layout
  48307. * @returns the main component of this controller
  48308. */
  48309. getMainComponent(): WebXRControllerComponent;
  48310. /**
  48311. * Loads the model correlating to this controller
  48312. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48313. * @returns A promise fulfilled with the result of the model loading
  48314. */
  48315. loadModel(): Promise<boolean>;
  48316. /**
  48317. * Update this model using the current XRFrame
  48318. * @param xrFrame the current xr frame to use and update the model
  48319. */
  48320. updateFromXRFrame(xrFrame: XRFrame): void;
  48321. /**
  48322. * Backwards compatibility due to a deeply-integrated typo
  48323. */
  48324. get handness(): XREye;
  48325. /**
  48326. * Pulse (vibrate) this controller
  48327. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48328. * Consecutive calls to this function will cancel the last pulse call
  48329. *
  48330. * @param value the strength of the pulse in 0.0...1.0 range
  48331. * @param duration Duration of the pulse in milliseconds
  48332. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48333. * @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
  48334. */
  48335. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48336. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48337. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48338. /**
  48339. * Moves the axis on the controller mesh based on its current state
  48340. * @param axis the index of the axis
  48341. * @param axisValue the value of the axis which determines the meshes new position
  48342. * @hidden
  48343. */
  48344. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48345. /**
  48346. * Update the model itself with the current frame data
  48347. * @param xrFrame the frame to use for updating the model mesh
  48348. */
  48349. protected updateModel(xrFrame: XRFrame): void;
  48350. /**
  48351. * Get the filename and path for this controller's model
  48352. * @returns a map of filename and path
  48353. */
  48354. protected abstract _getFilenameAndPath(): {
  48355. filename: string;
  48356. path: string;
  48357. };
  48358. /**
  48359. * This function is called before the mesh is loaded. It checks for loading constraints.
  48360. * For example, this function can check if the GLB loader is available
  48361. * If this function returns false, the generic controller will be loaded instead
  48362. * @returns Is the client ready to load the mesh
  48363. */
  48364. protected abstract _getModelLoadingConstraints(): boolean;
  48365. /**
  48366. * This function will be called after the model was successfully loaded and can be used
  48367. * for mesh transformations before it is available for the user
  48368. * @param meshes the loaded meshes
  48369. */
  48370. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48371. /**
  48372. * Set the root mesh for this controller. Important for the WebXR controller class
  48373. * @param meshes the loaded meshes
  48374. */
  48375. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48376. /**
  48377. * A function executed each frame that updates the mesh (if needed)
  48378. * @param xrFrame the current xrFrame
  48379. */
  48380. protected abstract _updateModel(xrFrame: XRFrame): void;
  48381. private _getGenericFilenameAndPath;
  48382. private _getGenericParentMesh;
  48383. }
  48384. }
  48385. declare module BABYLON {
  48386. /**
  48387. * A generic trigger-only motion controller for WebXR
  48388. */
  48389. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48390. /**
  48391. * Static version of the profile id of this controller
  48392. */
  48393. static ProfileId: string;
  48394. profileId: string;
  48395. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48396. protected _getFilenameAndPath(): {
  48397. filename: string;
  48398. path: string;
  48399. };
  48400. protected _getModelLoadingConstraints(): boolean;
  48401. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48402. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48403. protected _updateModel(): void;
  48404. }
  48405. }
  48406. declare module BABYLON {
  48407. /**
  48408. * Class containing static functions to help procedurally build meshes
  48409. */
  48410. export class SphereBuilder {
  48411. /**
  48412. * Creates a sphere mesh
  48413. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48414. * * 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`)
  48415. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48416. * * 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
  48417. * * 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)
  48418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48419. * * 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
  48420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48421. * @param name defines the name of the mesh
  48422. * @param options defines the options used to create the mesh
  48423. * @param scene defines the hosting scene
  48424. * @returns the sphere mesh
  48425. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48426. */
  48427. static CreateSphere(name: string, options: {
  48428. segments?: number;
  48429. diameter?: number;
  48430. diameterX?: number;
  48431. diameterY?: number;
  48432. diameterZ?: number;
  48433. arc?: number;
  48434. slice?: number;
  48435. sideOrientation?: number;
  48436. frontUVs?: Vector4;
  48437. backUVs?: Vector4;
  48438. updatable?: boolean;
  48439. }, scene?: Nullable<Scene>): Mesh;
  48440. }
  48441. }
  48442. declare module BABYLON {
  48443. /**
  48444. * A profiled motion controller has its profile loaded from an online repository.
  48445. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48446. */
  48447. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48448. private _repositoryUrl;
  48449. private _buttonMeshMapping;
  48450. private _touchDots;
  48451. /**
  48452. * The profile ID of this controller. Will be populated when the controller initializes.
  48453. */
  48454. profileId: string;
  48455. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48456. dispose(): void;
  48457. protected _getFilenameAndPath(): {
  48458. filename: string;
  48459. path: string;
  48460. };
  48461. protected _getModelLoadingConstraints(): boolean;
  48462. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48463. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48464. protected _updateModel(_xrFrame: XRFrame): void;
  48465. }
  48466. }
  48467. declare module BABYLON {
  48468. /**
  48469. * A construction function type to create a new controller based on an xrInput object
  48470. */
  48471. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48472. /**
  48473. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48474. *
  48475. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48476. * it should be replaced with auto-loaded controllers.
  48477. *
  48478. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48479. */
  48480. export class WebXRMotionControllerManager {
  48481. private static _AvailableControllers;
  48482. private static _Fallbacks;
  48483. private static _ProfileLoadingPromises;
  48484. private static _ProfilesList;
  48485. /**
  48486. * The base URL of the online controller repository. Can be changed at any time.
  48487. */
  48488. static BaseRepositoryUrl: string;
  48489. /**
  48490. * Which repository gets priority - local or online
  48491. */
  48492. static PrioritizeOnlineRepository: boolean;
  48493. /**
  48494. * Use the online repository, or use only locally-defined controllers
  48495. */
  48496. static UseOnlineRepository: boolean;
  48497. /**
  48498. * Clear the cache used for profile loading and reload when requested again
  48499. */
  48500. static ClearProfilesCache(): void;
  48501. /**
  48502. * Register the default fallbacks.
  48503. * This function is called automatically when this file is imported.
  48504. */
  48505. static DefaultFallbacks(): void;
  48506. /**
  48507. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48508. * @param profileId the profile to which a fallback needs to be found
  48509. * @return an array with corresponding fallback profiles
  48510. */
  48511. static FindFallbackWithProfileId(profileId: string): string[];
  48512. /**
  48513. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48514. * The order of search:
  48515. *
  48516. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48517. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48518. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48519. * 4) return the generic trigger controller if none were found
  48520. *
  48521. * @param xrInput the xrInput to which a new controller is initialized
  48522. * @param scene the scene to which the model will be added
  48523. * @param forceProfile force a certain profile for this controller
  48524. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48525. */
  48526. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48527. /**
  48528. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48529. *
  48530. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48531. *
  48532. * @param type the profile type to register
  48533. * @param constructFunction the function to be called when loading this profile
  48534. */
  48535. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48536. /**
  48537. * Register a fallback to a specific profile.
  48538. * @param profileId the profileId that will receive the fallbacks
  48539. * @param fallbacks A list of fallback profiles
  48540. */
  48541. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48542. /**
  48543. * Will update the list of profiles available in the repository
  48544. * @return a promise that resolves to a map of profiles available online
  48545. */
  48546. static UpdateProfilesList(): Promise<{
  48547. [profile: string]: string;
  48548. }>;
  48549. private static _LoadProfileFromRepository;
  48550. private static _LoadProfilesFromAvailableControllers;
  48551. }
  48552. }
  48553. declare module BABYLON {
  48554. /**
  48555. * Configuration options for the WebXR controller creation
  48556. */
  48557. export interface IWebXRControllerOptions {
  48558. /**
  48559. * Should the controller mesh be animated when a user interacts with it
  48560. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48561. */
  48562. disableMotionControllerAnimation?: boolean;
  48563. /**
  48564. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48565. */
  48566. doNotLoadControllerMesh?: boolean;
  48567. /**
  48568. * Force a specific controller type for this controller.
  48569. * This can be used when creating your own profile or when testing different controllers
  48570. */
  48571. forceControllerProfile?: string;
  48572. /**
  48573. * Defines a rendering group ID for meshes that will be loaded.
  48574. * This is for the default controllers only.
  48575. */
  48576. renderingGroupId?: number;
  48577. }
  48578. /**
  48579. * Represents an XR controller
  48580. */
  48581. export class WebXRInputSource {
  48582. private _scene;
  48583. /** The underlying input source for the controller */
  48584. inputSource: XRInputSource;
  48585. private _options;
  48586. private _tmpVector;
  48587. private _uniqueId;
  48588. private _disposed;
  48589. /**
  48590. * 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
  48591. */
  48592. grip?: AbstractMesh;
  48593. /**
  48594. * If available, this is the gamepad object related to this controller.
  48595. * Using this object it is possible to get click events and trackpad changes of the
  48596. * webxr controller that is currently being used.
  48597. */
  48598. motionController?: WebXRAbstractMotionController;
  48599. /**
  48600. * Event that fires when the controller is removed/disposed.
  48601. * The object provided as event data is this controller, after associated assets were disposed.
  48602. * uniqueId is still available.
  48603. */
  48604. onDisposeObservable: Observable<WebXRInputSource>;
  48605. /**
  48606. * Will be triggered when the mesh associated with the motion controller is done loading.
  48607. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48608. * A shortened version of controller -> motion controller -> on mesh loaded.
  48609. */
  48610. onMeshLoadedObservable: Observable<AbstractMesh>;
  48611. /**
  48612. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48613. */
  48614. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48615. /**
  48616. * Pointer which can be used to select objects or attach a visible laser to
  48617. */
  48618. pointer: AbstractMesh;
  48619. /**
  48620. * Creates the input source object
  48621. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48622. * @param _scene the scene which the controller should be associated to
  48623. * @param inputSource the underlying input source for the controller
  48624. * @param _options options for this controller creation
  48625. */
  48626. constructor(_scene: Scene,
  48627. /** The underlying input source for the controller */
  48628. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48629. /**
  48630. * Get this controllers unique id
  48631. */
  48632. get uniqueId(): string;
  48633. /**
  48634. * Disposes of the object
  48635. */
  48636. dispose(): void;
  48637. /**
  48638. * Gets a world space ray coming from the pointer or grip
  48639. * @param result the resulting ray
  48640. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48641. */
  48642. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48643. /**
  48644. * Updates the controller pose based on the given XRFrame
  48645. * @param xrFrame xr frame to update the pose with
  48646. * @param referenceSpace reference space to use
  48647. */
  48648. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48649. }
  48650. }
  48651. declare module BABYLON {
  48652. /**
  48653. * The schema for initialization options of the XR Input class
  48654. */
  48655. export interface IWebXRInputOptions {
  48656. /**
  48657. * If set to true no model will be automatically loaded
  48658. */
  48659. doNotLoadControllerMeshes?: boolean;
  48660. /**
  48661. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48662. * If not found, the xr input profile data will be used.
  48663. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48664. */
  48665. forceInputProfile?: string;
  48666. /**
  48667. * Do not send a request to the controller repository to load the profile.
  48668. *
  48669. * Instead, use the controllers available in babylon itself.
  48670. */
  48671. disableOnlineControllerRepository?: boolean;
  48672. /**
  48673. * A custom URL for the controllers repository
  48674. */
  48675. customControllersRepositoryURL?: string;
  48676. /**
  48677. * Should the controller model's components not move according to the user input
  48678. */
  48679. disableControllerAnimation?: boolean;
  48680. /**
  48681. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48682. */
  48683. controllerOptions?: IWebXRControllerOptions;
  48684. }
  48685. /**
  48686. * XR input used to track XR inputs such as controllers/rays
  48687. */
  48688. export class WebXRInput implements IDisposable {
  48689. /**
  48690. * the xr session manager for this session
  48691. */
  48692. xrSessionManager: WebXRSessionManager;
  48693. /**
  48694. * the WebXR camera for this session. Mainly used for teleportation
  48695. */
  48696. xrCamera: WebXRCamera;
  48697. private readonly options;
  48698. /**
  48699. * XR controllers being tracked
  48700. */
  48701. controllers: Array<WebXRInputSource>;
  48702. private _frameObserver;
  48703. private _sessionEndedObserver;
  48704. private _sessionInitObserver;
  48705. /**
  48706. * Event when a controller has been connected/added
  48707. */
  48708. onControllerAddedObservable: Observable<WebXRInputSource>;
  48709. /**
  48710. * Event when a controller has been removed/disconnected
  48711. */
  48712. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48713. /**
  48714. * Initializes the WebXRInput
  48715. * @param xrSessionManager the xr session manager for this session
  48716. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48717. * @param options = initialization options for this xr input
  48718. */
  48719. constructor(
  48720. /**
  48721. * the xr session manager for this session
  48722. */
  48723. xrSessionManager: WebXRSessionManager,
  48724. /**
  48725. * the WebXR camera for this session. Mainly used for teleportation
  48726. */
  48727. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48728. private _onInputSourcesChange;
  48729. private _addAndRemoveControllers;
  48730. /**
  48731. * Disposes of the object
  48732. */
  48733. dispose(): void;
  48734. }
  48735. }
  48736. declare module BABYLON {
  48737. /**
  48738. * This is the base class for all WebXR features.
  48739. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48740. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48741. */
  48742. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48743. protected _xrSessionManager: WebXRSessionManager;
  48744. private _attached;
  48745. private _removeOnDetach;
  48746. /**
  48747. * Is this feature disposed?
  48748. */
  48749. isDisposed: boolean;
  48750. /**
  48751. * Should auto-attach be disabled?
  48752. */
  48753. disableAutoAttach: boolean;
  48754. /**
  48755. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48756. */
  48757. xrNativeFeatureName: string;
  48758. /**
  48759. * Construct a new (abstract) WebXR feature
  48760. * @param _xrSessionManager the xr session manager for this feature
  48761. */
  48762. constructor(_xrSessionManager: WebXRSessionManager);
  48763. /**
  48764. * Is this feature attached
  48765. */
  48766. get attached(): boolean;
  48767. /**
  48768. * attach this feature
  48769. *
  48770. * @param force should attachment be forced (even when already attached)
  48771. * @returns true if successful, false is failed or already attached
  48772. */
  48773. attach(force?: boolean): boolean;
  48774. /**
  48775. * detach this feature.
  48776. *
  48777. * @returns true if successful, false if failed or already detached
  48778. */
  48779. detach(): boolean;
  48780. /**
  48781. * Dispose this feature and all of the resources attached
  48782. */
  48783. dispose(): void;
  48784. /**
  48785. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48786. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48787. *
  48788. * @returns whether or not the feature is compatible in this environment
  48789. */
  48790. isCompatible(): boolean;
  48791. /**
  48792. * This is used to register callbacks that will automatically be removed when detach is called.
  48793. * @param observable the observable to which the observer will be attached
  48794. * @param callback the callback to register
  48795. */
  48796. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48797. /**
  48798. * Code in this function will be executed on each xrFrame received from the browser.
  48799. * This function will not execute after the feature is detached.
  48800. * @param _xrFrame the current frame
  48801. */
  48802. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48803. }
  48804. }
  48805. declare module BABYLON {
  48806. /**
  48807. * Renders a layer on top of an existing scene
  48808. */
  48809. export class UtilityLayerRenderer implements IDisposable {
  48810. /** the original scene that will be rendered on top of */
  48811. originalScene: Scene;
  48812. private _pointerCaptures;
  48813. private _lastPointerEvents;
  48814. private static _DefaultUtilityLayer;
  48815. private static _DefaultKeepDepthUtilityLayer;
  48816. private _sharedGizmoLight;
  48817. private _renderCamera;
  48818. /**
  48819. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48820. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48821. * @returns the camera that is used when rendering the utility layer
  48822. */
  48823. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48824. /**
  48825. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48826. * @param cam the camera that should be used when rendering the utility layer
  48827. */
  48828. setRenderCamera(cam: Nullable<Camera>): void;
  48829. /**
  48830. * @hidden
  48831. * Light which used by gizmos to get light shading
  48832. */
  48833. _getSharedGizmoLight(): HemisphericLight;
  48834. /**
  48835. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48836. */
  48837. pickUtilitySceneFirst: boolean;
  48838. /**
  48839. * 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)
  48840. */
  48841. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48842. /**
  48843. * 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)
  48844. */
  48845. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48846. /**
  48847. * The scene that is rendered on top of the original scene
  48848. */
  48849. utilityLayerScene: Scene;
  48850. /**
  48851. * If the utility layer should automatically be rendered on top of existing scene
  48852. */
  48853. shouldRender: boolean;
  48854. /**
  48855. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48856. */
  48857. onlyCheckPointerDownEvents: boolean;
  48858. /**
  48859. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48860. */
  48861. processAllEvents: boolean;
  48862. /**
  48863. * Observable raised when the pointer move from the utility layer scene to the main scene
  48864. */
  48865. onPointerOutObservable: Observable<number>;
  48866. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48867. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48868. private _afterRenderObserver;
  48869. private _sceneDisposeObserver;
  48870. private _originalPointerObserver;
  48871. /**
  48872. * Instantiates a UtilityLayerRenderer
  48873. * @param originalScene the original scene that will be rendered on top of
  48874. * @param handleEvents boolean indicating if the utility layer should handle events
  48875. */
  48876. constructor(
  48877. /** the original scene that will be rendered on top of */
  48878. originalScene: Scene, handleEvents?: boolean);
  48879. private _notifyObservers;
  48880. /**
  48881. * Renders the utility layers scene on top of the original scene
  48882. */
  48883. render(): void;
  48884. /**
  48885. * Disposes of the renderer
  48886. */
  48887. dispose(): void;
  48888. private _updateCamera;
  48889. }
  48890. }
  48891. declare module BABYLON {
  48892. /**
  48893. * Options interface for the pointer selection module
  48894. */
  48895. export interface IWebXRControllerPointerSelectionOptions {
  48896. /**
  48897. * if provided, this scene will be used to render meshes.
  48898. */
  48899. customUtilityLayerScene?: Scene;
  48900. /**
  48901. * 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)
  48902. * If not disabled, the last picked point will be used to execute a pointer up event
  48903. * If disabled, pointer up event will be triggered right after the pointer down event.
  48904. * Used in screen and gaze target ray mode only
  48905. */
  48906. disablePointerUpOnTouchOut: boolean;
  48907. /**
  48908. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48909. */
  48910. forceGazeMode: boolean;
  48911. /**
  48912. * 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
  48913. * to start a new countdown to the pointer down event.
  48914. * Defaults to 1.
  48915. */
  48916. gazeModePointerMovedFactor?: number;
  48917. /**
  48918. * Different button type to use instead of the main component
  48919. */
  48920. overrideButtonId?: string;
  48921. /**
  48922. * use this rendering group id for the meshes (optional)
  48923. */
  48924. renderingGroupId?: number;
  48925. /**
  48926. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48927. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48928. * 3000 means 3 seconds between pointing at something and selecting it
  48929. */
  48930. timeToSelect?: number;
  48931. /**
  48932. * Should meshes created here be added to a utility layer or the main scene
  48933. */
  48934. useUtilityLayer?: boolean;
  48935. /**
  48936. * Optional WebXR camera to be used for gaze selection
  48937. */
  48938. gazeCamera?: WebXRCamera;
  48939. /**
  48940. * the xr input to use with this pointer selection
  48941. */
  48942. xrInput: WebXRInput;
  48943. }
  48944. /**
  48945. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48946. */
  48947. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48948. private readonly _options;
  48949. private static _idCounter;
  48950. private _attachController;
  48951. private _controllers;
  48952. private _scene;
  48953. private _tmpVectorForPickCompare;
  48954. /**
  48955. * The module's name
  48956. */
  48957. static readonly Name: string;
  48958. /**
  48959. * The (Babylon) version of this module.
  48960. * This is an integer representing the implementation version.
  48961. * This number does not correspond to the WebXR specs version
  48962. */
  48963. static readonly Version: number;
  48964. /**
  48965. * Disable lighting on the laser pointer (so it will always be visible)
  48966. */
  48967. disablePointerLighting: boolean;
  48968. /**
  48969. * Disable lighting on the selection mesh (so it will always be visible)
  48970. */
  48971. disableSelectionMeshLighting: boolean;
  48972. /**
  48973. * Should the laser pointer be displayed
  48974. */
  48975. displayLaserPointer: boolean;
  48976. /**
  48977. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48978. */
  48979. displaySelectionMesh: boolean;
  48980. /**
  48981. * This color will be set to the laser pointer when selection is triggered
  48982. */
  48983. laserPointerPickedColor: Color3;
  48984. /**
  48985. * Default color of the laser pointer
  48986. */
  48987. laserPointerDefaultColor: Color3;
  48988. /**
  48989. * default color of the selection ring
  48990. */
  48991. selectionMeshDefaultColor: Color3;
  48992. /**
  48993. * This color will be applied to the selection ring when selection is triggered
  48994. */
  48995. selectionMeshPickedColor: Color3;
  48996. /**
  48997. * Optional filter to be used for ray selection. This predicate shares behavior with
  48998. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48999. */
  49000. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49001. /**
  49002. * constructs a new background remover module
  49003. * @param _xrSessionManager the session manager for this module
  49004. * @param _options read-only options to be used in this module
  49005. */
  49006. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49007. /**
  49008. * attach this feature
  49009. * Will usually be called by the features manager
  49010. *
  49011. * @returns true if successful.
  49012. */
  49013. attach(): boolean;
  49014. /**
  49015. * detach this feature.
  49016. * Will usually be called by the features manager
  49017. *
  49018. * @returns true if successful.
  49019. */
  49020. detach(): boolean;
  49021. /**
  49022. * Will get the mesh under a specific pointer.
  49023. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49024. * @param controllerId the controllerId to check
  49025. * @returns The mesh under pointer or null if no mesh is under the pointer
  49026. */
  49027. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49028. /**
  49029. * Get the xr controller that correlates to the pointer id in the pointer event
  49030. *
  49031. * @param id the pointer id to search for
  49032. * @returns the controller that correlates to this id or null if not found
  49033. */
  49034. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49035. protected _onXRFrame(_xrFrame: XRFrame): void;
  49036. private _attachGazeMode;
  49037. private _attachScreenRayMode;
  49038. private _attachTrackedPointerRayMode;
  49039. private _convertNormalToDirectionOfRay;
  49040. private _detachController;
  49041. private _generateNewMeshPair;
  49042. private _pickingMoved;
  49043. private _updatePointerDistance;
  49044. /** @hidden */
  49045. get lasterPointerDefaultColor(): Color3;
  49046. }
  49047. }
  49048. declare module BABYLON {
  49049. /**
  49050. * Button which can be used to enter a different mode of XR
  49051. */
  49052. export class WebXREnterExitUIButton {
  49053. /** button element */
  49054. element: HTMLElement;
  49055. /** XR initialization options for the button */
  49056. sessionMode: XRSessionMode;
  49057. /** Reference space type */
  49058. referenceSpaceType: XRReferenceSpaceType;
  49059. /**
  49060. * Creates a WebXREnterExitUIButton
  49061. * @param element button element
  49062. * @param sessionMode XR initialization session mode
  49063. * @param referenceSpaceType the type of reference space to be used
  49064. */
  49065. constructor(
  49066. /** button element */
  49067. element: HTMLElement,
  49068. /** XR initialization options for the button */
  49069. sessionMode: XRSessionMode,
  49070. /** Reference space type */
  49071. referenceSpaceType: XRReferenceSpaceType);
  49072. /**
  49073. * Extendable function which can be used to update the button's visuals when the state changes
  49074. * @param activeButton the current active button in the UI
  49075. */
  49076. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49077. }
  49078. /**
  49079. * Options to create the webXR UI
  49080. */
  49081. export class WebXREnterExitUIOptions {
  49082. /**
  49083. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49084. */
  49085. customButtons?: Array<WebXREnterExitUIButton>;
  49086. /**
  49087. * A reference space type to use when creating the default button.
  49088. * Default is local-floor
  49089. */
  49090. referenceSpaceType?: XRReferenceSpaceType;
  49091. /**
  49092. * Context to enter xr with
  49093. */
  49094. renderTarget?: Nullable<WebXRRenderTarget>;
  49095. /**
  49096. * A session mode to use when creating the default button.
  49097. * Default is immersive-vr
  49098. */
  49099. sessionMode?: XRSessionMode;
  49100. /**
  49101. * A list of optional features to init the session with
  49102. */
  49103. optionalFeatures?: string[];
  49104. /**
  49105. * A list of optional features to init the session with
  49106. */
  49107. requiredFeatures?: string[];
  49108. }
  49109. /**
  49110. * UI to allow the user to enter/exit XR mode
  49111. */
  49112. export class WebXREnterExitUI implements IDisposable {
  49113. private scene;
  49114. /** version of the options passed to this UI */
  49115. options: WebXREnterExitUIOptions;
  49116. private _activeButton;
  49117. private _buttons;
  49118. /**
  49119. * The HTML Div Element to which buttons are added.
  49120. */
  49121. readonly overlay: HTMLDivElement;
  49122. /**
  49123. * Fired every time the active button is changed.
  49124. *
  49125. * When xr is entered via a button that launches xr that button will be the callback parameter
  49126. *
  49127. * When exiting xr the callback parameter will be null)
  49128. */
  49129. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49130. /**
  49131. *
  49132. * @param scene babylon scene object to use
  49133. * @param options (read-only) version of the options passed to this UI
  49134. */
  49135. private constructor();
  49136. /**
  49137. * Creates UI to allow the user to enter/exit XR mode
  49138. * @param scene the scene to add the ui to
  49139. * @param helper the xr experience helper to enter/exit xr with
  49140. * @param options options to configure the UI
  49141. * @returns the created ui
  49142. */
  49143. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49144. /**
  49145. * Disposes of the XR UI component
  49146. */
  49147. dispose(): void;
  49148. private _updateButtons;
  49149. }
  49150. }
  49151. declare module BABYLON {
  49152. /**
  49153. * Class containing static functions to help procedurally build meshes
  49154. */
  49155. export class LinesBuilder {
  49156. /**
  49157. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49158. * * 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
  49159. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49160. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49161. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49162. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49163. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49164. * * 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
  49165. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49168. * @param name defines the name of the new line system
  49169. * @param options defines the options used to create the line system
  49170. * @param scene defines the hosting scene
  49171. * @returns a new line system mesh
  49172. */
  49173. static CreateLineSystem(name: string, options: {
  49174. lines: Vector3[][];
  49175. updatable?: boolean;
  49176. instance?: Nullable<LinesMesh>;
  49177. colors?: Nullable<Color4[][]>;
  49178. useVertexAlpha?: boolean;
  49179. }, scene: Nullable<Scene>): LinesMesh;
  49180. /**
  49181. * Creates a line mesh
  49182. * 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
  49183. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49184. * * The parameter `points` is an array successive Vector3
  49185. * * 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
  49186. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49187. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49188. * * When updating an instance, remember that only point positions can change, not the number of points
  49189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49191. * @param name defines the name of the new line system
  49192. * @param options defines the options used to create the line system
  49193. * @param scene defines the hosting scene
  49194. * @returns a new line mesh
  49195. */
  49196. static CreateLines(name: string, options: {
  49197. points: Vector3[];
  49198. updatable?: boolean;
  49199. instance?: Nullable<LinesMesh>;
  49200. colors?: Color4[];
  49201. useVertexAlpha?: boolean;
  49202. }, scene?: Nullable<Scene>): LinesMesh;
  49203. /**
  49204. * Creates a dashed line mesh
  49205. * * 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
  49206. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49207. * * The parameter `points` is an array successive Vector3
  49208. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49209. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49210. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49211. * * 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
  49212. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49213. * * When updating an instance, remember that only point positions can change, not the number of points
  49214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49215. * @param name defines the name of the mesh
  49216. * @param options defines the options used to create the mesh
  49217. * @param scene defines the hosting scene
  49218. * @returns the dashed line mesh
  49219. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49220. */
  49221. static CreateDashedLines(name: string, options: {
  49222. points: Vector3[];
  49223. dashSize?: number;
  49224. gapSize?: number;
  49225. dashNb?: number;
  49226. updatable?: boolean;
  49227. instance?: LinesMesh;
  49228. useVertexAlpha?: boolean;
  49229. }, scene?: Nullable<Scene>): LinesMesh;
  49230. }
  49231. }
  49232. declare module BABYLON {
  49233. /**
  49234. * Construction options for a timer
  49235. */
  49236. export interface ITimerOptions<T> {
  49237. /**
  49238. * Time-to-end
  49239. */
  49240. timeout: number;
  49241. /**
  49242. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49243. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49244. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49245. */
  49246. contextObservable: Observable<T>;
  49247. /**
  49248. * Optional parameters when adding an observer to the observable
  49249. */
  49250. observableParameters?: {
  49251. mask?: number;
  49252. insertFirst?: boolean;
  49253. scope?: any;
  49254. };
  49255. /**
  49256. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49257. */
  49258. breakCondition?: (data?: ITimerData<T>) => boolean;
  49259. /**
  49260. * Will be triggered when the time condition has met
  49261. */
  49262. onEnded?: (data: ITimerData<any>) => void;
  49263. /**
  49264. * Will be triggered when the break condition has met (prematurely ended)
  49265. */
  49266. onAborted?: (data: ITimerData<any>) => void;
  49267. /**
  49268. * Optional function to execute on each tick (or count)
  49269. */
  49270. onTick?: (data: ITimerData<any>) => void;
  49271. }
  49272. /**
  49273. * An interface defining the data sent by the timer
  49274. */
  49275. export interface ITimerData<T> {
  49276. /**
  49277. * When did it start
  49278. */
  49279. startTime: number;
  49280. /**
  49281. * Time now
  49282. */
  49283. currentTime: number;
  49284. /**
  49285. * Time passed since started
  49286. */
  49287. deltaTime: number;
  49288. /**
  49289. * How much is completed, in [0.0...1.0].
  49290. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49291. */
  49292. completeRate: number;
  49293. /**
  49294. * What the registered observable sent in the last count
  49295. */
  49296. payload: T;
  49297. }
  49298. /**
  49299. * The current state of the timer
  49300. */
  49301. export enum TimerState {
  49302. /**
  49303. * Timer initialized, not yet started
  49304. */
  49305. INIT = 0,
  49306. /**
  49307. * Timer started and counting
  49308. */
  49309. STARTED = 1,
  49310. /**
  49311. * Timer ended (whether aborted or time reached)
  49312. */
  49313. ENDED = 2
  49314. }
  49315. /**
  49316. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49317. *
  49318. * @param options options with which to initialize this timer
  49319. */
  49320. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49321. /**
  49322. * An advanced implementation of a timer class
  49323. */
  49324. export class AdvancedTimer<T = any> implements IDisposable {
  49325. /**
  49326. * Will notify each time the timer calculates the remaining time
  49327. */
  49328. onEachCountObservable: Observable<ITimerData<T>>;
  49329. /**
  49330. * Will trigger when the timer was aborted due to the break condition
  49331. */
  49332. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49333. /**
  49334. * Will trigger when the timer ended successfully
  49335. */
  49336. onTimerEndedObservable: Observable<ITimerData<T>>;
  49337. /**
  49338. * Will trigger when the timer state has changed
  49339. */
  49340. onStateChangedObservable: Observable<TimerState>;
  49341. private _observer;
  49342. private _contextObservable;
  49343. private _observableParameters;
  49344. private _startTime;
  49345. private _timer;
  49346. private _state;
  49347. private _breakCondition;
  49348. private _timeToEnd;
  49349. private _breakOnNextTick;
  49350. /**
  49351. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49352. * @param options construction options for this advanced timer
  49353. */
  49354. constructor(options: ITimerOptions<T>);
  49355. /**
  49356. * set a breaking condition for this timer. Default is to never break during count
  49357. * @param predicate the new break condition. Returns true to break, false otherwise
  49358. */
  49359. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49360. /**
  49361. * Reset ALL associated observables in this advanced timer
  49362. */
  49363. clearObservables(): void;
  49364. /**
  49365. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49366. *
  49367. * @param timeToEnd how much time to measure until timer ended
  49368. */
  49369. start(timeToEnd?: number): void;
  49370. /**
  49371. * Will force a stop on the next tick.
  49372. */
  49373. stop(): void;
  49374. /**
  49375. * Dispose this timer, clearing all resources
  49376. */
  49377. dispose(): void;
  49378. private _setState;
  49379. private _tick;
  49380. private _stop;
  49381. }
  49382. }
  49383. declare module BABYLON {
  49384. /**
  49385. * The options container for the teleportation module
  49386. */
  49387. export interface IWebXRTeleportationOptions {
  49388. /**
  49389. * if provided, this scene will be used to render meshes.
  49390. */
  49391. customUtilityLayerScene?: Scene;
  49392. /**
  49393. * Values to configure the default target mesh
  49394. */
  49395. defaultTargetMeshOptions?: {
  49396. /**
  49397. * Fill color of the teleportation area
  49398. */
  49399. teleportationFillColor?: string;
  49400. /**
  49401. * Border color for the teleportation area
  49402. */
  49403. teleportationBorderColor?: string;
  49404. /**
  49405. * Disable the mesh's animation sequence
  49406. */
  49407. disableAnimation?: boolean;
  49408. /**
  49409. * Disable lighting on the material or the ring and arrow
  49410. */
  49411. disableLighting?: boolean;
  49412. /**
  49413. * Override the default material of the torus and arrow
  49414. */
  49415. torusArrowMaterial?: Material;
  49416. };
  49417. /**
  49418. * A list of meshes to use as floor meshes.
  49419. * Meshes can be added and removed after initializing the feature using the
  49420. * addFloorMesh and removeFloorMesh functions
  49421. * If empty, rotation will still work
  49422. */
  49423. floorMeshes?: AbstractMesh[];
  49424. /**
  49425. * use this rendering group id for the meshes (optional)
  49426. */
  49427. renderingGroupId?: number;
  49428. /**
  49429. * Should teleportation move only to snap points
  49430. */
  49431. snapPointsOnly?: boolean;
  49432. /**
  49433. * An array of points to which the teleportation will snap to.
  49434. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49435. */
  49436. snapPositions?: Vector3[];
  49437. /**
  49438. * How close should the teleportation ray be in order to snap to position.
  49439. * Default to 0.8 units (meters)
  49440. */
  49441. snapToPositionRadius?: number;
  49442. /**
  49443. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49444. * If you want to support rotation, make sure your mesh has a direction indicator.
  49445. *
  49446. * When left untouched, the default mesh will be initialized.
  49447. */
  49448. teleportationTargetMesh?: AbstractMesh;
  49449. /**
  49450. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49451. */
  49452. timeToTeleport?: number;
  49453. /**
  49454. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49455. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49456. */
  49457. useMainComponentOnly?: boolean;
  49458. /**
  49459. * Should meshes created here be added to a utility layer or the main scene
  49460. */
  49461. useUtilityLayer?: boolean;
  49462. /**
  49463. * Babylon XR Input class for controller
  49464. */
  49465. xrInput: WebXRInput;
  49466. /**
  49467. * Meshes that the teleportation ray cannot go through
  49468. */
  49469. pickBlockerMeshes?: AbstractMesh[];
  49470. }
  49471. /**
  49472. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49473. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49474. * the input of the attached controllers.
  49475. */
  49476. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49477. private _options;
  49478. private _controllers;
  49479. private _currentTeleportationControllerId;
  49480. private _floorMeshes;
  49481. private _quadraticBezierCurve;
  49482. private _selectionFeature;
  49483. private _snapToPositions;
  49484. private _snappedToPoint;
  49485. private _teleportationRingMaterial?;
  49486. private _tmpRay;
  49487. private _tmpVector;
  49488. private _tmpQuaternion;
  49489. /**
  49490. * The module's name
  49491. */
  49492. static readonly Name: string;
  49493. /**
  49494. * The (Babylon) version of this module.
  49495. * This is an integer representing the implementation version.
  49496. * This number does not correspond to the webxr specs version
  49497. */
  49498. static readonly Version: number;
  49499. /**
  49500. * Is movement backwards enabled
  49501. */
  49502. backwardsMovementEnabled: boolean;
  49503. /**
  49504. * Distance to travel when moving backwards
  49505. */
  49506. backwardsTeleportationDistance: number;
  49507. /**
  49508. * The distance from the user to the inspection point in the direction of the controller
  49509. * A higher number will allow the user to move further
  49510. * defaults to 5 (meters, in xr units)
  49511. */
  49512. parabolicCheckRadius: number;
  49513. /**
  49514. * Should the module support parabolic ray on top of direct ray
  49515. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49516. * Very helpful when moving between floors / different heights
  49517. */
  49518. parabolicRayEnabled: boolean;
  49519. /**
  49520. * How much rotation should be applied when rotating right and left
  49521. */
  49522. rotationAngle: number;
  49523. /**
  49524. * Is rotation enabled when moving forward?
  49525. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49526. */
  49527. rotationEnabled: boolean;
  49528. /**
  49529. * constructs a new anchor system
  49530. * @param _xrSessionManager an instance of WebXRSessionManager
  49531. * @param _options configuration object for this feature
  49532. */
  49533. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49534. /**
  49535. * Get the snapPointsOnly flag
  49536. */
  49537. get snapPointsOnly(): boolean;
  49538. /**
  49539. * Sets the snapPointsOnly flag
  49540. * @param snapToPoints should teleportation be exclusively to snap points
  49541. */
  49542. set snapPointsOnly(snapToPoints: boolean);
  49543. /**
  49544. * Add a new mesh to the floor meshes array
  49545. * @param mesh the mesh to use as floor mesh
  49546. */
  49547. addFloorMesh(mesh: AbstractMesh): void;
  49548. /**
  49549. * Add a new snap-to point to fix teleportation to this position
  49550. * @param newSnapPoint The new Snap-To point
  49551. */
  49552. addSnapPoint(newSnapPoint: Vector3): void;
  49553. attach(): boolean;
  49554. detach(): boolean;
  49555. dispose(): void;
  49556. /**
  49557. * Remove a mesh from the floor meshes array
  49558. * @param mesh the mesh to remove
  49559. */
  49560. removeFloorMesh(mesh: AbstractMesh): void;
  49561. /**
  49562. * Remove a mesh from the floor meshes array using its name
  49563. * @param name the mesh name to remove
  49564. */
  49565. removeFloorMeshByName(name: string): void;
  49566. /**
  49567. * 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
  49568. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49569. * @returns was the point found and removed or not
  49570. */
  49571. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49572. /**
  49573. * This function sets a selection feature that will be disabled when
  49574. * the forward ray is shown and will be reattached when hidden.
  49575. * This is used to remove the selection rays when moving.
  49576. * @param selectionFeature the feature to disable when forward movement is enabled
  49577. */
  49578. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  49579. protected _onXRFrame(_xrFrame: XRFrame): void;
  49580. private _attachController;
  49581. private _createDefaultTargetMesh;
  49582. private _detachController;
  49583. private _findClosestSnapPointWithRadius;
  49584. private _setTargetMeshPosition;
  49585. private _setTargetMeshVisibility;
  49586. private _showParabolicPath;
  49587. private _teleportForward;
  49588. }
  49589. }
  49590. declare module BABYLON {
  49591. /**
  49592. * Options for the default xr helper
  49593. */
  49594. export class WebXRDefaultExperienceOptions {
  49595. /**
  49596. * Enable or disable default UI to enter XR
  49597. */
  49598. disableDefaultUI?: boolean;
  49599. /**
  49600. * Should teleportation not initialize. defaults to false.
  49601. */
  49602. disableTeleportation?: boolean;
  49603. /**
  49604. * Floor meshes that will be used for teleport
  49605. */
  49606. floorMeshes?: Array<AbstractMesh>;
  49607. /**
  49608. * If set to true, the first frame will not be used to reset position
  49609. * The first frame is mainly used when copying transformation from the old camera
  49610. * Mainly used in AR
  49611. */
  49612. ignoreNativeCameraTransformation?: boolean;
  49613. /**
  49614. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49615. */
  49616. inputOptions?: IWebXRInputOptions;
  49617. /**
  49618. * optional configuration for the output canvas
  49619. */
  49620. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49621. /**
  49622. * optional UI options. This can be used among other to change session mode and reference space type
  49623. */
  49624. uiOptions?: WebXREnterExitUIOptions;
  49625. /**
  49626. * When loading teleportation and pointer select, use stable versions instead of latest.
  49627. */
  49628. useStablePlugins?: boolean;
  49629. /**
  49630. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49631. */
  49632. renderingGroupId?: number;
  49633. /**
  49634. * A list of optional features to init the session with
  49635. * If set to true, all features we support will be added
  49636. */
  49637. optionalFeatures?: boolean | string[];
  49638. }
  49639. /**
  49640. * Default experience which provides a similar setup to the previous webVRExperience
  49641. */
  49642. export class WebXRDefaultExperience {
  49643. /**
  49644. * Base experience
  49645. */
  49646. baseExperience: WebXRExperienceHelper;
  49647. /**
  49648. * Enables ui for entering/exiting xr
  49649. */
  49650. enterExitUI: WebXREnterExitUI;
  49651. /**
  49652. * Input experience extension
  49653. */
  49654. input: WebXRInput;
  49655. /**
  49656. * Enables laser pointer and selection
  49657. */
  49658. pointerSelection: WebXRControllerPointerSelection;
  49659. /**
  49660. * Default target xr should render to
  49661. */
  49662. renderTarget: WebXRRenderTarget;
  49663. /**
  49664. * Enables teleportation
  49665. */
  49666. teleportation: WebXRMotionControllerTeleportation;
  49667. private constructor();
  49668. /**
  49669. * Creates the default xr experience
  49670. * @param scene scene
  49671. * @param options options for basic configuration
  49672. * @returns resulting WebXRDefaultExperience
  49673. */
  49674. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49675. /**
  49676. * DIsposes of the experience helper
  49677. */
  49678. dispose(): void;
  49679. }
  49680. }
  49681. declare module BABYLON {
  49682. /**
  49683. * Options to modify the vr teleportation behavior.
  49684. */
  49685. export interface VRTeleportationOptions {
  49686. /**
  49687. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49688. */
  49689. floorMeshName?: string;
  49690. /**
  49691. * A list of meshes to be used as the teleportation floor. (default: empty)
  49692. */
  49693. floorMeshes?: Mesh[];
  49694. /**
  49695. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49696. */
  49697. teleportationMode?: number;
  49698. /**
  49699. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49700. */
  49701. teleportationTime?: number;
  49702. /**
  49703. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49704. */
  49705. teleportationSpeed?: number;
  49706. /**
  49707. * The easing function used in the animation or null for Linear. (default CircleEase)
  49708. */
  49709. easingFunction?: EasingFunction;
  49710. }
  49711. /**
  49712. * Options to modify the vr experience helper's behavior.
  49713. */
  49714. export interface VRExperienceHelperOptions extends WebVROptions {
  49715. /**
  49716. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49717. */
  49718. createDeviceOrientationCamera?: boolean;
  49719. /**
  49720. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49721. */
  49722. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49723. /**
  49724. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49725. */
  49726. laserToggle?: boolean;
  49727. /**
  49728. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49729. */
  49730. floorMeshes?: Mesh[];
  49731. /**
  49732. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49733. */
  49734. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49735. /**
  49736. * Defines if WebXR should be used instead of WebVR (if available)
  49737. */
  49738. useXR?: boolean;
  49739. }
  49740. /**
  49741. * Event containing information after VR has been entered
  49742. */
  49743. export class OnAfterEnteringVRObservableEvent {
  49744. /**
  49745. * If entering vr was successful
  49746. */
  49747. success: boolean;
  49748. }
  49749. /**
  49750. * Helps to quickly add VR support to an existing scene.
  49751. * See https://doc.babylonjs.com/how_to/webvr_helper
  49752. */
  49753. export class VRExperienceHelper {
  49754. /** Options to modify the vr experience helper's behavior. */
  49755. webVROptions: VRExperienceHelperOptions;
  49756. private _scene;
  49757. private _position;
  49758. private _btnVR;
  49759. private _btnVRDisplayed;
  49760. private _webVRsupported;
  49761. private _webVRready;
  49762. private _webVRrequesting;
  49763. private _webVRpresenting;
  49764. private _hasEnteredVR;
  49765. private _fullscreenVRpresenting;
  49766. private _inputElement;
  49767. private _webVRCamera;
  49768. private _vrDeviceOrientationCamera;
  49769. private _deviceOrientationCamera;
  49770. private _existingCamera;
  49771. private _onKeyDown;
  49772. private _onVrDisplayPresentChange;
  49773. private _onVRDisplayChanged;
  49774. private _onVRRequestPresentStart;
  49775. private _onVRRequestPresentComplete;
  49776. /**
  49777. * 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)
  49778. */
  49779. enableGazeEvenWhenNoPointerLock: boolean;
  49780. /**
  49781. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49782. */
  49783. exitVROnDoubleTap: boolean;
  49784. /**
  49785. * Observable raised right before entering VR.
  49786. */
  49787. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49788. /**
  49789. * Observable raised when entering VR has completed.
  49790. */
  49791. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49792. /**
  49793. * Observable raised when exiting VR.
  49794. */
  49795. onExitingVRObservable: Observable<VRExperienceHelper>;
  49796. /**
  49797. * Observable raised when controller mesh is loaded.
  49798. */
  49799. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49800. /** Return this.onEnteringVRObservable
  49801. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49802. */
  49803. get onEnteringVR(): Observable<VRExperienceHelper>;
  49804. /** Return this.onExitingVRObservable
  49805. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49806. */
  49807. get onExitingVR(): Observable<VRExperienceHelper>;
  49808. /** Return this.onControllerMeshLoadedObservable
  49809. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49810. */
  49811. get onControllerMeshLoaded(): Observable<WebVRController>;
  49812. private _rayLength;
  49813. private _useCustomVRButton;
  49814. private _teleportationRequested;
  49815. private _teleportActive;
  49816. private _floorMeshName;
  49817. private _floorMeshesCollection;
  49818. private _teleportationMode;
  49819. private _teleportationTime;
  49820. private _teleportationSpeed;
  49821. private _teleportationEasing;
  49822. private _rotationAllowed;
  49823. private _teleportBackwardsVector;
  49824. private _teleportationTarget;
  49825. private _isDefaultTeleportationTarget;
  49826. private _postProcessMove;
  49827. private _teleportationFillColor;
  49828. private _teleportationBorderColor;
  49829. private _rotationAngle;
  49830. private _haloCenter;
  49831. private _cameraGazer;
  49832. private _padSensibilityUp;
  49833. private _padSensibilityDown;
  49834. private _leftController;
  49835. private _rightController;
  49836. private _gazeColor;
  49837. private _laserColor;
  49838. private _pickedLaserColor;
  49839. private _pickedGazeColor;
  49840. /**
  49841. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49842. */
  49843. onNewMeshSelected: Observable<AbstractMesh>;
  49844. /**
  49845. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49846. * This observable will provide the mesh and the controller used to select the mesh
  49847. */
  49848. onMeshSelectedWithController: Observable<{
  49849. mesh: AbstractMesh;
  49850. controller: WebVRController;
  49851. }>;
  49852. /**
  49853. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49854. */
  49855. onNewMeshPicked: Observable<PickingInfo>;
  49856. private _circleEase;
  49857. /**
  49858. * Observable raised before camera teleportation
  49859. */
  49860. onBeforeCameraTeleport: Observable<Vector3>;
  49861. /**
  49862. * Observable raised after camera teleportation
  49863. */
  49864. onAfterCameraTeleport: Observable<Vector3>;
  49865. /**
  49866. * Observable raised when current selected mesh gets unselected
  49867. */
  49868. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49869. private _raySelectionPredicate;
  49870. /**
  49871. * To be optionaly changed by user to define custom ray selection
  49872. */
  49873. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49874. /**
  49875. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49876. */
  49877. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49878. /**
  49879. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49880. */
  49881. teleportationEnabled: boolean;
  49882. private _defaultHeight;
  49883. private _teleportationInitialized;
  49884. private _interactionsEnabled;
  49885. private _interactionsRequested;
  49886. private _displayGaze;
  49887. private _displayLaserPointer;
  49888. /**
  49889. * The mesh used to display where the user is going to teleport.
  49890. */
  49891. get teleportationTarget(): Mesh;
  49892. /**
  49893. * Sets the mesh to be used to display where the user is going to teleport.
  49894. */
  49895. set teleportationTarget(value: Mesh);
  49896. /**
  49897. * 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
  49898. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49899. * See https://doc.babylonjs.com/resources/baking_transformations
  49900. */
  49901. get gazeTrackerMesh(): Mesh;
  49902. set gazeTrackerMesh(value: Mesh);
  49903. /**
  49904. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49905. */
  49906. updateGazeTrackerScale: boolean;
  49907. /**
  49908. * If the gaze trackers color should be updated when selecting meshes
  49909. */
  49910. updateGazeTrackerColor: boolean;
  49911. /**
  49912. * If the controller laser color should be updated when selecting meshes
  49913. */
  49914. updateControllerLaserColor: boolean;
  49915. /**
  49916. * The gaze tracking mesh corresponding to the left controller
  49917. */
  49918. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49919. /**
  49920. * The gaze tracking mesh corresponding to the right controller
  49921. */
  49922. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49923. /**
  49924. * If the ray of the gaze should be displayed.
  49925. */
  49926. get displayGaze(): boolean;
  49927. /**
  49928. * Sets if the ray of the gaze should be displayed.
  49929. */
  49930. set displayGaze(value: boolean);
  49931. /**
  49932. * If the ray of the LaserPointer should be displayed.
  49933. */
  49934. get displayLaserPointer(): boolean;
  49935. /**
  49936. * Sets if the ray of the LaserPointer should be displayed.
  49937. */
  49938. set displayLaserPointer(value: boolean);
  49939. /**
  49940. * The deviceOrientationCamera used as the camera when not in VR.
  49941. */
  49942. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49943. /**
  49944. * Based on the current WebVR support, returns the current VR camera used.
  49945. */
  49946. get currentVRCamera(): Nullable<Camera>;
  49947. /**
  49948. * The webVRCamera which is used when in VR.
  49949. */
  49950. get webVRCamera(): WebVRFreeCamera;
  49951. /**
  49952. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49953. */
  49954. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49955. /**
  49956. * The html button that is used to trigger entering into VR.
  49957. */
  49958. get vrButton(): Nullable<HTMLButtonElement>;
  49959. private get _teleportationRequestInitiated();
  49960. /**
  49961. * Defines whether or not Pointer lock should be requested when switching to
  49962. * full screen.
  49963. */
  49964. requestPointerLockOnFullScreen: boolean;
  49965. /**
  49966. * If asking to force XR, this will be populated with the default xr experience
  49967. */
  49968. xr: WebXRDefaultExperience;
  49969. /**
  49970. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49971. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49972. */
  49973. xrTestDone: boolean;
  49974. /**
  49975. * Instantiates a VRExperienceHelper.
  49976. * Helps to quickly add VR support to an existing scene.
  49977. * @param scene The scene the VRExperienceHelper belongs to.
  49978. * @param webVROptions Options to modify the vr experience helper's behavior.
  49979. */
  49980. constructor(scene: Scene,
  49981. /** Options to modify the vr experience helper's behavior. */
  49982. webVROptions?: VRExperienceHelperOptions);
  49983. private completeVRInit;
  49984. private _onDefaultMeshLoaded;
  49985. private _onResize;
  49986. private _onFullscreenChange;
  49987. /**
  49988. * Gets a value indicating if we are currently in VR mode.
  49989. */
  49990. get isInVRMode(): boolean;
  49991. private onVrDisplayPresentChange;
  49992. private onVRDisplayChanged;
  49993. private moveButtonToBottomRight;
  49994. private displayVRButton;
  49995. private updateButtonVisibility;
  49996. private _cachedAngularSensibility;
  49997. /**
  49998. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49999. * Otherwise, will use the fullscreen API.
  50000. */
  50001. enterVR(): void;
  50002. /**
  50003. * Attempt to exit VR, or fullscreen.
  50004. */
  50005. exitVR(): void;
  50006. /**
  50007. * The position of the vr experience helper.
  50008. */
  50009. get position(): Vector3;
  50010. /**
  50011. * Sets the position of the vr experience helper.
  50012. */
  50013. set position(value: Vector3);
  50014. /**
  50015. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50016. */
  50017. enableInteractions(): void;
  50018. private get _noControllerIsActive();
  50019. private beforeRender;
  50020. private _isTeleportationFloor;
  50021. /**
  50022. * Adds a floor mesh to be used for teleportation.
  50023. * @param floorMesh the mesh to be used for teleportation.
  50024. */
  50025. addFloorMesh(floorMesh: Mesh): void;
  50026. /**
  50027. * Removes a floor mesh from being used for teleportation.
  50028. * @param floorMesh the mesh to be removed.
  50029. */
  50030. removeFloorMesh(floorMesh: Mesh): void;
  50031. /**
  50032. * Enables interactions and teleportation using the VR controllers and gaze.
  50033. * @param vrTeleportationOptions options to modify teleportation behavior.
  50034. */
  50035. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50036. private _onNewGamepadConnected;
  50037. private _tryEnableInteractionOnController;
  50038. private _onNewGamepadDisconnected;
  50039. private _enableInteractionOnController;
  50040. private _checkTeleportWithRay;
  50041. private _checkRotate;
  50042. private _checkTeleportBackwards;
  50043. private _enableTeleportationOnController;
  50044. private _createTeleportationCircles;
  50045. private _displayTeleportationTarget;
  50046. private _hideTeleportationTarget;
  50047. private _rotateCamera;
  50048. private _moveTeleportationSelectorTo;
  50049. private _workingVector;
  50050. private _workingQuaternion;
  50051. private _workingMatrix;
  50052. /**
  50053. * Time Constant Teleportation Mode
  50054. */
  50055. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50056. /**
  50057. * Speed Constant Teleportation Mode
  50058. */
  50059. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50060. /**
  50061. * Teleports the users feet to the desired location
  50062. * @param location The location where the user's feet should be placed
  50063. */
  50064. teleportCamera(location: Vector3): void;
  50065. private _convertNormalToDirectionOfRay;
  50066. private _castRayAndSelectObject;
  50067. private _notifySelectedMeshUnselected;
  50068. /**
  50069. * Permanently set new colors for the laser pointer
  50070. * @param color the new laser color
  50071. * @param pickedColor the new laser color when picked mesh detected
  50072. */
  50073. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50074. /**
  50075. * Set lighting enabled / disabled on the laser pointer of both controllers
  50076. * @param enabled should the lighting be enabled on the laser pointer
  50077. */
  50078. setLaserLightingState(enabled?: boolean): void;
  50079. /**
  50080. * Permanently set new colors for the gaze pointer
  50081. * @param color the new gaze color
  50082. * @param pickedColor the new gaze color when picked mesh detected
  50083. */
  50084. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50085. /**
  50086. * Sets the color of the laser ray from the vr controllers.
  50087. * @param color new color for the ray.
  50088. */
  50089. changeLaserColor(color: Color3): void;
  50090. /**
  50091. * Sets the color of the ray from the vr headsets gaze.
  50092. * @param color new color for the ray.
  50093. */
  50094. changeGazeColor(color: Color3): void;
  50095. /**
  50096. * Exits VR and disposes of the vr experience helper
  50097. */
  50098. dispose(): void;
  50099. /**
  50100. * Gets the name of the VRExperienceHelper class
  50101. * @returns "VRExperienceHelper"
  50102. */
  50103. getClassName(): string;
  50104. }
  50105. }
  50106. declare module BABYLON {
  50107. /**
  50108. * Contains an array of blocks representing the octree
  50109. */
  50110. export interface IOctreeContainer<T> {
  50111. /**
  50112. * Blocks within the octree
  50113. */
  50114. blocks: Array<OctreeBlock<T>>;
  50115. }
  50116. /**
  50117. * Class used to store a cell in an octree
  50118. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50119. */
  50120. export class OctreeBlock<T> {
  50121. /**
  50122. * Gets the content of the current block
  50123. */
  50124. entries: T[];
  50125. /**
  50126. * Gets the list of block children
  50127. */
  50128. blocks: Array<OctreeBlock<T>>;
  50129. private _depth;
  50130. private _maxDepth;
  50131. private _capacity;
  50132. private _minPoint;
  50133. private _maxPoint;
  50134. private _boundingVectors;
  50135. private _creationFunc;
  50136. /**
  50137. * Creates a new block
  50138. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50139. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50140. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50141. * @param depth defines the current depth of this block in the octree
  50142. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50143. * @param creationFunc defines a callback to call when an element is added to the block
  50144. */
  50145. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50146. /**
  50147. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50148. */
  50149. get capacity(): number;
  50150. /**
  50151. * Gets the minimum vector (in world space) of the block's bounding box
  50152. */
  50153. get minPoint(): Vector3;
  50154. /**
  50155. * Gets the maximum vector (in world space) of the block's bounding box
  50156. */
  50157. get maxPoint(): Vector3;
  50158. /**
  50159. * Add a new element to this block
  50160. * @param entry defines the element to add
  50161. */
  50162. addEntry(entry: T): void;
  50163. /**
  50164. * Remove an element from this block
  50165. * @param entry defines the element to remove
  50166. */
  50167. removeEntry(entry: T): void;
  50168. /**
  50169. * Add an array of elements to this block
  50170. * @param entries defines the array of elements to add
  50171. */
  50172. addEntries(entries: T[]): void;
  50173. /**
  50174. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50175. * @param frustumPlanes defines the frustum planes to test
  50176. * @param selection defines the array to store current content if selection is positive
  50177. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50178. */
  50179. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50180. /**
  50181. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50182. * @param sphereCenter defines the bounding sphere center
  50183. * @param sphereRadius defines the bounding sphere radius
  50184. * @param selection defines the array to store current content if selection is positive
  50185. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50186. */
  50187. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50188. /**
  50189. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50190. * @param ray defines the ray to test with
  50191. * @param selection defines the array to store current content if selection is positive
  50192. */
  50193. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50194. /**
  50195. * Subdivide the content into child blocks (this block will then be empty)
  50196. */
  50197. createInnerBlocks(): void;
  50198. /**
  50199. * @hidden
  50200. */
  50201. 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;
  50202. }
  50203. }
  50204. declare module BABYLON {
  50205. /**
  50206. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50207. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50208. */
  50209. export class Octree<T> {
  50210. /** 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.) */
  50211. maxDepth: number;
  50212. /**
  50213. * Blocks within the octree containing objects
  50214. */
  50215. blocks: Array<OctreeBlock<T>>;
  50216. /**
  50217. * Content stored in the octree
  50218. */
  50219. dynamicContent: T[];
  50220. private _maxBlockCapacity;
  50221. private _selectionContent;
  50222. private _creationFunc;
  50223. /**
  50224. * Creates a octree
  50225. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50226. * @param creationFunc function to be used to instatiate the octree
  50227. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50228. * @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.)
  50229. */
  50230. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50231. /** 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.) */
  50232. maxDepth?: number);
  50233. /**
  50234. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50235. * @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);
  50236. * @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);
  50237. * @param entries meshes to be added to the octree blocks
  50238. */
  50239. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50240. /**
  50241. * Adds a mesh to the octree
  50242. * @param entry Mesh to add to the octree
  50243. */
  50244. addMesh(entry: T): void;
  50245. /**
  50246. * Remove an element from the octree
  50247. * @param entry defines the element to remove
  50248. */
  50249. removeMesh(entry: T): void;
  50250. /**
  50251. * Selects an array of meshes within the frustum
  50252. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50253. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50254. * @returns array of meshes within the frustum
  50255. */
  50256. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50257. /**
  50258. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50259. * @param sphereCenter defines the bounding sphere center
  50260. * @param sphereRadius defines the bounding sphere radius
  50261. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50262. * @returns an array of objects that intersect the sphere
  50263. */
  50264. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50265. /**
  50266. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50267. * @param ray defines the ray to test with
  50268. * @returns array of intersected objects
  50269. */
  50270. intersectsRay(ray: Ray): SmartArray<T>;
  50271. /**
  50272. * Adds a mesh into the octree block if it intersects the block
  50273. */
  50274. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50275. /**
  50276. * Adds a submesh into the octree block if it intersects the block
  50277. */
  50278. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50279. }
  50280. }
  50281. declare module BABYLON {
  50282. interface Scene {
  50283. /**
  50284. * @hidden
  50285. * Backing Filed
  50286. */
  50287. _selectionOctree: Octree<AbstractMesh>;
  50288. /**
  50289. * Gets the octree used to boost mesh selection (picking)
  50290. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50291. */
  50292. selectionOctree: Octree<AbstractMesh>;
  50293. /**
  50294. * Creates or updates the octree used to boost selection (picking)
  50295. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50296. * @param maxCapacity defines the maximum capacity per leaf
  50297. * @param maxDepth defines the maximum depth of the octree
  50298. * @returns an octree of AbstractMesh
  50299. */
  50300. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50301. }
  50302. interface AbstractMesh {
  50303. /**
  50304. * @hidden
  50305. * Backing Field
  50306. */
  50307. _submeshesOctree: Octree<SubMesh>;
  50308. /**
  50309. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50310. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50311. * @param maxCapacity defines the maximum size of each block (64 by default)
  50312. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50313. * @returns the new octree
  50314. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50315. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50316. */
  50317. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50318. }
  50319. /**
  50320. * Defines the octree scene component responsible to manage any octrees
  50321. * in a given scene.
  50322. */
  50323. export class OctreeSceneComponent {
  50324. /**
  50325. * The component name help to identify the component in the list of scene components.
  50326. */
  50327. readonly name: string;
  50328. /**
  50329. * The scene the component belongs to.
  50330. */
  50331. scene: Scene;
  50332. /**
  50333. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50334. */
  50335. readonly checksIsEnabled: boolean;
  50336. /**
  50337. * Creates a new instance of the component for the given scene
  50338. * @param scene Defines the scene to register the component in
  50339. */
  50340. constructor(scene: Scene);
  50341. /**
  50342. * Registers the component in a given scene
  50343. */
  50344. register(): void;
  50345. /**
  50346. * Return the list of active meshes
  50347. * @returns the list of active meshes
  50348. */
  50349. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50350. /**
  50351. * Return the list of active sub meshes
  50352. * @param mesh The mesh to get the candidates sub meshes from
  50353. * @returns the list of active sub meshes
  50354. */
  50355. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50356. private _tempRay;
  50357. /**
  50358. * Return the list of sub meshes intersecting with a given local ray
  50359. * @param mesh defines the mesh to find the submesh for
  50360. * @param localRay defines the ray in local space
  50361. * @returns the list of intersecting sub meshes
  50362. */
  50363. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50364. /**
  50365. * Return the list of sub meshes colliding with a collider
  50366. * @param mesh defines the mesh to find the submesh for
  50367. * @param collider defines the collider to evaluate the collision against
  50368. * @returns the list of colliding sub meshes
  50369. */
  50370. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50371. /**
  50372. * Rebuilds the elements related to this component in case of
  50373. * context lost for instance.
  50374. */
  50375. rebuild(): void;
  50376. /**
  50377. * Disposes the component and the associated ressources.
  50378. */
  50379. dispose(): void;
  50380. }
  50381. }
  50382. declare module BABYLON {
  50383. /**
  50384. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50385. */
  50386. export class Gizmo implements IDisposable {
  50387. /** The utility layer the gizmo will be added to */
  50388. gizmoLayer: UtilityLayerRenderer;
  50389. /**
  50390. * The root mesh of the gizmo
  50391. */
  50392. _rootMesh: Mesh;
  50393. private _attachedMesh;
  50394. private _attachedNode;
  50395. /**
  50396. * Ratio for the scale of the gizmo (Default: 1)
  50397. */
  50398. protected _scaleRatio: number;
  50399. /**
  50400. * Ratio for the scale of the gizmo (Default: 1)
  50401. */
  50402. set scaleRatio(value: number);
  50403. get scaleRatio(): number;
  50404. /**
  50405. * If a custom mesh has been set (Default: false)
  50406. */
  50407. protected _customMeshSet: boolean;
  50408. /**
  50409. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50410. * * When set, interactions will be enabled
  50411. */
  50412. get attachedMesh(): Nullable<AbstractMesh>;
  50413. set attachedMesh(value: Nullable<AbstractMesh>);
  50414. /**
  50415. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50416. * * When set, interactions will be enabled
  50417. */
  50418. get attachedNode(): Nullable<Node>;
  50419. set attachedNode(value: Nullable<Node>);
  50420. /**
  50421. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50422. * @param mesh The mesh to replace the default mesh of the gizmo
  50423. */
  50424. setCustomMesh(mesh: Mesh): void;
  50425. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50426. /**
  50427. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50428. */
  50429. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50430. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50431. /**
  50432. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50433. */
  50434. updateGizmoPositionToMatchAttachedMesh: boolean;
  50435. /**
  50436. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50437. */
  50438. updateScale: boolean;
  50439. protected _interactionsEnabled: boolean;
  50440. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50441. private _beforeRenderObserver;
  50442. private _tempQuaternion;
  50443. private _tempVector;
  50444. private _tempVector2;
  50445. private _tempMatrix1;
  50446. private _tempMatrix2;
  50447. private _rightHandtoLeftHandMatrix;
  50448. /**
  50449. * Creates a gizmo
  50450. * @param gizmoLayer The utility layer the gizmo will be added to
  50451. */
  50452. constructor(
  50453. /** The utility layer the gizmo will be added to */
  50454. gizmoLayer?: UtilityLayerRenderer);
  50455. /**
  50456. * Updates the gizmo to match the attached mesh's position/rotation
  50457. */
  50458. protected _update(): void;
  50459. /**
  50460. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50461. * @param value Node, TransformNode or mesh
  50462. */
  50463. protected _matrixChanged(): void;
  50464. /**
  50465. * Disposes of the gizmo
  50466. */
  50467. dispose(): void;
  50468. }
  50469. }
  50470. declare module BABYLON {
  50471. /**
  50472. * Single plane drag gizmo
  50473. */
  50474. export class PlaneDragGizmo extends Gizmo {
  50475. /**
  50476. * Drag behavior responsible for the gizmos dragging interactions
  50477. */
  50478. dragBehavior: PointerDragBehavior;
  50479. private _pointerObserver;
  50480. /**
  50481. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50482. */
  50483. snapDistance: number;
  50484. /**
  50485. * Event that fires each time the gizmo snaps to a new location.
  50486. * * snapDistance is the the change in distance
  50487. */
  50488. onSnapObservable: Observable<{
  50489. snapDistance: number;
  50490. }>;
  50491. private _plane;
  50492. private _coloredMaterial;
  50493. private _hoverMaterial;
  50494. private _isEnabled;
  50495. private _parent;
  50496. /** @hidden */
  50497. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50498. /** @hidden */
  50499. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50500. /**
  50501. * Creates a PlaneDragGizmo
  50502. * @param gizmoLayer The utility layer the gizmo will be added to
  50503. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50504. * @param color The color of the gizmo
  50505. */
  50506. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50507. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50508. /**
  50509. * If the gizmo is enabled
  50510. */
  50511. set isEnabled(value: boolean);
  50512. get isEnabled(): boolean;
  50513. /**
  50514. * Disposes of the gizmo
  50515. */
  50516. dispose(): void;
  50517. }
  50518. }
  50519. declare module BABYLON {
  50520. /**
  50521. * Gizmo that enables dragging a mesh along 3 axis
  50522. */
  50523. export class PositionGizmo extends Gizmo {
  50524. /**
  50525. * Internal gizmo used for interactions on the x axis
  50526. */
  50527. xGizmo: AxisDragGizmo;
  50528. /**
  50529. * Internal gizmo used for interactions on the y axis
  50530. */
  50531. yGizmo: AxisDragGizmo;
  50532. /**
  50533. * Internal gizmo used for interactions on the z axis
  50534. */
  50535. zGizmo: AxisDragGizmo;
  50536. /**
  50537. * Internal gizmo used for interactions on the yz plane
  50538. */
  50539. xPlaneGizmo: PlaneDragGizmo;
  50540. /**
  50541. * Internal gizmo used for interactions on the xz plane
  50542. */
  50543. yPlaneGizmo: PlaneDragGizmo;
  50544. /**
  50545. * Internal gizmo used for interactions on the xy plane
  50546. */
  50547. zPlaneGizmo: PlaneDragGizmo;
  50548. /**
  50549. * private variables
  50550. */
  50551. private _meshAttached;
  50552. private _nodeAttached;
  50553. private _snapDistance;
  50554. /** Fires an event when any of it's sub gizmos are dragged */
  50555. onDragStartObservable: Observable<unknown>;
  50556. /** Fires an event when any of it's sub gizmos are released from dragging */
  50557. onDragEndObservable: Observable<unknown>;
  50558. /**
  50559. * If set to true, planar drag is enabled
  50560. */
  50561. private _planarGizmoEnabled;
  50562. get attachedMesh(): Nullable<AbstractMesh>;
  50563. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50564. get attachedNode(): Nullable<Node>;
  50565. set attachedNode(node: Nullable<Node>);
  50566. /**
  50567. * Creates a PositionGizmo
  50568. * @param gizmoLayer The utility layer the gizmo will be added to
  50569. @param thickness display gizmo axis thickness
  50570. */
  50571. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50572. /**
  50573. * If the planar drag gizmo is enabled
  50574. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50575. */
  50576. set planarGizmoEnabled(value: boolean);
  50577. get planarGizmoEnabled(): boolean;
  50578. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50579. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50580. /**
  50581. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50582. */
  50583. set snapDistance(value: number);
  50584. get snapDistance(): number;
  50585. /**
  50586. * Ratio for the scale of the gizmo (Default: 1)
  50587. */
  50588. set scaleRatio(value: number);
  50589. get scaleRatio(): number;
  50590. /**
  50591. * Disposes of the gizmo
  50592. */
  50593. dispose(): void;
  50594. /**
  50595. * CustomMeshes are not supported by this gizmo
  50596. * @param mesh The mesh to replace the default mesh of the gizmo
  50597. */
  50598. setCustomMesh(mesh: Mesh): void;
  50599. }
  50600. }
  50601. declare module BABYLON {
  50602. /**
  50603. * Single axis drag gizmo
  50604. */
  50605. export class AxisDragGizmo extends Gizmo {
  50606. /**
  50607. * Drag behavior responsible for the gizmos dragging interactions
  50608. */
  50609. dragBehavior: PointerDragBehavior;
  50610. private _pointerObserver;
  50611. /**
  50612. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50613. */
  50614. snapDistance: number;
  50615. /**
  50616. * Event that fires each time the gizmo snaps to a new location.
  50617. * * snapDistance is the the change in distance
  50618. */
  50619. onSnapObservable: Observable<{
  50620. snapDistance: number;
  50621. }>;
  50622. private _isEnabled;
  50623. private _parent;
  50624. private _arrow;
  50625. private _coloredMaterial;
  50626. private _hoverMaterial;
  50627. /** @hidden */
  50628. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50629. /** @hidden */
  50630. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50631. /**
  50632. * Creates an AxisDragGizmo
  50633. * @param gizmoLayer The utility layer the gizmo will be added to
  50634. * @param dragAxis The axis which the gizmo will be able to drag on
  50635. * @param color The color of the gizmo
  50636. * @param thickness display gizmo axis thickness
  50637. */
  50638. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50639. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50640. /**
  50641. * If the gizmo is enabled
  50642. */
  50643. set isEnabled(value: boolean);
  50644. get isEnabled(): boolean;
  50645. /**
  50646. * Disposes of the gizmo
  50647. */
  50648. dispose(): void;
  50649. }
  50650. }
  50651. declare module BABYLON.Debug {
  50652. /**
  50653. * The Axes viewer will show 3 axes in a specific point in space
  50654. */
  50655. export class AxesViewer {
  50656. private _xAxis;
  50657. private _yAxis;
  50658. private _zAxis;
  50659. private _scaleLinesFactor;
  50660. private _instanced;
  50661. /**
  50662. * Gets the hosting scene
  50663. */
  50664. scene: Nullable<Scene>;
  50665. /**
  50666. * Gets or sets a number used to scale line length
  50667. */
  50668. scaleLines: number;
  50669. /** Gets the node hierarchy used to render x-axis */
  50670. get xAxis(): TransformNode;
  50671. /** Gets the node hierarchy used to render y-axis */
  50672. get yAxis(): TransformNode;
  50673. /** Gets the node hierarchy used to render z-axis */
  50674. get zAxis(): TransformNode;
  50675. /**
  50676. * Creates a new AxesViewer
  50677. * @param scene defines the hosting scene
  50678. * @param scaleLines defines a number used to scale line length (1 by default)
  50679. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50680. * @param xAxis defines the node hierarchy used to render the x-axis
  50681. * @param yAxis defines the node hierarchy used to render the y-axis
  50682. * @param zAxis defines the node hierarchy used to render the z-axis
  50683. */
  50684. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50685. /**
  50686. * Force the viewer to update
  50687. * @param position defines the position of the viewer
  50688. * @param xaxis defines the x axis of the viewer
  50689. * @param yaxis defines the y axis of the viewer
  50690. * @param zaxis defines the z axis of the viewer
  50691. */
  50692. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50693. /**
  50694. * Creates an instance of this axes viewer.
  50695. * @returns a new axes viewer with instanced meshes
  50696. */
  50697. createInstance(): AxesViewer;
  50698. /** Releases resources */
  50699. dispose(): void;
  50700. private static _SetRenderingGroupId;
  50701. }
  50702. }
  50703. declare module BABYLON.Debug {
  50704. /**
  50705. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50706. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50707. */
  50708. export class BoneAxesViewer extends AxesViewer {
  50709. /**
  50710. * Gets or sets the target mesh where to display the axes viewer
  50711. */
  50712. mesh: Nullable<Mesh>;
  50713. /**
  50714. * Gets or sets the target bone where to display the axes viewer
  50715. */
  50716. bone: Nullable<Bone>;
  50717. /** Gets current position */
  50718. pos: Vector3;
  50719. /** Gets direction of X axis */
  50720. xaxis: Vector3;
  50721. /** Gets direction of Y axis */
  50722. yaxis: Vector3;
  50723. /** Gets direction of Z axis */
  50724. zaxis: Vector3;
  50725. /**
  50726. * Creates a new BoneAxesViewer
  50727. * @param scene defines the hosting scene
  50728. * @param bone defines the target bone
  50729. * @param mesh defines the target mesh
  50730. * @param scaleLines defines a scaling factor for line length (1 by default)
  50731. */
  50732. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50733. /**
  50734. * Force the viewer to update
  50735. */
  50736. update(): void;
  50737. /** Releases resources */
  50738. dispose(): void;
  50739. }
  50740. }
  50741. declare module BABYLON {
  50742. /**
  50743. * Interface used to define scene explorer extensibility option
  50744. */
  50745. export interface IExplorerExtensibilityOption {
  50746. /**
  50747. * Define the option label
  50748. */
  50749. label: string;
  50750. /**
  50751. * Defines the action to execute on click
  50752. */
  50753. action: (entity: any) => void;
  50754. }
  50755. /**
  50756. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50757. */
  50758. export interface IExplorerExtensibilityGroup {
  50759. /**
  50760. * Defines a predicate to test if a given type mut be extended
  50761. */
  50762. predicate: (entity: any) => boolean;
  50763. /**
  50764. * Gets the list of options added to a type
  50765. */
  50766. entries: IExplorerExtensibilityOption[];
  50767. }
  50768. /**
  50769. * Interface used to define the options to use to create the Inspector
  50770. */
  50771. export interface IInspectorOptions {
  50772. /**
  50773. * Display in overlay mode (default: false)
  50774. */
  50775. overlay?: boolean;
  50776. /**
  50777. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50778. */
  50779. globalRoot?: HTMLElement;
  50780. /**
  50781. * Display the Scene explorer
  50782. */
  50783. showExplorer?: boolean;
  50784. /**
  50785. * Display the property inspector
  50786. */
  50787. showInspector?: boolean;
  50788. /**
  50789. * Display in embed mode (both panes on the right)
  50790. */
  50791. embedMode?: boolean;
  50792. /**
  50793. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50794. */
  50795. handleResize?: boolean;
  50796. /**
  50797. * Allow the panes to popup (default: true)
  50798. */
  50799. enablePopup?: boolean;
  50800. /**
  50801. * Allow the panes to be closed by users (default: true)
  50802. */
  50803. enableClose?: boolean;
  50804. /**
  50805. * Optional list of extensibility entries
  50806. */
  50807. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50808. /**
  50809. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50810. */
  50811. inspectorURL?: string;
  50812. /**
  50813. * Optional initial tab (default to DebugLayerTab.Properties)
  50814. */
  50815. initialTab?: DebugLayerTab;
  50816. }
  50817. interface Scene {
  50818. /**
  50819. * @hidden
  50820. * Backing field
  50821. */
  50822. _debugLayer: DebugLayer;
  50823. /**
  50824. * Gets the debug layer (aka Inspector) associated with the scene
  50825. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50826. */
  50827. debugLayer: DebugLayer;
  50828. }
  50829. /**
  50830. * Enum of inspector action tab
  50831. */
  50832. export enum DebugLayerTab {
  50833. /**
  50834. * Properties tag (default)
  50835. */
  50836. Properties = 0,
  50837. /**
  50838. * Debug tab
  50839. */
  50840. Debug = 1,
  50841. /**
  50842. * Statistics tab
  50843. */
  50844. Statistics = 2,
  50845. /**
  50846. * Tools tab
  50847. */
  50848. Tools = 3,
  50849. /**
  50850. * Settings tab
  50851. */
  50852. Settings = 4
  50853. }
  50854. /**
  50855. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50856. * what is happening in your scene
  50857. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50858. */
  50859. export class DebugLayer {
  50860. /**
  50861. * Define the url to get the inspector script from.
  50862. * By default it uses the babylonjs CDN.
  50863. * @ignoreNaming
  50864. */
  50865. static InspectorURL: string;
  50866. private _scene;
  50867. private BJSINSPECTOR;
  50868. private _onPropertyChangedObservable?;
  50869. /**
  50870. * Observable triggered when a property is changed through the inspector.
  50871. */
  50872. get onPropertyChangedObservable(): any;
  50873. /**
  50874. * Instantiates a new debug layer.
  50875. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50876. * what is happening in your scene
  50877. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50878. * @param scene Defines the scene to inspect
  50879. */
  50880. constructor(scene: Scene);
  50881. /** Creates the inspector window. */
  50882. private _createInspector;
  50883. /**
  50884. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50885. * @param entity defines the entity to select
  50886. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50887. */
  50888. select(entity: any, lineContainerTitles?: string | string[]): void;
  50889. /** Get the inspector from bundle or global */
  50890. private _getGlobalInspector;
  50891. /**
  50892. * Get if the inspector is visible or not.
  50893. * @returns true if visible otherwise, false
  50894. */
  50895. isVisible(): boolean;
  50896. /**
  50897. * Hide the inspector and close its window.
  50898. */
  50899. hide(): void;
  50900. /**
  50901. * Update the scene in the inspector
  50902. */
  50903. setAsActiveScene(): void;
  50904. /**
  50905. * Launch the debugLayer.
  50906. * @param config Define the configuration of the inspector
  50907. * @return a promise fulfilled when the debug layer is visible
  50908. */
  50909. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50910. }
  50911. }
  50912. declare module BABYLON {
  50913. /**
  50914. * Class containing static functions to help procedurally build meshes
  50915. */
  50916. export class BoxBuilder {
  50917. /**
  50918. * Creates a box mesh
  50919. * * The parameter `size` sets the size (float) of each box side (default 1)
  50920. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50921. * * 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)
  50922. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50924. * * 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
  50925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50926. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50927. * @param name defines the name of the mesh
  50928. * @param options defines the options used to create the mesh
  50929. * @param scene defines the hosting scene
  50930. * @returns the box mesh
  50931. */
  50932. static CreateBox(name: string, options: {
  50933. size?: number;
  50934. width?: number;
  50935. height?: number;
  50936. depth?: number;
  50937. faceUV?: Vector4[];
  50938. faceColors?: Color4[];
  50939. sideOrientation?: number;
  50940. frontUVs?: Vector4;
  50941. backUVs?: Vector4;
  50942. wrap?: boolean;
  50943. topBaseAt?: number;
  50944. bottomBaseAt?: number;
  50945. updatable?: boolean;
  50946. }, scene?: Nullable<Scene>): Mesh;
  50947. }
  50948. }
  50949. declare module BABYLON.Debug {
  50950. /**
  50951. * Used to show the physics impostor around the specific mesh
  50952. */
  50953. export class PhysicsViewer {
  50954. /** @hidden */
  50955. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50956. /** @hidden */
  50957. protected _meshes: Array<Nullable<AbstractMesh>>;
  50958. /** @hidden */
  50959. protected _scene: Nullable<Scene>;
  50960. /** @hidden */
  50961. protected _numMeshes: number;
  50962. /** @hidden */
  50963. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50964. private _renderFunction;
  50965. private _utilityLayer;
  50966. private _debugBoxMesh;
  50967. private _debugSphereMesh;
  50968. private _debugCylinderMesh;
  50969. private _debugMaterial;
  50970. private _debugMeshMeshes;
  50971. /**
  50972. * Creates a new PhysicsViewer
  50973. * @param scene defines the hosting scene
  50974. */
  50975. constructor(scene: Scene);
  50976. /** @hidden */
  50977. protected _updateDebugMeshes(): void;
  50978. /**
  50979. * Renders a specified physic impostor
  50980. * @param impostor defines the impostor to render
  50981. * @param targetMesh defines the mesh represented by the impostor
  50982. * @returns the new debug mesh used to render the impostor
  50983. */
  50984. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50985. /**
  50986. * Hides a specified physic impostor
  50987. * @param impostor defines the impostor to hide
  50988. */
  50989. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50990. private _getDebugMaterial;
  50991. private _getDebugBoxMesh;
  50992. private _getDebugSphereMesh;
  50993. private _getDebugCylinderMesh;
  50994. private _getDebugMeshMesh;
  50995. private _getDebugMesh;
  50996. /** Releases all resources */
  50997. dispose(): void;
  50998. }
  50999. }
  51000. declare module BABYLON {
  51001. /**
  51002. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51003. * in order to better appreciate the issue one might have.
  51004. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51005. */
  51006. export class RayHelper {
  51007. /**
  51008. * Defines the ray we are currently tryin to visualize.
  51009. */
  51010. ray: Nullable<Ray>;
  51011. private _renderPoints;
  51012. private _renderLine;
  51013. private _renderFunction;
  51014. private _scene;
  51015. private _onAfterRenderObserver;
  51016. private _onAfterStepObserver;
  51017. private _attachedToMesh;
  51018. private _meshSpaceDirection;
  51019. private _meshSpaceOrigin;
  51020. /**
  51021. * Helper function to create a colored helper in a scene in one line.
  51022. * @param ray Defines the ray we are currently tryin to visualize
  51023. * @param scene Defines the scene the ray is used in
  51024. * @param color Defines the color we want to see the ray in
  51025. * @returns The newly created ray helper.
  51026. */
  51027. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51028. /**
  51029. * Instantiate a new ray helper.
  51030. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51031. * in order to better appreciate the issue one might have.
  51032. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51033. * @param ray Defines the ray we are currently tryin to visualize
  51034. */
  51035. constructor(ray: Ray);
  51036. /**
  51037. * Shows the ray we are willing to debug.
  51038. * @param scene Defines the scene the ray needs to be rendered in
  51039. * @param color Defines the color the ray needs to be rendered in
  51040. */
  51041. show(scene: Scene, color?: Color3): void;
  51042. /**
  51043. * Hides the ray we are debugging.
  51044. */
  51045. hide(): void;
  51046. private _render;
  51047. /**
  51048. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51049. * @param mesh Defines the mesh we want the helper attached to
  51050. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51051. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51052. * @param length Defines the length of the ray
  51053. */
  51054. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51055. /**
  51056. * Detach the ray helper from the mesh it has previously been attached to.
  51057. */
  51058. detachFromMesh(): void;
  51059. private _updateToMesh;
  51060. /**
  51061. * Dispose the helper and release its associated resources.
  51062. */
  51063. dispose(): void;
  51064. }
  51065. }
  51066. declare module BABYLON {
  51067. /**
  51068. * Defines the options associated with the creation of a SkeletonViewer.
  51069. */
  51070. export interface ISkeletonViewerOptions {
  51071. /** Should the system pause animations before building the Viewer? */
  51072. pauseAnimations: boolean;
  51073. /** Should the system return the skeleton to rest before building? */
  51074. returnToRest: boolean;
  51075. /** public Display Mode of the Viewer */
  51076. displayMode: number;
  51077. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51078. displayOptions: ISkeletonViewerDisplayOptions;
  51079. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51080. computeBonesUsingShaders: boolean;
  51081. /** Flag ignore non weighted bones */
  51082. useAllBones: boolean;
  51083. }
  51084. /**
  51085. * Defines how to display the various bone meshes for the viewer.
  51086. */
  51087. export interface ISkeletonViewerDisplayOptions {
  51088. /** How far down to start tapering the bone spurs */
  51089. midStep?: number;
  51090. /** How big is the midStep? */
  51091. midStepFactor?: number;
  51092. /** Base for the Sphere Size */
  51093. sphereBaseSize?: number;
  51094. /** The ratio of the sphere to the longest bone in units */
  51095. sphereScaleUnit?: number;
  51096. /** Ratio for the Sphere Size */
  51097. sphereFactor?: number;
  51098. }
  51099. /**
  51100. * Defines the constructor options for the BoneWeight Shader.
  51101. */
  51102. export interface IBoneWeightShaderOptions {
  51103. /** Skeleton to Map */
  51104. skeleton: Skeleton;
  51105. /** Colors for Uninfluenced bones */
  51106. colorBase?: Color3;
  51107. /** Colors for 0.0-0.25 Weight bones */
  51108. colorZero?: Color3;
  51109. /** Color for 0.25-0.5 Weight Influence */
  51110. colorQuarter?: Color3;
  51111. /** Color for 0.5-0.75 Weight Influence */
  51112. colorHalf?: Color3;
  51113. /** Color for 0.75-1 Weight Influence */
  51114. colorFull?: Color3;
  51115. /** Color for Zero Weight Influence */
  51116. targetBoneIndex?: number;
  51117. }
  51118. /**
  51119. * Simple structure of the gradient steps for the Color Map.
  51120. */
  51121. export interface ISkeletonMapShaderColorMapKnot {
  51122. /** Color of the Knot */
  51123. color: Color3;
  51124. /** Location of the Knot */
  51125. location: number;
  51126. }
  51127. /**
  51128. * Defines the constructor options for the SkeletonMap Shader.
  51129. */
  51130. export interface ISkeletonMapShaderOptions {
  51131. /** Skeleton to Map */
  51132. skeleton: Skeleton;
  51133. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51134. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51135. }
  51136. }
  51137. declare module BABYLON {
  51138. /**
  51139. * Class containing static functions to help procedurally build meshes
  51140. */
  51141. export class RibbonBuilder {
  51142. /**
  51143. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51144. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51145. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51146. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51147. * * 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
  51148. * * 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
  51149. * * 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
  51150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51151. * * 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
  51152. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51153. * * 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
  51154. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51155. * * 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
  51156. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51158. * @param name defines the name of the mesh
  51159. * @param options defines the options used to create the mesh
  51160. * @param scene defines the hosting scene
  51161. * @returns the ribbon mesh
  51162. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51163. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51164. */
  51165. static CreateRibbon(name: string, options: {
  51166. pathArray: Vector3[][];
  51167. closeArray?: boolean;
  51168. closePath?: boolean;
  51169. offset?: number;
  51170. updatable?: boolean;
  51171. sideOrientation?: number;
  51172. frontUVs?: Vector4;
  51173. backUVs?: Vector4;
  51174. instance?: Mesh;
  51175. invertUV?: boolean;
  51176. uvs?: Vector2[];
  51177. colors?: Color4[];
  51178. }, scene?: Nullable<Scene>): Mesh;
  51179. }
  51180. }
  51181. declare module BABYLON {
  51182. /**
  51183. * Class containing static functions to help procedurally build meshes
  51184. */
  51185. export class ShapeBuilder {
  51186. /**
  51187. * 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.
  51188. * * 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.
  51189. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51190. * * 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.
  51191. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51192. * * 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
  51193. * * 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
  51194. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51196. * * 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
  51197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51199. * @param name defines the name of the mesh
  51200. * @param options defines the options used to create the mesh
  51201. * @param scene defines the hosting scene
  51202. * @returns the extruded shape mesh
  51203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51205. */
  51206. static ExtrudeShape(name: string, options: {
  51207. shape: Vector3[];
  51208. path: Vector3[];
  51209. scale?: number;
  51210. rotation?: number;
  51211. cap?: number;
  51212. updatable?: boolean;
  51213. sideOrientation?: number;
  51214. frontUVs?: Vector4;
  51215. backUVs?: Vector4;
  51216. instance?: Mesh;
  51217. invertUV?: boolean;
  51218. }, scene?: Nullable<Scene>): Mesh;
  51219. /**
  51220. * Creates an custom extruded shape mesh.
  51221. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51222. * * 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.
  51223. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51224. * * 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
  51225. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51226. * * 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
  51227. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51228. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51229. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51230. * * 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
  51231. * * 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
  51232. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51234. * * 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
  51235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51237. * @param name defines the name of the mesh
  51238. * @param options defines the options used to create the mesh
  51239. * @param scene defines the hosting scene
  51240. * @returns the custom extruded shape mesh
  51241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51244. */
  51245. static ExtrudeShapeCustom(name: string, options: {
  51246. shape: Vector3[];
  51247. path: Vector3[];
  51248. scaleFunction?: any;
  51249. rotationFunction?: any;
  51250. ribbonCloseArray?: boolean;
  51251. ribbonClosePath?: boolean;
  51252. cap?: number;
  51253. updatable?: boolean;
  51254. sideOrientation?: number;
  51255. frontUVs?: Vector4;
  51256. backUVs?: Vector4;
  51257. instance?: Mesh;
  51258. invertUV?: boolean;
  51259. }, scene?: Nullable<Scene>): Mesh;
  51260. private static _ExtrudeShapeGeneric;
  51261. }
  51262. }
  51263. declare module BABYLON.Debug {
  51264. /**
  51265. * Class used to render a debug view of a given skeleton
  51266. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51267. */
  51268. export class SkeletonViewer {
  51269. /** defines the skeleton to render */
  51270. skeleton: Skeleton;
  51271. /** defines the mesh attached to the skeleton */
  51272. mesh: AbstractMesh;
  51273. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51274. autoUpdateBonesMatrices: boolean;
  51275. /** defines the rendering group id to use with the viewer */
  51276. renderingGroupId: number;
  51277. /** is the options for the viewer */
  51278. options: Partial<ISkeletonViewerOptions>;
  51279. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51280. static readonly DISPLAY_LINES: number;
  51281. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51282. static readonly DISPLAY_SPHERES: number;
  51283. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51284. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51285. /** public static method to create a BoneWeight Shader
  51286. * @param options The constructor options
  51287. * @param scene The scene that the shader is scoped to
  51288. * @returns The created ShaderMaterial
  51289. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51290. */
  51291. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51292. /** public static method to create a BoneWeight Shader
  51293. * @param options The constructor options
  51294. * @param scene The scene that the shader is scoped to
  51295. * @returns The created ShaderMaterial
  51296. */
  51297. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51298. /** private static method to create a BoneWeight Shader
  51299. * @param size The size of the buffer to create (usually the bone count)
  51300. * @param colorMap The gradient data to generate
  51301. * @param scene The scene that the shader is scoped to
  51302. * @returns an Array of floats from the color gradient values
  51303. */
  51304. private static _CreateBoneMapColorBuffer;
  51305. /** If SkeletonViewer scene scope. */
  51306. private _scene;
  51307. /** Gets or sets the color used to render the skeleton */
  51308. color: Color3;
  51309. /** Array of the points of the skeleton fo the line view. */
  51310. private _debugLines;
  51311. /** The SkeletonViewers Mesh. */
  51312. private _debugMesh;
  51313. /** If SkeletonViewer is enabled. */
  51314. private _isEnabled;
  51315. /** If SkeletonViewer is ready. */
  51316. private _ready;
  51317. /** SkeletonViewer render observable. */
  51318. private _obs;
  51319. /** The Utility Layer to render the gizmos in. */
  51320. private _utilityLayer;
  51321. private _boneIndices;
  51322. /** Gets the Scene. */
  51323. get scene(): Scene;
  51324. /** Gets the utilityLayer. */
  51325. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51326. /** Checks Ready Status. */
  51327. get isReady(): Boolean;
  51328. /** Sets Ready Status. */
  51329. set ready(value: boolean);
  51330. /** Gets the debugMesh */
  51331. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51332. /** Sets the debugMesh */
  51333. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51334. /** Gets the displayMode */
  51335. get displayMode(): number;
  51336. /** Sets the displayMode */
  51337. set displayMode(value: number);
  51338. /**
  51339. * Creates a new SkeletonViewer
  51340. * @param skeleton defines the skeleton to render
  51341. * @param mesh defines the mesh attached to the skeleton
  51342. * @param scene defines the hosting scene
  51343. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51344. * @param renderingGroupId defines the rendering group id to use with the viewer
  51345. * @param options All of the extra constructor options for the SkeletonViewer
  51346. */
  51347. constructor(
  51348. /** defines the skeleton to render */
  51349. skeleton: Skeleton,
  51350. /** defines the mesh attached to the skeleton */
  51351. mesh: AbstractMesh,
  51352. /** The Scene scope*/
  51353. scene: Scene,
  51354. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51355. autoUpdateBonesMatrices?: boolean,
  51356. /** defines the rendering group id to use with the viewer */
  51357. renderingGroupId?: number,
  51358. /** is the options for the viewer */
  51359. options?: Partial<ISkeletonViewerOptions>);
  51360. /** The Dynamic bindings for the update functions */
  51361. private _bindObs;
  51362. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51363. update(): void;
  51364. /** Gets or sets a boolean indicating if the viewer is enabled */
  51365. set isEnabled(value: boolean);
  51366. get isEnabled(): boolean;
  51367. private _getBonePosition;
  51368. private _getLinesForBonesWithLength;
  51369. private _getLinesForBonesNoLength;
  51370. /** function to revert the mesh and scene back to the initial state. */
  51371. private _revert;
  51372. /** function to build and bind sphere joint points and spur bone representations. */
  51373. private _buildSpheresAndSpurs;
  51374. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51375. private _displayLinesUpdate;
  51376. /** Changes the displayMode of the skeleton viewer
  51377. * @param mode The displayMode numerical value
  51378. */
  51379. changeDisplayMode(mode: number): void;
  51380. /** Changes the displayMode of the skeleton viewer
  51381. * @param option String of the option name
  51382. * @param value The numerical option value
  51383. */
  51384. changeDisplayOptions(option: string, value: number): void;
  51385. /** Release associated resources */
  51386. dispose(): void;
  51387. }
  51388. }
  51389. declare module BABYLON {
  51390. /**
  51391. * Enum for Device Types
  51392. */
  51393. export enum DeviceType {
  51394. /** Generic */
  51395. Generic = 0,
  51396. /** Keyboard */
  51397. Keyboard = 1,
  51398. /** Mouse */
  51399. Mouse = 2,
  51400. /** Touch Pointers */
  51401. Touch = 3,
  51402. /** PS4 Dual Shock */
  51403. DualShock = 4,
  51404. /** Xbox */
  51405. Xbox = 5,
  51406. /** Switch Controller */
  51407. Switch = 6
  51408. }
  51409. /**
  51410. * Enum for All Pointers (Touch/Mouse)
  51411. */
  51412. export enum PointerInput {
  51413. /** Horizontal Axis */
  51414. Horizontal = 0,
  51415. /** Vertical Axis */
  51416. Vertical = 1,
  51417. /** Left Click or Touch */
  51418. LeftClick = 2,
  51419. /** Middle Click */
  51420. MiddleClick = 3,
  51421. /** Right Click */
  51422. RightClick = 4,
  51423. /** Browser Back */
  51424. BrowserBack = 5,
  51425. /** Browser Forward */
  51426. BrowserForward = 6
  51427. }
  51428. /**
  51429. * Enum for Dual Shock Gamepad
  51430. */
  51431. export enum DualShockInput {
  51432. /** Cross */
  51433. Cross = 0,
  51434. /** Circle */
  51435. Circle = 1,
  51436. /** Square */
  51437. Square = 2,
  51438. /** Triangle */
  51439. Triangle = 3,
  51440. /** L1 */
  51441. L1 = 4,
  51442. /** R1 */
  51443. R1 = 5,
  51444. /** L2 */
  51445. L2 = 6,
  51446. /** R2 */
  51447. R2 = 7,
  51448. /** Share */
  51449. Share = 8,
  51450. /** Options */
  51451. Options = 9,
  51452. /** L3 */
  51453. L3 = 10,
  51454. /** R3 */
  51455. R3 = 11,
  51456. /** DPadUp */
  51457. DPadUp = 12,
  51458. /** DPadDown */
  51459. DPadDown = 13,
  51460. /** DPadLeft */
  51461. DPadLeft = 14,
  51462. /** DRight */
  51463. DPadRight = 15,
  51464. /** Home */
  51465. Home = 16,
  51466. /** TouchPad */
  51467. TouchPad = 17,
  51468. /** LStickXAxis */
  51469. LStickXAxis = 18,
  51470. /** LStickYAxis */
  51471. LStickYAxis = 19,
  51472. /** RStickXAxis */
  51473. RStickXAxis = 20,
  51474. /** RStickYAxis */
  51475. RStickYAxis = 21
  51476. }
  51477. /**
  51478. * Enum for Xbox Gamepad
  51479. */
  51480. export enum XboxInput {
  51481. /** A */
  51482. A = 0,
  51483. /** B */
  51484. B = 1,
  51485. /** X */
  51486. X = 2,
  51487. /** Y */
  51488. Y = 3,
  51489. /** LB */
  51490. LB = 4,
  51491. /** RB */
  51492. RB = 5,
  51493. /** LT */
  51494. LT = 6,
  51495. /** RT */
  51496. RT = 7,
  51497. /** Back */
  51498. Back = 8,
  51499. /** Start */
  51500. Start = 9,
  51501. /** LS */
  51502. LS = 10,
  51503. /** RS */
  51504. RS = 11,
  51505. /** DPadUp */
  51506. DPadUp = 12,
  51507. /** DPadDown */
  51508. DPadDown = 13,
  51509. /** DPadLeft */
  51510. DPadLeft = 14,
  51511. /** DRight */
  51512. DPadRight = 15,
  51513. /** Home */
  51514. Home = 16,
  51515. /** LStickXAxis */
  51516. LStickXAxis = 17,
  51517. /** LStickYAxis */
  51518. LStickYAxis = 18,
  51519. /** RStickXAxis */
  51520. RStickXAxis = 19,
  51521. /** RStickYAxis */
  51522. RStickYAxis = 20
  51523. }
  51524. /**
  51525. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51526. */
  51527. export enum SwitchInput {
  51528. /** B */
  51529. B = 0,
  51530. /** A */
  51531. A = 1,
  51532. /** Y */
  51533. Y = 2,
  51534. /** X */
  51535. X = 3,
  51536. /** L */
  51537. L = 4,
  51538. /** R */
  51539. R = 5,
  51540. /** ZL */
  51541. ZL = 6,
  51542. /** ZR */
  51543. ZR = 7,
  51544. /** Minus */
  51545. Minus = 8,
  51546. /** Plus */
  51547. Plus = 9,
  51548. /** LS */
  51549. LS = 10,
  51550. /** RS */
  51551. RS = 11,
  51552. /** DPadUp */
  51553. DPadUp = 12,
  51554. /** DPadDown */
  51555. DPadDown = 13,
  51556. /** DPadLeft */
  51557. DPadLeft = 14,
  51558. /** DRight */
  51559. DPadRight = 15,
  51560. /** Home */
  51561. Home = 16,
  51562. /** Capture */
  51563. Capture = 17,
  51564. /** LStickXAxis */
  51565. LStickXAxis = 18,
  51566. /** LStickYAxis */
  51567. LStickYAxis = 19,
  51568. /** RStickXAxis */
  51569. RStickXAxis = 20,
  51570. /** RStickYAxis */
  51571. RStickYAxis = 21
  51572. }
  51573. }
  51574. declare module BABYLON {
  51575. /**
  51576. * This class will take all inputs from Keyboard, Pointer, and
  51577. * any Gamepads and provide a polling system that all devices
  51578. * will use. This class assumes that there will only be one
  51579. * pointer device and one keyboard.
  51580. */
  51581. export class DeviceInputSystem implements IDisposable {
  51582. /**
  51583. * Callback to be triggered when a device is connected
  51584. */
  51585. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51586. /**
  51587. * Callback to be triggered when a device is disconnected
  51588. */
  51589. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51590. /**
  51591. * Callback to be triggered when event driven input is updated
  51592. */
  51593. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51594. private _inputs;
  51595. private _gamepads;
  51596. private _keyboardActive;
  51597. private _pointerActive;
  51598. private _elementToAttachTo;
  51599. private _keyboardDownEvent;
  51600. private _keyboardUpEvent;
  51601. private _pointerMoveEvent;
  51602. private _pointerDownEvent;
  51603. private _pointerUpEvent;
  51604. private _gamepadConnectedEvent;
  51605. private _gamepadDisconnectedEvent;
  51606. private static _MAX_KEYCODES;
  51607. private static _MAX_POINTER_INPUTS;
  51608. private constructor();
  51609. /**
  51610. * Creates a new DeviceInputSystem instance
  51611. * @param engine Engine to pull input element from
  51612. * @returns The new instance
  51613. */
  51614. static Create(engine: Engine): DeviceInputSystem;
  51615. /**
  51616. * Checks for current device input value, given an id and input index
  51617. * @param deviceName Id of connected device
  51618. * @param inputIndex Index of device input
  51619. * @returns Current value of input
  51620. */
  51621. /**
  51622. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51623. * @param deviceType Enum specifiying device type
  51624. * @param deviceSlot "Slot" or index that device is referenced in
  51625. * @param inputIndex Id of input to be checked
  51626. * @returns Current value of input
  51627. */
  51628. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51629. /**
  51630. * Dispose of all the eventlisteners
  51631. */
  51632. dispose(): void;
  51633. /**
  51634. * Add device and inputs to device array
  51635. * @param deviceType Enum specifiying device type
  51636. * @param deviceSlot "Slot" or index that device is referenced in
  51637. * @param numberOfInputs Number of input entries to create for given device
  51638. */
  51639. private _registerDevice;
  51640. /**
  51641. * Given a specific device name, remove that device from the device map
  51642. * @param deviceType Enum specifiying device type
  51643. * @param deviceSlot "Slot" or index that device is referenced in
  51644. */
  51645. private _unregisterDevice;
  51646. /**
  51647. * Handle all actions that come from keyboard interaction
  51648. */
  51649. private _handleKeyActions;
  51650. /**
  51651. * Handle all actions that come from pointer interaction
  51652. */
  51653. private _handlePointerActions;
  51654. /**
  51655. * Handle all actions that come from gamepad interaction
  51656. */
  51657. private _handleGamepadActions;
  51658. /**
  51659. * Update all non-event based devices with each frame
  51660. * @param deviceType Enum specifiying device type
  51661. * @param deviceSlot "Slot" or index that device is referenced in
  51662. * @param inputIndex Id of input to be checked
  51663. */
  51664. private _updateDevice;
  51665. /**
  51666. * Gets DeviceType from the device name
  51667. * @param deviceName Name of Device from DeviceInputSystem
  51668. * @returns DeviceType enum value
  51669. */
  51670. private _getGamepadDeviceType;
  51671. }
  51672. }
  51673. declare module BABYLON {
  51674. /**
  51675. * Type to handle enforcement of inputs
  51676. */
  51677. 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;
  51678. }
  51679. declare module BABYLON {
  51680. /**
  51681. * Class that handles all input for a specific device
  51682. */
  51683. export class DeviceSource<T extends DeviceType> {
  51684. /** Type of device */
  51685. readonly deviceType: DeviceType;
  51686. /** "Slot" or index that device is referenced in */
  51687. readonly deviceSlot: number;
  51688. /**
  51689. * Observable to handle device input changes per device
  51690. */
  51691. readonly onInputChangedObservable: Observable<{
  51692. inputIndex: DeviceInput<T>;
  51693. previousState: Nullable<number>;
  51694. currentState: Nullable<number>;
  51695. }>;
  51696. private readonly _deviceInputSystem;
  51697. /**
  51698. * Default Constructor
  51699. * @param deviceInputSystem Reference to DeviceInputSystem
  51700. * @param deviceType Type of device
  51701. * @param deviceSlot "Slot" or index that device is referenced in
  51702. */
  51703. constructor(deviceInputSystem: DeviceInputSystem,
  51704. /** Type of device */
  51705. deviceType: DeviceType,
  51706. /** "Slot" or index that device is referenced in */
  51707. deviceSlot?: number);
  51708. /**
  51709. * Get input for specific input
  51710. * @param inputIndex index of specific input on device
  51711. * @returns Input value from DeviceInputSystem
  51712. */
  51713. getInput(inputIndex: DeviceInput<T>): number;
  51714. }
  51715. /**
  51716. * Class to keep track of devices
  51717. */
  51718. export class DeviceSourceManager implements IDisposable {
  51719. /**
  51720. * Observable to be triggered when before a device is connected
  51721. */
  51722. readonly onBeforeDeviceConnectedObservable: Observable<{
  51723. deviceType: DeviceType;
  51724. deviceSlot: number;
  51725. }>;
  51726. /**
  51727. * Observable to be triggered when before a device is disconnected
  51728. */
  51729. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51730. deviceType: DeviceType;
  51731. deviceSlot: number;
  51732. }>;
  51733. /**
  51734. * Observable to be triggered when after a device is connected
  51735. */
  51736. readonly onAfterDeviceConnectedObservable: Observable<{
  51737. deviceType: DeviceType;
  51738. deviceSlot: number;
  51739. }>;
  51740. /**
  51741. * Observable to be triggered when after a device is disconnected
  51742. */
  51743. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51744. deviceType: DeviceType;
  51745. deviceSlot: number;
  51746. }>;
  51747. private readonly _devices;
  51748. private readonly _firstDevice;
  51749. private readonly _deviceInputSystem;
  51750. /**
  51751. * Default Constructor
  51752. * @param engine engine to pull input element from
  51753. */
  51754. constructor(engine: Engine);
  51755. /**
  51756. * Gets a DeviceSource, given a type and slot
  51757. * @param deviceType Enum specifying device type
  51758. * @param deviceSlot "Slot" or index that device is referenced in
  51759. * @returns DeviceSource object
  51760. */
  51761. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51762. /**
  51763. * Gets an array of DeviceSource objects for a given device type
  51764. * @param deviceType Enum specifying device type
  51765. * @returns Array of DeviceSource objects
  51766. */
  51767. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51768. /**
  51769. * Dispose of DeviceInputSystem and other parts
  51770. */
  51771. dispose(): void;
  51772. /**
  51773. * Function to add device name to device list
  51774. * @param deviceType Enum specifying device type
  51775. * @param deviceSlot "Slot" or index that device is referenced in
  51776. */
  51777. private _addDevice;
  51778. /**
  51779. * Function to remove device name to device list
  51780. * @param deviceType Enum specifying device type
  51781. * @param deviceSlot "Slot" or index that device is referenced in
  51782. */
  51783. private _removeDevice;
  51784. /**
  51785. * Updates array storing first connected device of each type
  51786. * @param type Type of Device
  51787. */
  51788. private _updateFirstDevices;
  51789. }
  51790. }
  51791. declare module BABYLON {
  51792. /**
  51793. * Options to create the null engine
  51794. */
  51795. export class NullEngineOptions {
  51796. /**
  51797. * Render width (Default: 512)
  51798. */
  51799. renderWidth: number;
  51800. /**
  51801. * Render height (Default: 256)
  51802. */
  51803. renderHeight: number;
  51804. /**
  51805. * Texture size (Default: 512)
  51806. */
  51807. textureSize: number;
  51808. /**
  51809. * If delta time between frames should be constant
  51810. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51811. */
  51812. deterministicLockstep: boolean;
  51813. /**
  51814. * Maximum about of steps between frames (Default: 4)
  51815. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51816. */
  51817. lockstepMaxSteps: number;
  51818. /**
  51819. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51820. */
  51821. useHighPrecisionMatrix?: boolean;
  51822. }
  51823. /**
  51824. * The null engine class provides support for headless version of babylon.js.
  51825. * This can be used in server side scenario or for testing purposes
  51826. */
  51827. export class NullEngine extends Engine {
  51828. private _options;
  51829. /**
  51830. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51831. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51832. * @returns true if engine is in deterministic lock step mode
  51833. */
  51834. isDeterministicLockStep(): boolean;
  51835. /**
  51836. * Gets the max steps when engine is running in deterministic lock step
  51837. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51838. * @returns the max steps
  51839. */
  51840. getLockstepMaxSteps(): number;
  51841. /**
  51842. * Gets the current hardware scaling level.
  51843. * By default the hardware scaling level is computed from the window device ratio.
  51844. * 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.
  51845. * @returns a number indicating the current hardware scaling level
  51846. */
  51847. getHardwareScalingLevel(): number;
  51848. constructor(options?: NullEngineOptions);
  51849. /**
  51850. * Creates a vertex buffer
  51851. * @param vertices the data for the vertex buffer
  51852. * @returns the new WebGL static buffer
  51853. */
  51854. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51855. /**
  51856. * Creates a new index buffer
  51857. * @param indices defines the content of the index buffer
  51858. * @param updatable defines if the index buffer must be updatable
  51859. * @returns a new webGL buffer
  51860. */
  51861. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51862. /**
  51863. * Clear the current render buffer or the current render target (if any is set up)
  51864. * @param color defines the color to use
  51865. * @param backBuffer defines if the back buffer must be cleared
  51866. * @param depth defines if the depth buffer must be cleared
  51867. * @param stencil defines if the stencil buffer must be cleared
  51868. */
  51869. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51870. /**
  51871. * Gets the current render width
  51872. * @param useScreen defines if screen size must be used (or the current render target if any)
  51873. * @returns a number defining the current render width
  51874. */
  51875. getRenderWidth(useScreen?: boolean): number;
  51876. /**
  51877. * Gets the current render height
  51878. * @param useScreen defines if screen size must be used (or the current render target if any)
  51879. * @returns a number defining the current render height
  51880. */
  51881. getRenderHeight(useScreen?: boolean): number;
  51882. /**
  51883. * Set the WebGL's viewport
  51884. * @param viewport defines the viewport element to be used
  51885. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51886. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51887. */
  51888. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51889. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51890. /**
  51891. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51892. * @param pipelineContext defines the pipeline context to use
  51893. * @param uniformsNames defines the list of uniform names
  51894. * @returns an array of webGL uniform locations
  51895. */
  51896. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51897. /**
  51898. * Gets the lsit of active attributes for a given webGL program
  51899. * @param pipelineContext defines the pipeline context to use
  51900. * @param attributesNames defines the list of attribute names to get
  51901. * @returns an array of indices indicating the offset of each attribute
  51902. */
  51903. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51904. /**
  51905. * Binds an effect to the webGL context
  51906. * @param effect defines the effect to bind
  51907. */
  51908. bindSamplers(effect: Effect): void;
  51909. /**
  51910. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51911. * @param effect defines the effect to activate
  51912. */
  51913. enableEffect(effect: Effect): void;
  51914. /**
  51915. * Set various states to the webGL context
  51916. * @param culling defines backface culling state
  51917. * @param zOffset defines the value to apply to zOffset (0 by default)
  51918. * @param force defines if states must be applied even if cache is up to date
  51919. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51920. */
  51921. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51922. /**
  51923. * Set the value of an uniform to an array of int32
  51924. * @param uniform defines the webGL uniform location where to store the value
  51925. * @param array defines the array of int32 to store
  51926. */
  51927. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51928. /**
  51929. * Set the value of an uniform to an array of int32 (stored as vec2)
  51930. * @param uniform defines the webGL uniform location where to store the value
  51931. * @param array defines the array of int32 to store
  51932. */
  51933. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51934. /**
  51935. * Set the value of an uniform to an array of int32 (stored as vec3)
  51936. * @param uniform defines the webGL uniform location where to store the value
  51937. * @param array defines the array of int32 to store
  51938. */
  51939. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51940. /**
  51941. * Set the value of an uniform to an array of int32 (stored as vec4)
  51942. * @param uniform defines the webGL uniform location where to store the value
  51943. * @param array defines the array of int32 to store
  51944. */
  51945. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51946. /**
  51947. * Set the value of an uniform to an array of float32
  51948. * @param uniform defines the webGL uniform location where to store the value
  51949. * @param array defines the array of float32 to store
  51950. */
  51951. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51952. /**
  51953. * Set the value of an uniform to an array of float32 (stored as vec2)
  51954. * @param uniform defines the webGL uniform location where to store the value
  51955. * @param array defines the array of float32 to store
  51956. */
  51957. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51958. /**
  51959. * Set the value of an uniform to an array of float32 (stored as vec3)
  51960. * @param uniform defines the webGL uniform location where to store the value
  51961. * @param array defines the array of float32 to store
  51962. */
  51963. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51964. /**
  51965. * Set the value of an uniform to an array of float32 (stored as vec4)
  51966. * @param uniform defines the webGL uniform location where to store the value
  51967. * @param array defines the array of float32 to store
  51968. */
  51969. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51970. /**
  51971. * Set the value of an uniform to an array of number
  51972. * @param uniform defines the webGL uniform location where to store the value
  51973. * @param array defines the array of number to store
  51974. */
  51975. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51976. /**
  51977. * Set the value of an uniform to an array of number (stored as vec2)
  51978. * @param uniform defines the webGL uniform location where to store the value
  51979. * @param array defines the array of number to store
  51980. */
  51981. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51982. /**
  51983. * Set the value of an uniform to an array of number (stored as vec3)
  51984. * @param uniform defines the webGL uniform location where to store the value
  51985. * @param array defines the array of number to store
  51986. */
  51987. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51988. /**
  51989. * Set the value of an uniform to an array of number (stored as vec4)
  51990. * @param uniform defines the webGL uniform location where to store the value
  51991. * @param array defines the array of number to store
  51992. */
  51993. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51994. /**
  51995. * Set the value of an uniform to an array of float32 (stored as matrices)
  51996. * @param uniform defines the webGL uniform location where to store the value
  51997. * @param matrices defines the array of float32 to store
  51998. */
  51999. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52000. /**
  52001. * Set the value of an uniform to a matrix (3x3)
  52002. * @param uniform defines the webGL uniform location where to store the value
  52003. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52004. */
  52005. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52006. /**
  52007. * Set the value of an uniform to a matrix (2x2)
  52008. * @param uniform defines the webGL uniform location where to store the value
  52009. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52010. */
  52011. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52012. /**
  52013. * Set the value of an uniform to a number (float)
  52014. * @param uniform defines the webGL uniform location where to store the value
  52015. * @param value defines the float number to store
  52016. */
  52017. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52018. /**
  52019. * Set the value of an uniform to a vec2
  52020. * @param uniform defines the webGL uniform location where to store the value
  52021. * @param x defines the 1st component of the value
  52022. * @param y defines the 2nd component of the value
  52023. */
  52024. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52025. /**
  52026. * Set the value of an uniform to a vec3
  52027. * @param uniform defines the webGL uniform location where to store the value
  52028. * @param x defines the 1st component of the value
  52029. * @param y defines the 2nd component of the value
  52030. * @param z defines the 3rd component of the value
  52031. */
  52032. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52033. /**
  52034. * Set the value of an uniform to a boolean
  52035. * @param uniform defines the webGL uniform location where to store the value
  52036. * @param bool defines the boolean to store
  52037. */
  52038. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52039. /**
  52040. * Set the value of an uniform to a vec4
  52041. * @param uniform defines the webGL uniform location where to store the value
  52042. * @param x defines the 1st component of the value
  52043. * @param y defines the 2nd component of the value
  52044. * @param z defines the 3rd component of the value
  52045. * @param w defines the 4th component of the value
  52046. */
  52047. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52048. /**
  52049. * Sets the current alpha mode
  52050. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52051. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52052. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52053. */
  52054. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52055. /**
  52056. * Bind webGl buffers directly to the webGL context
  52057. * @param vertexBuffers defines the vertex buffer to bind
  52058. * @param indexBuffer defines the index buffer to bind
  52059. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52060. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52061. * @param effect defines the effect associated with the vertex buffer
  52062. */
  52063. bindBuffers(vertexBuffers: {
  52064. [key: string]: VertexBuffer;
  52065. }, indexBuffer: DataBuffer, effect: Effect): void;
  52066. /**
  52067. * Force the entire cache to be cleared
  52068. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52069. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52070. */
  52071. wipeCaches(bruteForce?: boolean): void;
  52072. /**
  52073. * Send a draw order
  52074. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52075. * @param indexStart defines the starting index
  52076. * @param indexCount defines the number of index to draw
  52077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52078. */
  52079. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52080. /**
  52081. * Draw a list of indexed primitives
  52082. * @param fillMode defines the primitive to use
  52083. * @param indexStart defines the starting index
  52084. * @param indexCount defines the number of index to draw
  52085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52086. */
  52087. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52088. /**
  52089. * Draw a list of unindexed primitives
  52090. * @param fillMode defines the primitive to use
  52091. * @param verticesStart defines the index of first vertex to draw
  52092. * @param verticesCount defines the count of vertices to draw
  52093. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52094. */
  52095. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52096. /** @hidden */
  52097. _createTexture(): WebGLTexture;
  52098. /** @hidden */
  52099. _releaseTexture(texture: InternalTexture): void;
  52100. /**
  52101. * Usually called from Texture.ts.
  52102. * Passed information to create a WebGLTexture
  52103. * @param urlArg defines a value which contains one of the following:
  52104. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52105. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52106. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52107. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52108. * @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)
  52109. * @param scene needed for loading to the correct scene
  52110. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52111. * @param onLoad optional callback to be called upon successful completion
  52112. * @param onError optional callback to be called upon failure
  52113. * @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
  52114. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52115. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52116. * @param forcedExtension defines the extension to use to pick the right loader
  52117. * @param mimeType defines an optional mime type
  52118. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52119. */
  52120. 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;
  52121. /**
  52122. * Creates a new render target texture
  52123. * @param size defines the size of the texture
  52124. * @param options defines the options used to create the texture
  52125. * @returns a new render target texture stored in an InternalTexture
  52126. */
  52127. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52128. /**
  52129. * Update the sampling mode of a given texture
  52130. * @param samplingMode defines the required sampling mode
  52131. * @param texture defines the texture to update
  52132. */
  52133. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52134. /**
  52135. * Binds the frame buffer to the specified texture.
  52136. * @param texture The texture to render to or null for the default canvas
  52137. * @param faceIndex The face of the texture to render to in case of cube texture
  52138. * @param requiredWidth The width of the target to render to
  52139. * @param requiredHeight The height of the target to render to
  52140. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52141. * @param lodLevel defines le lod level to bind to the frame buffer
  52142. */
  52143. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52144. /**
  52145. * Unbind the current render target texture from the webGL context
  52146. * @param texture defines the render target texture to unbind
  52147. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52148. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52149. */
  52150. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52151. /**
  52152. * Creates a dynamic vertex buffer
  52153. * @param vertices the data for the dynamic vertex buffer
  52154. * @returns the new WebGL dynamic buffer
  52155. */
  52156. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52157. /**
  52158. * Update the content of a dynamic texture
  52159. * @param texture defines the texture to update
  52160. * @param canvas defines the canvas containing the source
  52161. * @param invertY defines if data must be stored with Y axis inverted
  52162. * @param premulAlpha defines if alpha is stored as premultiplied
  52163. * @param format defines the format of the data
  52164. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52165. */
  52166. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52167. /**
  52168. * Gets a boolean indicating if all created effects are ready
  52169. * @returns true if all effects are ready
  52170. */
  52171. areAllEffectsReady(): boolean;
  52172. /**
  52173. * @hidden
  52174. * Get the current error code of the webGL context
  52175. * @returns the error code
  52176. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52177. */
  52178. getError(): number;
  52179. /** @hidden */
  52180. _getUnpackAlignement(): number;
  52181. /** @hidden */
  52182. _unpackFlipY(value: boolean): void;
  52183. /**
  52184. * Update a dynamic index buffer
  52185. * @param indexBuffer defines the target index buffer
  52186. * @param indices defines the data to update
  52187. * @param offset defines the offset in the target index buffer where update should start
  52188. */
  52189. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52190. /**
  52191. * Updates a dynamic vertex buffer.
  52192. * @param vertexBuffer the vertex buffer to update
  52193. * @param vertices the data used to update the vertex buffer
  52194. * @param byteOffset the byte offset of the data (optional)
  52195. * @param byteLength the byte length of the data (optional)
  52196. */
  52197. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52198. /** @hidden */
  52199. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52200. /** @hidden */
  52201. _bindTexture(channel: number, texture: InternalTexture): void;
  52202. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52203. /**
  52204. * 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
  52205. */
  52206. releaseEffects(): void;
  52207. displayLoadingUI(): void;
  52208. hideLoadingUI(): void;
  52209. /** @hidden */
  52210. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52211. /** @hidden */
  52212. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52213. /** @hidden */
  52214. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52215. /** @hidden */
  52216. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52217. }
  52218. }
  52219. declare module BABYLON {
  52220. /**
  52221. * @hidden
  52222. **/
  52223. export class _TimeToken {
  52224. _startTimeQuery: Nullable<WebGLQuery>;
  52225. _endTimeQuery: Nullable<WebGLQuery>;
  52226. _timeElapsedQuery: Nullable<WebGLQuery>;
  52227. _timeElapsedQueryEnded: boolean;
  52228. }
  52229. }
  52230. declare module BABYLON {
  52231. /** @hidden */
  52232. export class _OcclusionDataStorage {
  52233. /** @hidden */
  52234. occlusionInternalRetryCounter: number;
  52235. /** @hidden */
  52236. isOcclusionQueryInProgress: boolean;
  52237. /** @hidden */
  52238. isOccluded: boolean;
  52239. /** @hidden */
  52240. occlusionRetryCount: number;
  52241. /** @hidden */
  52242. occlusionType: number;
  52243. /** @hidden */
  52244. occlusionQueryAlgorithmType: number;
  52245. }
  52246. interface Engine {
  52247. /**
  52248. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52249. * @return the new query
  52250. */
  52251. createQuery(): WebGLQuery;
  52252. /**
  52253. * Delete and release a webGL query
  52254. * @param query defines the query to delete
  52255. * @return the current engine
  52256. */
  52257. deleteQuery(query: WebGLQuery): Engine;
  52258. /**
  52259. * Check if a given query has resolved and got its value
  52260. * @param query defines the query to check
  52261. * @returns true if the query got its value
  52262. */
  52263. isQueryResultAvailable(query: WebGLQuery): boolean;
  52264. /**
  52265. * Gets the value of a given query
  52266. * @param query defines the query to check
  52267. * @returns the value of the query
  52268. */
  52269. getQueryResult(query: WebGLQuery): number;
  52270. /**
  52271. * Initiates an occlusion query
  52272. * @param algorithmType defines the algorithm to use
  52273. * @param query defines the query to use
  52274. * @returns the current engine
  52275. * @see https://doc.babylonjs.com/features/occlusionquery
  52276. */
  52277. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52278. /**
  52279. * Ends an occlusion query
  52280. * @see https://doc.babylonjs.com/features/occlusionquery
  52281. * @param algorithmType defines the algorithm to use
  52282. * @returns the current engine
  52283. */
  52284. endOcclusionQuery(algorithmType: number): Engine;
  52285. /**
  52286. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52287. * Please note that only one query can be issued at a time
  52288. * @returns a time token used to track the time span
  52289. */
  52290. startTimeQuery(): Nullable<_TimeToken>;
  52291. /**
  52292. * Ends a time query
  52293. * @param token defines the token used to measure the time span
  52294. * @returns the time spent (in ns)
  52295. */
  52296. endTimeQuery(token: _TimeToken): int;
  52297. /** @hidden */
  52298. _currentNonTimestampToken: Nullable<_TimeToken>;
  52299. /** @hidden */
  52300. _createTimeQuery(): WebGLQuery;
  52301. /** @hidden */
  52302. _deleteTimeQuery(query: WebGLQuery): void;
  52303. /** @hidden */
  52304. _getGlAlgorithmType(algorithmType: number): number;
  52305. /** @hidden */
  52306. _getTimeQueryResult(query: WebGLQuery): any;
  52307. /** @hidden */
  52308. _getTimeQueryAvailability(query: WebGLQuery): any;
  52309. }
  52310. interface AbstractMesh {
  52311. /**
  52312. * Backing filed
  52313. * @hidden
  52314. */
  52315. __occlusionDataStorage: _OcclusionDataStorage;
  52316. /**
  52317. * Access property
  52318. * @hidden
  52319. */
  52320. _occlusionDataStorage: _OcclusionDataStorage;
  52321. /**
  52322. * 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.
  52323. * The default value is -1 which means don't break the query and wait till the result
  52324. * @see https://doc.babylonjs.com/features/occlusionquery
  52325. */
  52326. occlusionRetryCount: number;
  52327. /**
  52328. * 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:
  52329. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52330. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52331. * * 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.
  52332. * @see https://doc.babylonjs.com/features/occlusionquery
  52333. */
  52334. occlusionType: number;
  52335. /**
  52336. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52337. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52338. * * 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.
  52339. * @see https://doc.babylonjs.com/features/occlusionquery
  52340. */
  52341. occlusionQueryAlgorithmType: number;
  52342. /**
  52343. * 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
  52344. * @see https://doc.babylonjs.com/features/occlusionquery
  52345. */
  52346. isOccluded: boolean;
  52347. /**
  52348. * Flag to check the progress status of the query
  52349. * @see https://doc.babylonjs.com/features/occlusionquery
  52350. */
  52351. isOcclusionQueryInProgress: boolean;
  52352. }
  52353. }
  52354. declare module BABYLON {
  52355. /** @hidden */
  52356. export var _forceTransformFeedbackToBundle: boolean;
  52357. interface Engine {
  52358. /**
  52359. * Creates a webGL transform feedback object
  52360. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52361. * @returns the webGL transform feedback object
  52362. */
  52363. createTransformFeedback(): WebGLTransformFeedback;
  52364. /**
  52365. * Delete a webGL transform feedback object
  52366. * @param value defines the webGL transform feedback object to delete
  52367. */
  52368. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52369. /**
  52370. * Bind a webGL transform feedback object to the webgl context
  52371. * @param value defines the webGL transform feedback object to bind
  52372. */
  52373. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52374. /**
  52375. * Begins a transform feedback operation
  52376. * @param usePoints defines if points or triangles must be used
  52377. */
  52378. beginTransformFeedback(usePoints: boolean): void;
  52379. /**
  52380. * Ends a transform feedback operation
  52381. */
  52382. endTransformFeedback(): void;
  52383. /**
  52384. * Specify the varyings to use with transform feedback
  52385. * @param program defines the associated webGL program
  52386. * @param value defines the list of strings representing the varying names
  52387. */
  52388. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52389. /**
  52390. * Bind a webGL buffer for a transform feedback operation
  52391. * @param value defines the webGL buffer to bind
  52392. */
  52393. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52394. }
  52395. }
  52396. declare module BABYLON {
  52397. /**
  52398. * Class used to define an additional view for the engine
  52399. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52400. */
  52401. export class EngineView {
  52402. /** Defines the canvas where to render the view */
  52403. target: HTMLCanvasElement;
  52404. /** Defines an optional camera used to render the view (will use active camera else) */
  52405. camera?: Camera;
  52406. }
  52407. interface Engine {
  52408. /**
  52409. * Gets or sets the HTML element to use for attaching events
  52410. */
  52411. inputElement: Nullable<HTMLElement>;
  52412. /**
  52413. * Gets the current engine view
  52414. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52415. */
  52416. activeView: Nullable<EngineView>;
  52417. /** Gets or sets the list of views */
  52418. views: EngineView[];
  52419. /**
  52420. * Register a new child canvas
  52421. * @param canvas defines the canvas to register
  52422. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52423. * @returns the associated view
  52424. */
  52425. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52426. /**
  52427. * Remove a registered child canvas
  52428. * @param canvas defines the canvas to remove
  52429. * @returns the current engine
  52430. */
  52431. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52432. }
  52433. }
  52434. declare module BABYLON {
  52435. interface Engine {
  52436. /** @hidden */
  52437. _excludedCompressedTextures: string[];
  52438. /** @hidden */
  52439. _textureFormatInUse: string;
  52440. /**
  52441. * Gets the list of texture formats supported
  52442. */
  52443. readonly texturesSupported: Array<string>;
  52444. /**
  52445. * Gets the texture format in use
  52446. */
  52447. readonly textureFormatInUse: Nullable<string>;
  52448. /**
  52449. * Set the compressed texture extensions or file names to skip.
  52450. *
  52451. * @param skippedFiles defines the list of those texture files you want to skip
  52452. * Example: [".dds", ".env", "myfile.png"]
  52453. */
  52454. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52455. /**
  52456. * Set the compressed texture format to use, based on the formats you have, and the formats
  52457. * supported by the hardware / browser.
  52458. *
  52459. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52460. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52461. * to API arguments needed to compressed textures. This puts the burden on the container
  52462. * generator to house the arcane code for determining these for current & future formats.
  52463. *
  52464. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52465. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52466. *
  52467. * Note: The result of this call is not taken into account when a texture is base64.
  52468. *
  52469. * @param formatsAvailable defines the list of those format families you have created
  52470. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52471. *
  52472. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52473. * @returns The extension selected.
  52474. */
  52475. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52476. }
  52477. }
  52478. declare module BABYLON {
  52479. /**
  52480. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52481. */
  52482. export interface CubeMapInfo {
  52483. /**
  52484. * The pixel array for the front face.
  52485. * This is stored in format, left to right, up to down format.
  52486. */
  52487. front: Nullable<ArrayBufferView>;
  52488. /**
  52489. * The pixel array for the back face.
  52490. * This is stored in format, left to right, up to down format.
  52491. */
  52492. back: Nullable<ArrayBufferView>;
  52493. /**
  52494. * The pixel array for the left face.
  52495. * This is stored in format, left to right, up to down format.
  52496. */
  52497. left: Nullable<ArrayBufferView>;
  52498. /**
  52499. * The pixel array for the right face.
  52500. * This is stored in format, left to right, up to down format.
  52501. */
  52502. right: Nullable<ArrayBufferView>;
  52503. /**
  52504. * The pixel array for the up face.
  52505. * This is stored in format, left to right, up to down format.
  52506. */
  52507. up: Nullable<ArrayBufferView>;
  52508. /**
  52509. * The pixel array for the down face.
  52510. * This is stored in format, left to right, up to down format.
  52511. */
  52512. down: Nullable<ArrayBufferView>;
  52513. /**
  52514. * The size of the cubemap stored.
  52515. *
  52516. * Each faces will be size * size pixels.
  52517. */
  52518. size: number;
  52519. /**
  52520. * The format of the texture.
  52521. *
  52522. * RGBA, RGB.
  52523. */
  52524. format: number;
  52525. /**
  52526. * The type of the texture data.
  52527. *
  52528. * UNSIGNED_INT, FLOAT.
  52529. */
  52530. type: number;
  52531. /**
  52532. * Specifies whether the texture is in gamma space.
  52533. */
  52534. gammaSpace: boolean;
  52535. }
  52536. /**
  52537. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52538. */
  52539. export class PanoramaToCubeMapTools {
  52540. private static FACE_LEFT;
  52541. private static FACE_RIGHT;
  52542. private static FACE_FRONT;
  52543. private static FACE_BACK;
  52544. private static FACE_DOWN;
  52545. private static FACE_UP;
  52546. /**
  52547. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52548. *
  52549. * @param float32Array The source data.
  52550. * @param inputWidth The width of the input panorama.
  52551. * @param inputHeight The height of the input panorama.
  52552. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52553. * @return The cubemap data
  52554. */
  52555. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52556. private static CreateCubemapTexture;
  52557. private static CalcProjectionSpherical;
  52558. }
  52559. }
  52560. declare module BABYLON {
  52561. /**
  52562. * Helper class dealing with the extraction of spherical polynomial dataArray
  52563. * from a cube map.
  52564. */
  52565. export class CubeMapToSphericalPolynomialTools {
  52566. private static FileFaces;
  52567. /**
  52568. * Converts a texture to the according Spherical Polynomial data.
  52569. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52570. *
  52571. * @param texture The texture to extract the information from.
  52572. * @return The Spherical Polynomial data.
  52573. */
  52574. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52575. /**
  52576. * Converts a cubemap to the according Spherical Polynomial data.
  52577. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52578. *
  52579. * @param cubeInfo The Cube map to extract the information from.
  52580. * @return The Spherical Polynomial data.
  52581. */
  52582. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52583. }
  52584. }
  52585. declare module BABYLON {
  52586. interface BaseTexture {
  52587. /**
  52588. * Get the polynomial representation of the texture data.
  52589. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52590. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52591. */
  52592. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52593. }
  52594. }
  52595. declare module BABYLON {
  52596. /** @hidden */
  52597. export var rgbdEncodePixelShader: {
  52598. name: string;
  52599. shader: string;
  52600. };
  52601. }
  52602. declare module BABYLON {
  52603. /** @hidden */
  52604. export var rgbdDecodePixelShader: {
  52605. name: string;
  52606. shader: string;
  52607. };
  52608. }
  52609. declare module BABYLON {
  52610. /**
  52611. * Raw texture data and descriptor sufficient for WebGL texture upload
  52612. */
  52613. export interface EnvironmentTextureInfo {
  52614. /**
  52615. * Version of the environment map
  52616. */
  52617. version: number;
  52618. /**
  52619. * Width of image
  52620. */
  52621. width: number;
  52622. /**
  52623. * Irradiance information stored in the file.
  52624. */
  52625. irradiance: any;
  52626. /**
  52627. * Specular information stored in the file.
  52628. */
  52629. specular: any;
  52630. }
  52631. /**
  52632. * Defines One Image in the file. It requires only the position in the file
  52633. * as well as the length.
  52634. */
  52635. interface BufferImageData {
  52636. /**
  52637. * Length of the image data.
  52638. */
  52639. length: number;
  52640. /**
  52641. * Position of the data from the null terminator delimiting the end of the JSON.
  52642. */
  52643. position: number;
  52644. }
  52645. /**
  52646. * Defines the specular data enclosed in the file.
  52647. * This corresponds to the version 1 of the data.
  52648. */
  52649. export interface EnvironmentTextureSpecularInfoV1 {
  52650. /**
  52651. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52652. */
  52653. specularDataPosition?: number;
  52654. /**
  52655. * This contains all the images data needed to reconstruct the cubemap.
  52656. */
  52657. mipmaps: Array<BufferImageData>;
  52658. /**
  52659. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52660. */
  52661. lodGenerationScale: number;
  52662. }
  52663. /**
  52664. * Sets of helpers addressing the serialization and deserialization of environment texture
  52665. * stored in a BabylonJS env file.
  52666. * Those files are usually stored as .env files.
  52667. */
  52668. export class EnvironmentTextureTools {
  52669. /**
  52670. * Magic number identifying the env file.
  52671. */
  52672. private static _MagicBytes;
  52673. /**
  52674. * Gets the environment info from an env file.
  52675. * @param data The array buffer containing the .env bytes.
  52676. * @returns the environment file info (the json header) if successfully parsed.
  52677. */
  52678. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52679. /**
  52680. * Creates an environment texture from a loaded cube texture.
  52681. * @param texture defines the cube texture to convert in env file
  52682. * @return a promise containing the environment data if succesfull.
  52683. */
  52684. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52685. /**
  52686. * Creates a JSON representation of the spherical data.
  52687. * @param texture defines the texture containing the polynomials
  52688. * @return the JSON representation of the spherical info
  52689. */
  52690. private static _CreateEnvTextureIrradiance;
  52691. /**
  52692. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52693. * @param data the image data
  52694. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52695. * @return the views described by info providing access to the underlying buffer
  52696. */
  52697. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52698. /**
  52699. * Uploads the texture info contained in the env file to the GPU.
  52700. * @param texture defines the internal texture to upload to
  52701. * @param data defines the data to load
  52702. * @param info defines the texture info retrieved through the GetEnvInfo method
  52703. * @returns a promise
  52704. */
  52705. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52706. private static _OnImageReadyAsync;
  52707. /**
  52708. * Uploads the levels of image data to the GPU.
  52709. * @param texture defines the internal texture to upload to
  52710. * @param imageData defines the array buffer views of image data [mipmap][face]
  52711. * @returns a promise
  52712. */
  52713. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52714. /**
  52715. * Uploads spherical polynomials information to the texture.
  52716. * @param texture defines the texture we are trying to upload the information to
  52717. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52718. */
  52719. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52720. /** @hidden */
  52721. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52722. }
  52723. }
  52724. declare module BABYLON {
  52725. /**
  52726. * Class used to inline functions in shader code
  52727. */
  52728. export class ShaderCodeInliner {
  52729. private static readonly _RegexpFindFunctionNameAndType;
  52730. private _sourceCode;
  52731. private _functionDescr;
  52732. private _numMaxIterations;
  52733. /** Gets or sets the token used to mark the functions to inline */
  52734. inlineToken: string;
  52735. /** Gets or sets the debug mode */
  52736. debug: boolean;
  52737. /** Gets the code after the inlining process */
  52738. get code(): string;
  52739. /**
  52740. * Initializes the inliner
  52741. * @param sourceCode shader code source to inline
  52742. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52743. */
  52744. constructor(sourceCode: string, numMaxIterations?: number);
  52745. /**
  52746. * Start the processing of the shader code
  52747. */
  52748. processCode(): void;
  52749. private _collectFunctions;
  52750. private _processInlining;
  52751. private _extractBetweenMarkers;
  52752. private _skipWhitespaces;
  52753. private _removeComments;
  52754. private _replaceFunctionCallsByCode;
  52755. private _findBackward;
  52756. private _escapeRegExp;
  52757. private _replaceNames;
  52758. }
  52759. }
  52760. declare module BABYLON {
  52761. /**
  52762. * Container for accessors for natively-stored mesh data buffers.
  52763. */
  52764. class NativeDataBuffer extends DataBuffer {
  52765. /**
  52766. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52767. */
  52768. nativeIndexBuffer?: any;
  52769. /**
  52770. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52771. */
  52772. nativeVertexBuffer?: any;
  52773. }
  52774. /** @hidden */
  52775. class NativeTexture extends InternalTexture {
  52776. getInternalTexture(): InternalTexture;
  52777. getViewCount(): number;
  52778. }
  52779. /** @hidden */
  52780. export class NativeEngine extends Engine {
  52781. private readonly _native;
  52782. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52783. private readonly INVALID_HANDLE;
  52784. private _boundBuffersVertexArray;
  52785. getHardwareScalingLevel(): number;
  52786. constructor();
  52787. dispose(): void;
  52788. /**
  52789. * Can be used to override the current requestAnimationFrame requester.
  52790. * @hidden
  52791. */
  52792. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52793. /**
  52794. * Override default engine behavior.
  52795. * @param color
  52796. * @param backBuffer
  52797. * @param depth
  52798. * @param stencil
  52799. */
  52800. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52801. /**
  52802. * Gets host document
  52803. * @returns the host document object
  52804. */
  52805. getHostDocument(): Nullable<Document>;
  52806. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52807. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52808. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52809. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52810. [key: string]: VertexBuffer;
  52811. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52812. bindBuffers(vertexBuffers: {
  52813. [key: string]: VertexBuffer;
  52814. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52815. recordVertexArrayObject(vertexBuffers: {
  52816. [key: string]: VertexBuffer;
  52817. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52818. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52819. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52820. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52821. /**
  52822. * Draw a list of indexed primitives
  52823. * @param fillMode defines the primitive to use
  52824. * @param indexStart defines the starting index
  52825. * @param indexCount defines the number of index to draw
  52826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52827. */
  52828. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52829. /**
  52830. * Draw a list of unindexed primitives
  52831. * @param fillMode defines the primitive to use
  52832. * @param verticesStart defines the index of first vertex to draw
  52833. * @param verticesCount defines the count of vertices to draw
  52834. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52835. */
  52836. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52837. createPipelineContext(): IPipelineContext;
  52838. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52839. /** @hidden */
  52840. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52841. /** @hidden */
  52842. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52843. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52844. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52845. protected _setProgram(program: WebGLProgram): void;
  52846. _releaseEffect(effect: Effect): void;
  52847. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52848. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52849. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52850. bindSamplers(effect: Effect): void;
  52851. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52852. getRenderWidth(useScreen?: boolean): number;
  52853. getRenderHeight(useScreen?: boolean): number;
  52854. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52855. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52856. /**
  52857. * Set the z offset to apply to current rendering
  52858. * @param value defines the offset to apply
  52859. */
  52860. setZOffset(value: number): void;
  52861. /**
  52862. * Gets the current value of the zOffset
  52863. * @returns the current zOffset state
  52864. */
  52865. getZOffset(): number;
  52866. /**
  52867. * Enable or disable depth buffering
  52868. * @param enable defines the state to set
  52869. */
  52870. setDepthBuffer(enable: boolean): void;
  52871. /**
  52872. * Gets a boolean indicating if depth writing is enabled
  52873. * @returns the current depth writing state
  52874. */
  52875. getDepthWrite(): boolean;
  52876. /**
  52877. * Enable or disable depth writing
  52878. * @param enable defines the state to set
  52879. */
  52880. setDepthWrite(enable: boolean): void;
  52881. /**
  52882. * Enable or disable color writing
  52883. * @param enable defines the state to set
  52884. */
  52885. setColorWrite(enable: boolean): void;
  52886. /**
  52887. * Gets a boolean indicating if color writing is enabled
  52888. * @returns the current color writing state
  52889. */
  52890. getColorWrite(): boolean;
  52891. /**
  52892. * Sets alpha constants used by some alpha blending modes
  52893. * @param r defines the red component
  52894. * @param g defines the green component
  52895. * @param b defines the blue component
  52896. * @param a defines the alpha component
  52897. */
  52898. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52899. /**
  52900. * Sets the current alpha mode
  52901. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52902. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52903. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52904. */
  52905. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52906. /**
  52907. * Gets the current alpha mode
  52908. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52909. * @returns the current alpha mode
  52910. */
  52911. getAlphaMode(): number;
  52912. setInt(uniform: WebGLUniformLocation, int: number): void;
  52913. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52914. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52915. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52916. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52917. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52918. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52919. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52920. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52921. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52922. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52923. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52924. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52925. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52926. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52927. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52928. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52929. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52930. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52931. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52932. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52933. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52934. wipeCaches(bruteForce?: boolean): void;
  52935. _createTexture(): WebGLTexture;
  52936. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52937. /**
  52938. * Usually called from Texture.ts.
  52939. * Passed information to create a WebGLTexture
  52940. * @param url defines a value which contains one of the following:
  52941. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52942. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52943. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52944. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52945. * @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)
  52946. * @param scene needed for loading to the correct scene
  52947. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52948. * @param onLoad optional callback to be called upon successful completion
  52949. * @param onError optional callback to be called upon failure
  52950. * @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
  52951. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52952. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52953. * @param forcedExtension defines the extension to use to pick the right loader
  52954. * @param mimeType defines an optional mime type
  52955. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52956. */
  52957. 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;
  52958. /**
  52959. * Creates a cube texture
  52960. * @param rootUrl defines the url where the files to load is located
  52961. * @param scene defines the current scene
  52962. * @param files defines the list of files to load (1 per face)
  52963. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52964. * @param onLoad defines an optional callback raised when the texture is loaded
  52965. * @param onError defines an optional callback raised if there is an issue to load the texture
  52966. * @param format defines the format of the data
  52967. * @param forcedExtension defines the extension to use to pick the right loader
  52968. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52969. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52970. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52971. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52972. * @returns the cube texture as an InternalTexture
  52973. */
  52974. 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;
  52975. private _getSamplingFilter;
  52976. private static _GetNativeTextureFormat;
  52977. createRenderTargetTexture(size: number | {
  52978. width: number;
  52979. height: number;
  52980. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52981. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52982. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52983. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52984. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52985. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52986. /**
  52987. * Updates a dynamic vertex buffer.
  52988. * @param vertexBuffer the vertex buffer to update
  52989. * @param data the data used to update the vertex buffer
  52990. * @param byteOffset the byte offset of the data (optional)
  52991. * @param byteLength the byte length of the data (optional)
  52992. */
  52993. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52994. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52995. private _updateAnisotropicLevel;
  52996. private _getAddressMode;
  52997. /** @hidden */
  52998. _bindTexture(channel: number, texture: InternalTexture): void;
  52999. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53000. releaseEffects(): void;
  53001. /** @hidden */
  53002. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53003. /** @hidden */
  53004. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53005. /** @hidden */
  53006. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53007. /** @hidden */
  53008. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53009. }
  53010. }
  53011. declare module BABYLON {
  53012. /**
  53013. * Gather the list of clipboard event types as constants.
  53014. */
  53015. export class ClipboardEventTypes {
  53016. /**
  53017. * The clipboard event is fired when a copy command is active (pressed).
  53018. */
  53019. static readonly COPY: number;
  53020. /**
  53021. * The clipboard event is fired when a cut command is active (pressed).
  53022. */
  53023. static readonly CUT: number;
  53024. /**
  53025. * The clipboard event is fired when a paste command is active (pressed).
  53026. */
  53027. static readonly PASTE: number;
  53028. }
  53029. /**
  53030. * This class is used to store clipboard related info for the onClipboardObservable event.
  53031. */
  53032. export class ClipboardInfo {
  53033. /**
  53034. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53035. */
  53036. type: number;
  53037. /**
  53038. * Defines the related dom event
  53039. */
  53040. event: ClipboardEvent;
  53041. /**
  53042. *Creates an instance of ClipboardInfo.
  53043. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53044. * @param event Defines the related dom event
  53045. */
  53046. constructor(
  53047. /**
  53048. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53049. */
  53050. type: number,
  53051. /**
  53052. * Defines the related dom event
  53053. */
  53054. event: ClipboardEvent);
  53055. /**
  53056. * Get the clipboard event's type from the keycode.
  53057. * @param keyCode Defines the keyCode for the current keyboard event.
  53058. * @return {number}
  53059. */
  53060. static GetTypeFromCharacter(keyCode: number): number;
  53061. }
  53062. }
  53063. declare module BABYLON {
  53064. /**
  53065. * Google Daydream controller
  53066. */
  53067. export class DaydreamController extends WebVRController {
  53068. /**
  53069. * Base Url for the controller model.
  53070. */
  53071. static MODEL_BASE_URL: string;
  53072. /**
  53073. * File name for the controller model.
  53074. */
  53075. static MODEL_FILENAME: string;
  53076. /**
  53077. * Gamepad Id prefix used to identify Daydream Controller.
  53078. */
  53079. static readonly GAMEPAD_ID_PREFIX: string;
  53080. /**
  53081. * Creates a new DaydreamController from a gamepad
  53082. * @param vrGamepad the gamepad that the controller should be created from
  53083. */
  53084. constructor(vrGamepad: any);
  53085. /**
  53086. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53087. * @param scene scene in which to add meshes
  53088. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53089. */
  53090. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53091. /**
  53092. * Called once for each button that changed state since the last frame
  53093. * @param buttonIdx Which button index changed
  53094. * @param state New state of the button
  53095. * @param changes Which properties on the state changed since last frame
  53096. */
  53097. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53098. }
  53099. }
  53100. declare module BABYLON {
  53101. /**
  53102. * Gear VR Controller
  53103. */
  53104. export class GearVRController extends WebVRController {
  53105. /**
  53106. * Base Url for the controller model.
  53107. */
  53108. static MODEL_BASE_URL: string;
  53109. /**
  53110. * File name for the controller model.
  53111. */
  53112. static MODEL_FILENAME: string;
  53113. /**
  53114. * Gamepad Id prefix used to identify this controller.
  53115. */
  53116. static readonly GAMEPAD_ID_PREFIX: string;
  53117. private readonly _buttonIndexToObservableNameMap;
  53118. /**
  53119. * Creates a new GearVRController from a gamepad
  53120. * @param vrGamepad the gamepad that the controller should be created from
  53121. */
  53122. constructor(vrGamepad: any);
  53123. /**
  53124. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53125. * @param scene scene in which to add meshes
  53126. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53127. */
  53128. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53129. /**
  53130. * Called once for each button that changed state since the last frame
  53131. * @param buttonIdx Which button index changed
  53132. * @param state New state of the button
  53133. * @param changes Which properties on the state changed since last frame
  53134. */
  53135. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53136. }
  53137. }
  53138. declare module BABYLON {
  53139. /**
  53140. * Generic Controller
  53141. */
  53142. export class GenericController extends WebVRController {
  53143. /**
  53144. * Base Url for the controller model.
  53145. */
  53146. static readonly MODEL_BASE_URL: string;
  53147. /**
  53148. * File name for the controller model.
  53149. */
  53150. static readonly MODEL_FILENAME: string;
  53151. /**
  53152. * Creates a new GenericController from a gamepad
  53153. * @param vrGamepad the gamepad that the controller should be created from
  53154. */
  53155. constructor(vrGamepad: any);
  53156. /**
  53157. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53158. * @param scene scene in which to add meshes
  53159. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53160. */
  53161. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53162. /**
  53163. * Called once for each button that changed state since the last frame
  53164. * @param buttonIdx Which button index changed
  53165. * @param state New state of the button
  53166. * @param changes Which properties on the state changed since last frame
  53167. */
  53168. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53169. }
  53170. }
  53171. declare module BABYLON {
  53172. /**
  53173. * Oculus Touch Controller
  53174. */
  53175. export class OculusTouchController extends WebVRController {
  53176. /**
  53177. * Base Url for the controller model.
  53178. */
  53179. static MODEL_BASE_URL: string;
  53180. /**
  53181. * File name for the left controller model.
  53182. */
  53183. static MODEL_LEFT_FILENAME: string;
  53184. /**
  53185. * File name for the right controller model.
  53186. */
  53187. static MODEL_RIGHT_FILENAME: string;
  53188. /**
  53189. * Base Url for the Quest controller model.
  53190. */
  53191. static QUEST_MODEL_BASE_URL: string;
  53192. /**
  53193. * @hidden
  53194. * If the controllers are running on a device that needs the updated Quest controller models
  53195. */
  53196. static _IsQuest: boolean;
  53197. /**
  53198. * Fired when the secondary trigger on this controller is modified
  53199. */
  53200. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53201. /**
  53202. * Fired when the thumb rest on this controller is modified
  53203. */
  53204. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53205. /**
  53206. * Creates a new OculusTouchController from a gamepad
  53207. * @param vrGamepad the gamepad that the controller should be created from
  53208. */
  53209. constructor(vrGamepad: any);
  53210. /**
  53211. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53212. * @param scene scene in which to add meshes
  53213. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53214. */
  53215. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53216. /**
  53217. * Fired when the A button on this controller is modified
  53218. */
  53219. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53220. /**
  53221. * Fired when the B button on this controller is modified
  53222. */
  53223. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53224. /**
  53225. * Fired when the X button on this controller is modified
  53226. */
  53227. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53228. /**
  53229. * Fired when the Y button on this controller is modified
  53230. */
  53231. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53232. /**
  53233. * Called once for each button that changed state since the last frame
  53234. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53235. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53236. * 2) secondary trigger (same)
  53237. * 3) A (right) X (left), touch, pressed = value
  53238. * 4) B / Y
  53239. * 5) thumb rest
  53240. * @param buttonIdx Which button index changed
  53241. * @param state New state of the button
  53242. * @param changes Which properties on the state changed since last frame
  53243. */
  53244. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53245. }
  53246. }
  53247. declare module BABYLON {
  53248. /**
  53249. * Vive Controller
  53250. */
  53251. export class ViveController extends WebVRController {
  53252. /**
  53253. * Base Url for the controller model.
  53254. */
  53255. static MODEL_BASE_URL: string;
  53256. /**
  53257. * File name for the controller model.
  53258. */
  53259. static MODEL_FILENAME: string;
  53260. /**
  53261. * Creates a new ViveController from a gamepad
  53262. * @param vrGamepad the gamepad that the controller should be created from
  53263. */
  53264. constructor(vrGamepad: any);
  53265. /**
  53266. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53267. * @param scene scene in which to add meshes
  53268. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53269. */
  53270. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53271. /**
  53272. * Fired when the left button on this controller is modified
  53273. */
  53274. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53275. /**
  53276. * Fired when the right button on this controller is modified
  53277. */
  53278. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53279. /**
  53280. * Fired when the menu button on this controller is modified
  53281. */
  53282. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53283. /**
  53284. * Called once for each button that changed state since the last frame
  53285. * Vive mapping:
  53286. * 0: touchpad
  53287. * 1: trigger
  53288. * 2: left AND right buttons
  53289. * 3: menu button
  53290. * @param buttonIdx Which button index changed
  53291. * @param state New state of the button
  53292. * @param changes Which properties on the state changed since last frame
  53293. */
  53294. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53295. }
  53296. }
  53297. declare module BABYLON {
  53298. /**
  53299. * Defines the WindowsMotionController object that the state of the windows motion controller
  53300. */
  53301. export class WindowsMotionController extends WebVRController {
  53302. /**
  53303. * The base url used to load the left and right controller models
  53304. */
  53305. static MODEL_BASE_URL: string;
  53306. /**
  53307. * The name of the left controller model file
  53308. */
  53309. static MODEL_LEFT_FILENAME: string;
  53310. /**
  53311. * The name of the right controller model file
  53312. */
  53313. static MODEL_RIGHT_FILENAME: string;
  53314. /**
  53315. * The controller name prefix for this controller type
  53316. */
  53317. static readonly GAMEPAD_ID_PREFIX: string;
  53318. /**
  53319. * The controller id pattern for this controller type
  53320. */
  53321. private static readonly GAMEPAD_ID_PATTERN;
  53322. private _loadedMeshInfo;
  53323. protected readonly _mapping: {
  53324. buttons: string[];
  53325. buttonMeshNames: {
  53326. trigger: string;
  53327. menu: string;
  53328. grip: string;
  53329. thumbstick: string;
  53330. trackpad: string;
  53331. };
  53332. buttonObservableNames: {
  53333. trigger: string;
  53334. menu: string;
  53335. grip: string;
  53336. thumbstick: string;
  53337. trackpad: string;
  53338. };
  53339. axisMeshNames: string[];
  53340. pointingPoseMeshName: string;
  53341. };
  53342. /**
  53343. * Fired when the trackpad on this controller is clicked
  53344. */
  53345. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53346. /**
  53347. * Fired when the trackpad on this controller is modified
  53348. */
  53349. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53350. /**
  53351. * The current x and y values of this controller's trackpad
  53352. */
  53353. trackpad: StickValues;
  53354. /**
  53355. * Creates a new WindowsMotionController from a gamepad
  53356. * @param vrGamepad the gamepad that the controller should be created from
  53357. */
  53358. constructor(vrGamepad: any);
  53359. /**
  53360. * Fired when the trigger on this controller is modified
  53361. */
  53362. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53363. /**
  53364. * Fired when the menu button on this controller is modified
  53365. */
  53366. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53367. /**
  53368. * Fired when the grip button on this controller is modified
  53369. */
  53370. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53371. /**
  53372. * Fired when the thumbstick button on this controller is modified
  53373. */
  53374. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53375. /**
  53376. * Fired when the touchpad button on this controller is modified
  53377. */
  53378. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53379. /**
  53380. * Fired when the touchpad values on this controller are modified
  53381. */
  53382. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53383. protected _updateTrackpad(): void;
  53384. /**
  53385. * Called once per frame by the engine.
  53386. */
  53387. update(): void;
  53388. /**
  53389. * Called once for each button that changed state since the last frame
  53390. * @param buttonIdx Which button index changed
  53391. * @param state New state of the button
  53392. * @param changes Which properties on the state changed since last frame
  53393. */
  53394. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53395. /**
  53396. * Moves the buttons on the controller mesh based on their current state
  53397. * @param buttonName the name of the button to move
  53398. * @param buttonValue the value of the button which determines the buttons new position
  53399. */
  53400. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53401. /**
  53402. * Moves the axis on the controller mesh based on its current state
  53403. * @param axis the index of the axis
  53404. * @param axisValue the value of the axis which determines the meshes new position
  53405. * @hidden
  53406. */
  53407. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53408. /**
  53409. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53410. * @param scene scene in which to add meshes
  53411. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53412. */
  53413. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53414. /**
  53415. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53416. * can be transformed by button presses and axes values, based on this._mapping.
  53417. *
  53418. * @param scene scene in which the meshes exist
  53419. * @param meshes list of meshes that make up the controller model to process
  53420. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53421. */
  53422. private processModel;
  53423. private createMeshInfo;
  53424. /**
  53425. * Gets the ray of the controller in the direction the controller is pointing
  53426. * @param length the length the resulting ray should be
  53427. * @returns a ray in the direction the controller is pointing
  53428. */
  53429. getForwardRay(length?: number): Ray;
  53430. /**
  53431. * Disposes of the controller
  53432. */
  53433. dispose(): void;
  53434. }
  53435. /**
  53436. * This class represents a new windows motion controller in XR.
  53437. */
  53438. export class XRWindowsMotionController extends WindowsMotionController {
  53439. /**
  53440. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53441. */
  53442. protected readonly _mapping: {
  53443. buttons: string[];
  53444. buttonMeshNames: {
  53445. trigger: string;
  53446. menu: string;
  53447. grip: string;
  53448. thumbstick: string;
  53449. trackpad: string;
  53450. };
  53451. buttonObservableNames: {
  53452. trigger: string;
  53453. menu: string;
  53454. grip: string;
  53455. thumbstick: string;
  53456. trackpad: string;
  53457. };
  53458. axisMeshNames: string[];
  53459. pointingPoseMeshName: string;
  53460. };
  53461. /**
  53462. * Construct a new XR-Based windows motion controller
  53463. *
  53464. * @param gamepadInfo the gamepad object from the browser
  53465. */
  53466. constructor(gamepadInfo: any);
  53467. /**
  53468. * holds the thumbstick values (X,Y)
  53469. */
  53470. thumbstickValues: StickValues;
  53471. /**
  53472. * Fired when the thumbstick on this controller is clicked
  53473. */
  53474. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53475. /**
  53476. * Fired when the thumbstick on this controller is modified
  53477. */
  53478. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53479. /**
  53480. * Fired when the touchpad button on this controller is modified
  53481. */
  53482. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53483. /**
  53484. * Fired when the touchpad values on this controller are modified
  53485. */
  53486. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53487. /**
  53488. * Fired when the thumbstick button on this controller is modified
  53489. * here to prevent breaking changes
  53490. */
  53491. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53492. /**
  53493. * updating the thumbstick(!) and not the trackpad.
  53494. * This is named this way due to the difference between WebVR and XR and to avoid
  53495. * changing the parent class.
  53496. */
  53497. protected _updateTrackpad(): void;
  53498. /**
  53499. * Disposes the class with joy
  53500. */
  53501. dispose(): void;
  53502. }
  53503. }
  53504. declare module BABYLON {
  53505. /**
  53506. * Class containing static functions to help procedurally build meshes
  53507. */
  53508. export class PolyhedronBuilder {
  53509. /**
  53510. * Creates a polyhedron mesh
  53511. * * 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
  53512. * * The parameter `size` (positive float, default 1) sets the polygon size
  53513. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53514. * * 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`
  53515. * * 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
  53516. * * 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)`)
  53517. * * 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
  53518. * * 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
  53519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53520. * * 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
  53521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53522. * @param name defines the name of the mesh
  53523. * @param options defines the options used to create the mesh
  53524. * @param scene defines the hosting scene
  53525. * @returns the polyhedron mesh
  53526. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53527. */
  53528. static CreatePolyhedron(name: string, options: {
  53529. type?: number;
  53530. size?: number;
  53531. sizeX?: number;
  53532. sizeY?: number;
  53533. sizeZ?: number;
  53534. custom?: any;
  53535. faceUV?: Vector4[];
  53536. faceColors?: Color4[];
  53537. flat?: boolean;
  53538. updatable?: boolean;
  53539. sideOrientation?: number;
  53540. frontUVs?: Vector4;
  53541. backUVs?: Vector4;
  53542. }, scene?: Nullable<Scene>): Mesh;
  53543. }
  53544. }
  53545. declare module BABYLON {
  53546. /**
  53547. * Gizmo that enables scaling a mesh along 3 axis
  53548. */
  53549. export class ScaleGizmo extends Gizmo {
  53550. /**
  53551. * Internal gizmo used for interactions on the x axis
  53552. */
  53553. xGizmo: AxisScaleGizmo;
  53554. /**
  53555. * Internal gizmo used for interactions on the y axis
  53556. */
  53557. yGizmo: AxisScaleGizmo;
  53558. /**
  53559. * Internal gizmo used for interactions on the z axis
  53560. */
  53561. zGizmo: AxisScaleGizmo;
  53562. /**
  53563. * Internal gizmo used to scale all axis equally
  53564. */
  53565. uniformScaleGizmo: AxisScaleGizmo;
  53566. private _meshAttached;
  53567. private _nodeAttached;
  53568. private _snapDistance;
  53569. private _uniformScalingMesh;
  53570. private _octahedron;
  53571. private _sensitivity;
  53572. /** Fires an event when any of it's sub gizmos are dragged */
  53573. onDragStartObservable: Observable<unknown>;
  53574. /** Fires an event when any of it's sub gizmos are released from dragging */
  53575. onDragEndObservable: Observable<unknown>;
  53576. get attachedMesh(): Nullable<AbstractMesh>;
  53577. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53578. get attachedNode(): Nullable<Node>;
  53579. set attachedNode(node: Nullable<Node>);
  53580. /**
  53581. * Creates a ScaleGizmo
  53582. * @param gizmoLayer The utility layer the gizmo will be added to
  53583. * @param thickness display gizmo axis thickness
  53584. */
  53585. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53586. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53587. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53588. /**
  53589. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53590. */
  53591. set snapDistance(value: number);
  53592. get snapDistance(): number;
  53593. /**
  53594. * Ratio for the scale of the gizmo (Default: 1)
  53595. */
  53596. set scaleRatio(value: number);
  53597. get scaleRatio(): number;
  53598. /**
  53599. * Sensitivity factor for dragging (Default: 1)
  53600. */
  53601. set sensitivity(value: number);
  53602. get sensitivity(): number;
  53603. /**
  53604. * Disposes of the gizmo
  53605. */
  53606. dispose(): void;
  53607. }
  53608. }
  53609. declare module BABYLON {
  53610. /**
  53611. * Single axis scale gizmo
  53612. */
  53613. export class AxisScaleGizmo extends Gizmo {
  53614. /**
  53615. * Drag behavior responsible for the gizmos dragging interactions
  53616. */
  53617. dragBehavior: PointerDragBehavior;
  53618. private _pointerObserver;
  53619. /**
  53620. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53621. */
  53622. snapDistance: number;
  53623. /**
  53624. * Event that fires each time the gizmo snaps to a new location.
  53625. * * snapDistance is the the change in distance
  53626. */
  53627. onSnapObservable: Observable<{
  53628. snapDistance: number;
  53629. }>;
  53630. /**
  53631. * If the scaling operation should be done on all axis (default: false)
  53632. */
  53633. uniformScaling: boolean;
  53634. /**
  53635. * Custom sensitivity value for the drag strength
  53636. */
  53637. sensitivity: number;
  53638. private _isEnabled;
  53639. private _parent;
  53640. private _arrow;
  53641. private _coloredMaterial;
  53642. private _hoverMaterial;
  53643. /**
  53644. * Creates an AxisScaleGizmo
  53645. * @param gizmoLayer The utility layer the gizmo will be added to
  53646. * @param dragAxis The axis which the gizmo will be able to scale on
  53647. * @param color The color of the gizmo
  53648. * @param thickness display gizmo axis thickness
  53649. */
  53650. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53651. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53652. /**
  53653. * If the gizmo is enabled
  53654. */
  53655. set isEnabled(value: boolean);
  53656. get isEnabled(): boolean;
  53657. /**
  53658. * Disposes of the gizmo
  53659. */
  53660. dispose(): void;
  53661. /**
  53662. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53663. * @param mesh The mesh to replace the default mesh of the gizmo
  53664. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53665. */
  53666. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53667. }
  53668. }
  53669. declare module BABYLON {
  53670. /**
  53671. * Bounding box gizmo
  53672. */
  53673. export class BoundingBoxGizmo extends Gizmo {
  53674. private _lineBoundingBox;
  53675. private _rotateSpheresParent;
  53676. private _scaleBoxesParent;
  53677. private _boundingDimensions;
  53678. private _renderObserver;
  53679. private _pointerObserver;
  53680. private _scaleDragSpeed;
  53681. private _tmpQuaternion;
  53682. private _tmpVector;
  53683. private _tmpRotationMatrix;
  53684. /**
  53685. * 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)
  53686. */
  53687. ignoreChildren: boolean;
  53688. /**
  53689. * 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)
  53690. */
  53691. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53692. /**
  53693. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53694. */
  53695. rotationSphereSize: number;
  53696. /**
  53697. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53698. */
  53699. scaleBoxSize: number;
  53700. /**
  53701. * 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)
  53702. */
  53703. fixedDragMeshScreenSize: boolean;
  53704. /**
  53705. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53706. */
  53707. fixedDragMeshScreenSizeDistanceFactor: number;
  53708. /**
  53709. * Fired when a rotation sphere or scale box is dragged
  53710. */
  53711. onDragStartObservable: Observable<{}>;
  53712. /**
  53713. * Fired when a scale box is dragged
  53714. */
  53715. onScaleBoxDragObservable: Observable<{}>;
  53716. /**
  53717. * Fired when a scale box drag is ended
  53718. */
  53719. onScaleBoxDragEndObservable: Observable<{}>;
  53720. /**
  53721. * Fired when a rotation sphere is dragged
  53722. */
  53723. onRotationSphereDragObservable: Observable<{}>;
  53724. /**
  53725. * Fired when a rotation sphere drag is ended
  53726. */
  53727. onRotationSphereDragEndObservable: Observable<{}>;
  53728. /**
  53729. * 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)
  53730. */
  53731. scalePivot: Nullable<Vector3>;
  53732. /**
  53733. * Mesh used as a pivot to rotate the attached node
  53734. */
  53735. private _anchorMesh;
  53736. private _existingMeshScale;
  53737. private _dragMesh;
  53738. private pointerDragBehavior;
  53739. private coloredMaterial;
  53740. private hoverColoredMaterial;
  53741. /**
  53742. * Sets the color of the bounding box gizmo
  53743. * @param color the color to set
  53744. */
  53745. setColor(color: Color3): void;
  53746. /**
  53747. * Creates an BoundingBoxGizmo
  53748. * @param gizmoLayer The utility layer the gizmo will be added to
  53749. * @param color The color of the gizmo
  53750. */
  53751. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53752. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53753. private _selectNode;
  53754. /**
  53755. * Updates the bounding box information for the Gizmo
  53756. */
  53757. updateBoundingBox(): void;
  53758. private _updateRotationSpheres;
  53759. private _updateScaleBoxes;
  53760. /**
  53761. * Enables rotation on the specified axis and disables rotation on the others
  53762. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53763. */
  53764. setEnabledRotationAxis(axis: string): void;
  53765. /**
  53766. * Enables/disables scaling
  53767. * @param enable if scaling should be enabled
  53768. * @param homogeneousScaling defines if scaling should only be homogeneous
  53769. */
  53770. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53771. private _updateDummy;
  53772. /**
  53773. * Enables a pointer drag behavior on the bounding box of the gizmo
  53774. */
  53775. enableDragBehavior(): void;
  53776. /**
  53777. * Disposes of the gizmo
  53778. */
  53779. dispose(): void;
  53780. /**
  53781. * 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)
  53782. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53783. * @returns the bounding box mesh with the passed in mesh as a child
  53784. */
  53785. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53786. /**
  53787. * CustomMeshes are not supported by this gizmo
  53788. * @param mesh The mesh to replace the default mesh of the gizmo
  53789. */
  53790. setCustomMesh(mesh: Mesh): void;
  53791. }
  53792. }
  53793. declare module BABYLON {
  53794. /**
  53795. * Single plane rotation gizmo
  53796. */
  53797. export class PlaneRotationGizmo extends Gizmo {
  53798. /**
  53799. * Drag behavior responsible for the gizmos dragging interactions
  53800. */
  53801. dragBehavior: PointerDragBehavior;
  53802. private _pointerObserver;
  53803. /**
  53804. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53805. */
  53806. snapDistance: number;
  53807. /**
  53808. * Event that fires each time the gizmo snaps to a new location.
  53809. * * snapDistance is the the change in distance
  53810. */
  53811. onSnapObservable: Observable<{
  53812. snapDistance: number;
  53813. }>;
  53814. private _isEnabled;
  53815. private _parent;
  53816. /**
  53817. * Creates a PlaneRotationGizmo
  53818. * @param gizmoLayer The utility layer the gizmo will be added to
  53819. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53820. * @param color The color of the gizmo
  53821. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53822. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53823. * @param thickness display gizmo axis thickness
  53824. */
  53825. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53826. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53827. /**
  53828. * If the gizmo is enabled
  53829. */
  53830. set isEnabled(value: boolean);
  53831. get isEnabled(): boolean;
  53832. /**
  53833. * Disposes of the gizmo
  53834. */
  53835. dispose(): void;
  53836. }
  53837. }
  53838. declare module BABYLON {
  53839. /**
  53840. * Gizmo that enables rotating a mesh along 3 axis
  53841. */
  53842. export class RotationGizmo extends Gizmo {
  53843. /**
  53844. * Internal gizmo used for interactions on the x axis
  53845. */
  53846. xGizmo: PlaneRotationGizmo;
  53847. /**
  53848. * Internal gizmo used for interactions on the y axis
  53849. */
  53850. yGizmo: PlaneRotationGizmo;
  53851. /**
  53852. * Internal gizmo used for interactions on the z axis
  53853. */
  53854. zGizmo: PlaneRotationGizmo;
  53855. /** Fires an event when any of it's sub gizmos are dragged */
  53856. onDragStartObservable: Observable<unknown>;
  53857. /** Fires an event when any of it's sub gizmos are released from dragging */
  53858. onDragEndObservable: Observable<unknown>;
  53859. private _meshAttached;
  53860. private _nodeAttached;
  53861. get attachedMesh(): Nullable<AbstractMesh>;
  53862. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53863. get attachedNode(): Nullable<Node>;
  53864. set attachedNode(node: Nullable<Node>);
  53865. /**
  53866. * Creates a RotationGizmo
  53867. * @param gizmoLayer The utility layer the gizmo will be added to
  53868. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53869. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53870. * @param thickness display gizmo axis thickness
  53871. */
  53872. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53873. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53874. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53875. /**
  53876. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53877. */
  53878. set snapDistance(value: number);
  53879. get snapDistance(): number;
  53880. /**
  53881. * Ratio for the scale of the gizmo (Default: 1)
  53882. */
  53883. set scaleRatio(value: number);
  53884. get scaleRatio(): number;
  53885. /**
  53886. * Disposes of the gizmo
  53887. */
  53888. dispose(): void;
  53889. /**
  53890. * CustomMeshes are not supported by this gizmo
  53891. * @param mesh The mesh to replace the default mesh of the gizmo
  53892. */
  53893. setCustomMesh(mesh: Mesh): void;
  53894. }
  53895. }
  53896. declare module BABYLON {
  53897. /**
  53898. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53899. */
  53900. export class GizmoManager implements IDisposable {
  53901. private scene;
  53902. /**
  53903. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53904. */
  53905. gizmos: {
  53906. positionGizmo: Nullable<PositionGizmo>;
  53907. rotationGizmo: Nullable<RotationGizmo>;
  53908. scaleGizmo: Nullable<ScaleGizmo>;
  53909. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53910. };
  53911. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53912. clearGizmoOnEmptyPointerEvent: boolean;
  53913. /** Fires an event when the manager is attached to a mesh */
  53914. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53915. /** Fires an event when the manager is attached to a node */
  53916. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  53917. private _gizmosEnabled;
  53918. private _pointerObserver;
  53919. private _attachedMesh;
  53920. private _attachedNode;
  53921. private _boundingBoxColor;
  53922. private _defaultUtilityLayer;
  53923. private _defaultKeepDepthUtilityLayer;
  53924. private _thickness;
  53925. /**
  53926. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53927. */
  53928. boundingBoxDragBehavior: SixDofDragBehavior;
  53929. /**
  53930. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53931. */
  53932. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53933. /**
  53934. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  53935. */
  53936. attachableNodes: Nullable<Array<Node>>;
  53937. /**
  53938. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  53939. */
  53940. usePointerToAttachGizmos: boolean;
  53941. /**
  53942. * Utility layer that the bounding box gizmo belongs to
  53943. */
  53944. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53945. /**
  53946. * Utility layer that all gizmos besides bounding box belong to
  53947. */
  53948. get utilityLayer(): UtilityLayerRenderer;
  53949. /**
  53950. * Instatiates a gizmo manager
  53951. * @param scene the scene to overlay the gizmos on top of
  53952. * @param thickness display gizmo axis thickness
  53953. */
  53954. constructor(scene: Scene, thickness?: number);
  53955. /**
  53956. * Attaches a set of gizmos to the specified mesh
  53957. * @param mesh The mesh the gizmo's should be attached to
  53958. */
  53959. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53960. /**
  53961. * Attaches a set of gizmos to the specified node
  53962. * @param node The node the gizmo's should be attached to
  53963. */
  53964. attachToNode(node: Nullable<Node>): void;
  53965. /**
  53966. * If the position gizmo is enabled
  53967. */
  53968. set positionGizmoEnabled(value: boolean);
  53969. get positionGizmoEnabled(): boolean;
  53970. /**
  53971. * If the rotation gizmo is enabled
  53972. */
  53973. set rotationGizmoEnabled(value: boolean);
  53974. get rotationGizmoEnabled(): boolean;
  53975. /**
  53976. * If the scale gizmo is enabled
  53977. */
  53978. set scaleGizmoEnabled(value: boolean);
  53979. get scaleGizmoEnabled(): boolean;
  53980. /**
  53981. * If the boundingBox gizmo is enabled
  53982. */
  53983. set boundingBoxGizmoEnabled(value: boolean);
  53984. get boundingBoxGizmoEnabled(): boolean;
  53985. /**
  53986. * Disposes of the gizmo manager
  53987. */
  53988. dispose(): void;
  53989. }
  53990. }
  53991. declare module BABYLON {
  53992. /**
  53993. * A directional light is defined by a direction (what a surprise!).
  53994. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53995. * 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.
  53996. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53997. */
  53998. export class DirectionalLight extends ShadowLight {
  53999. private _shadowFrustumSize;
  54000. /**
  54001. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54002. */
  54003. get shadowFrustumSize(): number;
  54004. /**
  54005. * Specifies a fix frustum size for the shadow generation.
  54006. */
  54007. set shadowFrustumSize(value: number);
  54008. private _shadowOrthoScale;
  54009. /**
  54010. * Gets the shadow projection scale against the optimal computed one.
  54011. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54012. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54013. */
  54014. get shadowOrthoScale(): number;
  54015. /**
  54016. * Sets the shadow projection scale against the optimal computed one.
  54017. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54018. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54019. */
  54020. set shadowOrthoScale(value: number);
  54021. /**
  54022. * Automatically compute the projection matrix to best fit (including all the casters)
  54023. * on each frame.
  54024. */
  54025. autoUpdateExtends: boolean;
  54026. /**
  54027. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54028. * on each frame. autoUpdateExtends must be set to true for this to work
  54029. */
  54030. autoCalcShadowZBounds: boolean;
  54031. private _orthoLeft;
  54032. private _orthoRight;
  54033. private _orthoTop;
  54034. private _orthoBottom;
  54035. /**
  54036. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54037. * The directional light is emitted from everywhere in the given direction.
  54038. * It can cast shadows.
  54039. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54040. * @param name The friendly name of the light
  54041. * @param direction The direction of the light
  54042. * @param scene The scene the light belongs to
  54043. */
  54044. constructor(name: string, direction: Vector3, scene: Scene);
  54045. /**
  54046. * Returns the string "DirectionalLight".
  54047. * @return The class name
  54048. */
  54049. getClassName(): string;
  54050. /**
  54051. * Returns the integer 1.
  54052. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54053. */
  54054. getTypeID(): number;
  54055. /**
  54056. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54057. * Returns the DirectionalLight Shadow projection matrix.
  54058. */
  54059. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54060. /**
  54061. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54062. * Returns the DirectionalLight Shadow projection matrix.
  54063. */
  54064. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54065. /**
  54066. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54067. * Returns the DirectionalLight Shadow projection matrix.
  54068. */
  54069. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54070. protected _buildUniformLayout(): void;
  54071. /**
  54072. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54073. * @param effect The effect to update
  54074. * @param lightIndex The index of the light in the effect to update
  54075. * @returns The directional light
  54076. */
  54077. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54078. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54079. /**
  54080. * Gets the minZ used for shadow according to both the scene and the light.
  54081. *
  54082. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54083. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54084. * @param activeCamera The camera we are returning the min for
  54085. * @returns the depth min z
  54086. */
  54087. getDepthMinZ(activeCamera: Camera): number;
  54088. /**
  54089. * Gets the maxZ used for shadow according to both the scene and the light.
  54090. *
  54091. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54092. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54093. * @param activeCamera The camera we are returning the max for
  54094. * @returns the depth max z
  54095. */
  54096. getDepthMaxZ(activeCamera: Camera): number;
  54097. /**
  54098. * Prepares the list of defines specific to the light type.
  54099. * @param defines the list of defines
  54100. * @param lightIndex defines the index of the light for the effect
  54101. */
  54102. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54103. }
  54104. }
  54105. declare module BABYLON {
  54106. /**
  54107. * Class containing static functions to help procedurally build meshes
  54108. */
  54109. export class HemisphereBuilder {
  54110. /**
  54111. * Creates a hemisphere mesh
  54112. * @param name defines the name of the mesh
  54113. * @param options defines the options used to create the mesh
  54114. * @param scene defines the hosting scene
  54115. * @returns the hemisphere mesh
  54116. */
  54117. static CreateHemisphere(name: string, options: {
  54118. segments?: number;
  54119. diameter?: number;
  54120. sideOrientation?: number;
  54121. }, scene: any): Mesh;
  54122. }
  54123. }
  54124. declare module BABYLON {
  54125. /**
  54126. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54127. * These values define a cone of light starting from the position, emitting toward the direction.
  54128. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54129. * and the exponent defines the speed of the decay of the light with distance (reach).
  54130. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54131. */
  54132. export class SpotLight extends ShadowLight {
  54133. private _angle;
  54134. private _innerAngle;
  54135. private _cosHalfAngle;
  54136. private _lightAngleScale;
  54137. private _lightAngleOffset;
  54138. /**
  54139. * Gets the cone angle of the spot light in Radians.
  54140. */
  54141. get angle(): number;
  54142. /**
  54143. * Sets the cone angle of the spot light in Radians.
  54144. */
  54145. set angle(value: number);
  54146. /**
  54147. * Only used in gltf falloff mode, this defines the angle where
  54148. * the directional falloff will start before cutting at angle which could be seen
  54149. * as outer angle.
  54150. */
  54151. get innerAngle(): number;
  54152. /**
  54153. * Only used in gltf falloff mode, this defines the angle where
  54154. * the directional falloff will start before cutting at angle which could be seen
  54155. * as outer angle.
  54156. */
  54157. set innerAngle(value: number);
  54158. private _shadowAngleScale;
  54159. /**
  54160. * Allows scaling the angle of the light for shadow generation only.
  54161. */
  54162. get shadowAngleScale(): number;
  54163. /**
  54164. * Allows scaling the angle of the light for shadow generation only.
  54165. */
  54166. set shadowAngleScale(value: number);
  54167. /**
  54168. * The light decay speed with the distance from the emission spot.
  54169. */
  54170. exponent: number;
  54171. private _projectionTextureMatrix;
  54172. /**
  54173. * Allows reading the projecton texture
  54174. */
  54175. get projectionTextureMatrix(): Matrix;
  54176. protected _projectionTextureLightNear: number;
  54177. /**
  54178. * Gets the near clip of the Spotlight for texture projection.
  54179. */
  54180. get projectionTextureLightNear(): number;
  54181. /**
  54182. * Sets the near clip of the Spotlight for texture projection.
  54183. */
  54184. set projectionTextureLightNear(value: number);
  54185. protected _projectionTextureLightFar: number;
  54186. /**
  54187. * Gets the far clip of the Spotlight for texture projection.
  54188. */
  54189. get projectionTextureLightFar(): number;
  54190. /**
  54191. * Sets the far clip of the Spotlight for texture projection.
  54192. */
  54193. set projectionTextureLightFar(value: number);
  54194. protected _projectionTextureUpDirection: Vector3;
  54195. /**
  54196. * Gets the Up vector of the Spotlight for texture projection.
  54197. */
  54198. get projectionTextureUpDirection(): Vector3;
  54199. /**
  54200. * Sets the Up vector of the Spotlight for texture projection.
  54201. */
  54202. set projectionTextureUpDirection(value: Vector3);
  54203. private _projectionTexture;
  54204. /**
  54205. * Gets the projection texture of the light.
  54206. */
  54207. get projectionTexture(): Nullable<BaseTexture>;
  54208. /**
  54209. * Sets the projection texture of the light.
  54210. */
  54211. set projectionTexture(value: Nullable<BaseTexture>);
  54212. private _projectionTextureViewLightDirty;
  54213. private _projectionTextureProjectionLightDirty;
  54214. private _projectionTextureDirty;
  54215. private _projectionTextureViewTargetVector;
  54216. private _projectionTextureViewLightMatrix;
  54217. private _projectionTextureProjectionLightMatrix;
  54218. private _projectionTextureScalingMatrix;
  54219. /**
  54220. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54221. * It can cast shadows.
  54222. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54223. * @param name The light friendly name
  54224. * @param position The position of the spot light in the scene
  54225. * @param direction The direction of the light in the scene
  54226. * @param angle The cone angle of the light in Radians
  54227. * @param exponent The light decay speed with the distance from the emission spot
  54228. * @param scene The scene the lights belongs to
  54229. */
  54230. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54231. /**
  54232. * Returns the string "SpotLight".
  54233. * @returns the class name
  54234. */
  54235. getClassName(): string;
  54236. /**
  54237. * Returns the integer 2.
  54238. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54239. */
  54240. getTypeID(): number;
  54241. /**
  54242. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54243. */
  54244. protected _setDirection(value: Vector3): void;
  54245. /**
  54246. * Overrides the position setter to recompute the projection texture view light Matrix.
  54247. */
  54248. protected _setPosition(value: Vector3): void;
  54249. /**
  54250. * 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.
  54251. * Returns the SpotLight.
  54252. */
  54253. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54254. protected _computeProjectionTextureViewLightMatrix(): void;
  54255. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54256. /**
  54257. * Main function for light texture projection matrix computing.
  54258. */
  54259. protected _computeProjectionTextureMatrix(): void;
  54260. protected _buildUniformLayout(): void;
  54261. private _computeAngleValues;
  54262. /**
  54263. * Sets the passed Effect "effect" with the Light textures.
  54264. * @param effect The effect to update
  54265. * @param lightIndex The index of the light in the effect to update
  54266. * @returns The light
  54267. */
  54268. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54269. /**
  54270. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54271. * @param effect The effect to update
  54272. * @param lightIndex The index of the light in the effect to update
  54273. * @returns The spot light
  54274. */
  54275. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54276. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54277. /**
  54278. * Disposes the light and the associated resources.
  54279. */
  54280. dispose(): void;
  54281. /**
  54282. * Prepares the list of defines specific to the light type.
  54283. * @param defines the list of defines
  54284. * @param lightIndex defines the index of the light for the effect
  54285. */
  54286. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54287. }
  54288. }
  54289. declare module BABYLON {
  54290. /**
  54291. * Gizmo that enables viewing a light
  54292. */
  54293. export class LightGizmo extends Gizmo {
  54294. private _lightMesh;
  54295. private _material;
  54296. private _cachedPosition;
  54297. private _cachedForward;
  54298. private _attachedMeshParent;
  54299. private _pointerObserver;
  54300. /**
  54301. * Event that fires each time the gizmo is clicked
  54302. */
  54303. onClickedObservable: Observable<Light>;
  54304. /**
  54305. * Creates a LightGizmo
  54306. * @param gizmoLayer The utility layer the gizmo will be added to
  54307. */
  54308. constructor(gizmoLayer?: UtilityLayerRenderer);
  54309. private _light;
  54310. /**
  54311. * The light that the gizmo is attached to
  54312. */
  54313. set light(light: Nullable<Light>);
  54314. get light(): Nullable<Light>;
  54315. /**
  54316. * Gets the material used to render the light gizmo
  54317. */
  54318. get material(): StandardMaterial;
  54319. /**
  54320. * @hidden
  54321. * Updates the gizmo to match the attached mesh's position/rotation
  54322. */
  54323. protected _update(): void;
  54324. private static _Scale;
  54325. /**
  54326. * Creates the lines for a light mesh
  54327. */
  54328. private static _CreateLightLines;
  54329. /**
  54330. * Disposes of the light gizmo
  54331. */
  54332. dispose(): void;
  54333. private static _CreateHemisphericLightMesh;
  54334. private static _CreatePointLightMesh;
  54335. private static _CreateSpotLightMesh;
  54336. private static _CreateDirectionalLightMesh;
  54337. }
  54338. }
  54339. declare module BABYLON {
  54340. /**
  54341. * Gizmo that enables viewing a camera
  54342. */
  54343. export class CameraGizmo extends Gizmo {
  54344. private _cameraMesh;
  54345. private _cameraLinesMesh;
  54346. private _material;
  54347. private _pointerObserver;
  54348. /**
  54349. * Event that fires each time the gizmo is clicked
  54350. */
  54351. onClickedObservable: Observable<Camera>;
  54352. /**
  54353. * Creates a CameraGizmo
  54354. * @param gizmoLayer The utility layer the gizmo will be added to
  54355. */
  54356. constructor(gizmoLayer?: UtilityLayerRenderer);
  54357. private _camera;
  54358. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54359. get displayFrustum(): boolean;
  54360. set displayFrustum(value: boolean);
  54361. /**
  54362. * The camera that the gizmo is attached to
  54363. */
  54364. set camera(camera: Nullable<Camera>);
  54365. get camera(): Nullable<Camera>;
  54366. /**
  54367. * Gets the material used to render the camera gizmo
  54368. */
  54369. get material(): StandardMaterial;
  54370. /**
  54371. * @hidden
  54372. * Updates the gizmo to match the attached mesh's position/rotation
  54373. */
  54374. protected _update(): void;
  54375. private static _Scale;
  54376. private _invProjection;
  54377. /**
  54378. * Disposes of the camera gizmo
  54379. */
  54380. dispose(): void;
  54381. private static _CreateCameraMesh;
  54382. private static _CreateCameraFrustum;
  54383. }
  54384. }
  54385. declare module BABYLON {
  54386. /** @hidden */
  54387. export var backgroundFragmentDeclaration: {
  54388. name: string;
  54389. shader: string;
  54390. };
  54391. }
  54392. declare module BABYLON {
  54393. /** @hidden */
  54394. export var backgroundUboDeclaration: {
  54395. name: string;
  54396. shader: string;
  54397. };
  54398. }
  54399. declare module BABYLON {
  54400. /** @hidden */
  54401. export var backgroundPixelShader: {
  54402. name: string;
  54403. shader: string;
  54404. };
  54405. }
  54406. declare module BABYLON {
  54407. /** @hidden */
  54408. export var backgroundVertexDeclaration: {
  54409. name: string;
  54410. shader: string;
  54411. };
  54412. }
  54413. declare module BABYLON {
  54414. /** @hidden */
  54415. export var backgroundVertexShader: {
  54416. name: string;
  54417. shader: string;
  54418. };
  54419. }
  54420. declare module BABYLON {
  54421. /**
  54422. * Background material used to create an efficient environement around your scene.
  54423. */
  54424. export class BackgroundMaterial extends PushMaterial {
  54425. /**
  54426. * Standard reflectance value at parallel view angle.
  54427. */
  54428. static StandardReflectance0: number;
  54429. /**
  54430. * Standard reflectance value at grazing angle.
  54431. */
  54432. static StandardReflectance90: number;
  54433. protected _primaryColor: Color3;
  54434. /**
  54435. * Key light Color (multiply against the environement texture)
  54436. */
  54437. primaryColor: Color3;
  54438. protected __perceptualColor: Nullable<Color3>;
  54439. /**
  54440. * Experimental Internal Use Only.
  54441. *
  54442. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54443. * This acts as a helper to set the primary color to a more "human friendly" value.
  54444. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54445. * output color as close as possible from the chosen value.
  54446. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54447. * part of lighting setup.)
  54448. */
  54449. get _perceptualColor(): Nullable<Color3>;
  54450. set _perceptualColor(value: Nullable<Color3>);
  54451. protected _primaryColorShadowLevel: float;
  54452. /**
  54453. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54454. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54455. */
  54456. get primaryColorShadowLevel(): float;
  54457. set primaryColorShadowLevel(value: float);
  54458. protected _primaryColorHighlightLevel: float;
  54459. /**
  54460. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54461. * The primary color is used at the level chosen to define what the white area would look.
  54462. */
  54463. get primaryColorHighlightLevel(): float;
  54464. set primaryColorHighlightLevel(value: float);
  54465. protected _reflectionTexture: Nullable<BaseTexture>;
  54466. /**
  54467. * Reflection Texture used in the material.
  54468. * Should be author in a specific way for the best result (refer to the documentation).
  54469. */
  54470. reflectionTexture: Nullable<BaseTexture>;
  54471. protected _reflectionBlur: float;
  54472. /**
  54473. * Reflection Texture level of blur.
  54474. *
  54475. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54476. * texture twice.
  54477. */
  54478. reflectionBlur: float;
  54479. protected _diffuseTexture: Nullable<BaseTexture>;
  54480. /**
  54481. * Diffuse Texture used in the material.
  54482. * Should be author in a specific way for the best result (refer to the documentation).
  54483. */
  54484. diffuseTexture: Nullable<BaseTexture>;
  54485. protected _shadowLights: Nullable<IShadowLight[]>;
  54486. /**
  54487. * Specify the list of lights casting shadow on the material.
  54488. * All scene shadow lights will be included if null.
  54489. */
  54490. shadowLights: Nullable<IShadowLight[]>;
  54491. protected _shadowLevel: float;
  54492. /**
  54493. * Helps adjusting the shadow to a softer level if required.
  54494. * 0 means black shadows and 1 means no shadows.
  54495. */
  54496. shadowLevel: float;
  54497. protected _sceneCenter: Vector3;
  54498. /**
  54499. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54500. * It is usually zero but might be interesting to modify according to your setup.
  54501. */
  54502. sceneCenter: Vector3;
  54503. protected _opacityFresnel: boolean;
  54504. /**
  54505. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54506. * This helps ensuring a nice transition when the camera goes under the ground.
  54507. */
  54508. opacityFresnel: boolean;
  54509. protected _reflectionFresnel: boolean;
  54510. /**
  54511. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54512. * This helps adding a mirror texture on the ground.
  54513. */
  54514. reflectionFresnel: boolean;
  54515. protected _reflectionFalloffDistance: number;
  54516. /**
  54517. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54518. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54519. */
  54520. reflectionFalloffDistance: number;
  54521. protected _reflectionAmount: number;
  54522. /**
  54523. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54524. */
  54525. reflectionAmount: number;
  54526. protected _reflectionReflectance0: number;
  54527. /**
  54528. * This specifies the weight of the reflection at grazing angle.
  54529. */
  54530. reflectionReflectance0: number;
  54531. protected _reflectionReflectance90: number;
  54532. /**
  54533. * This specifies the weight of the reflection at a perpendicular point of view.
  54534. */
  54535. reflectionReflectance90: number;
  54536. /**
  54537. * Sets the reflection reflectance fresnel values according to the default standard
  54538. * empirically know to work well :-)
  54539. */
  54540. set reflectionStandardFresnelWeight(value: number);
  54541. protected _useRGBColor: boolean;
  54542. /**
  54543. * Helps to directly use the maps channels instead of their level.
  54544. */
  54545. useRGBColor: boolean;
  54546. protected _enableNoise: boolean;
  54547. /**
  54548. * This helps reducing the banding effect that could occur on the background.
  54549. */
  54550. enableNoise: boolean;
  54551. /**
  54552. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54553. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54554. * Recommended to be keep at 1.0 except for special cases.
  54555. */
  54556. get fovMultiplier(): number;
  54557. set fovMultiplier(value: number);
  54558. private _fovMultiplier;
  54559. /**
  54560. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54561. */
  54562. useEquirectangularFOV: boolean;
  54563. private _maxSimultaneousLights;
  54564. /**
  54565. * Number of Simultaneous lights allowed on the material.
  54566. */
  54567. maxSimultaneousLights: int;
  54568. private _shadowOnly;
  54569. /**
  54570. * Make the material only render shadows
  54571. */
  54572. shadowOnly: boolean;
  54573. /**
  54574. * Default configuration related to image processing available in the Background Material.
  54575. */
  54576. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54577. /**
  54578. * Keep track of the image processing observer to allow dispose and replace.
  54579. */
  54580. private _imageProcessingObserver;
  54581. /**
  54582. * Attaches a new image processing configuration to the PBR Material.
  54583. * @param configuration (if null the scene configuration will be use)
  54584. */
  54585. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54586. /**
  54587. * Gets the image processing configuration used either in this material.
  54588. */
  54589. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54590. /**
  54591. * Sets the Default image processing configuration used either in the this material.
  54592. *
  54593. * If sets to null, the scene one is in use.
  54594. */
  54595. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54596. /**
  54597. * Gets wether the color curves effect is enabled.
  54598. */
  54599. get cameraColorCurvesEnabled(): boolean;
  54600. /**
  54601. * Sets wether the color curves effect is enabled.
  54602. */
  54603. set cameraColorCurvesEnabled(value: boolean);
  54604. /**
  54605. * Gets wether the color grading effect is enabled.
  54606. */
  54607. get cameraColorGradingEnabled(): boolean;
  54608. /**
  54609. * Gets wether the color grading effect is enabled.
  54610. */
  54611. set cameraColorGradingEnabled(value: boolean);
  54612. /**
  54613. * Gets wether tonemapping is enabled or not.
  54614. */
  54615. get cameraToneMappingEnabled(): boolean;
  54616. /**
  54617. * Sets wether tonemapping is enabled or not
  54618. */
  54619. set cameraToneMappingEnabled(value: boolean);
  54620. /**
  54621. * The camera exposure used on this material.
  54622. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54623. * This corresponds to a photographic exposure.
  54624. */
  54625. get cameraExposure(): float;
  54626. /**
  54627. * The camera exposure used on this material.
  54628. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54629. * This corresponds to a photographic exposure.
  54630. */
  54631. set cameraExposure(value: float);
  54632. /**
  54633. * Gets The camera contrast used on this material.
  54634. */
  54635. get cameraContrast(): float;
  54636. /**
  54637. * Sets The camera contrast used on this material.
  54638. */
  54639. set cameraContrast(value: float);
  54640. /**
  54641. * Gets the Color Grading 2D Lookup Texture.
  54642. */
  54643. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54644. /**
  54645. * Sets the Color Grading 2D Lookup Texture.
  54646. */
  54647. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54648. /**
  54649. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54650. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54651. * 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;
  54652. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54653. */
  54654. get cameraColorCurves(): Nullable<ColorCurves>;
  54655. /**
  54656. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54657. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54658. * 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;
  54659. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54660. */
  54661. set cameraColorCurves(value: Nullable<ColorCurves>);
  54662. /**
  54663. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54664. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54665. */
  54666. switchToBGR: boolean;
  54667. private _renderTargets;
  54668. private _reflectionControls;
  54669. private _white;
  54670. private _primaryShadowColor;
  54671. private _primaryHighlightColor;
  54672. /**
  54673. * Instantiates a Background Material in the given scene
  54674. * @param name The friendly name of the material
  54675. * @param scene The scene to add the material to
  54676. */
  54677. constructor(name: string, scene: Scene);
  54678. /**
  54679. * Gets a boolean indicating that current material needs to register RTT
  54680. */
  54681. get hasRenderTargetTextures(): boolean;
  54682. /**
  54683. * The entire material has been created in order to prevent overdraw.
  54684. * @returns false
  54685. */
  54686. needAlphaTesting(): boolean;
  54687. /**
  54688. * The entire material has been created in order to prevent overdraw.
  54689. * @returns true if blending is enable
  54690. */
  54691. needAlphaBlending(): boolean;
  54692. /**
  54693. * Checks wether the material is ready to be rendered for a given mesh.
  54694. * @param mesh The mesh to render
  54695. * @param subMesh The submesh to check against
  54696. * @param useInstances Specify wether or not the material is used with instances
  54697. * @returns true if all the dependencies are ready (Textures, Effects...)
  54698. */
  54699. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54700. /**
  54701. * Compute the primary color according to the chosen perceptual color.
  54702. */
  54703. private _computePrimaryColorFromPerceptualColor;
  54704. /**
  54705. * Compute the highlights and shadow colors according to their chosen levels.
  54706. */
  54707. private _computePrimaryColors;
  54708. /**
  54709. * Build the uniform buffer used in the material.
  54710. */
  54711. buildUniformLayout(): void;
  54712. /**
  54713. * Unbind the material.
  54714. */
  54715. unbind(): void;
  54716. /**
  54717. * Bind only the world matrix to the material.
  54718. * @param world The world matrix to bind.
  54719. */
  54720. bindOnlyWorldMatrix(world: Matrix): void;
  54721. /**
  54722. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54723. * @param world The world matrix to bind.
  54724. * @param subMesh The submesh to bind for.
  54725. */
  54726. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54727. /**
  54728. * Checks to see if a texture is used in the material.
  54729. * @param texture - Base texture to use.
  54730. * @returns - Boolean specifying if a texture is used in the material.
  54731. */
  54732. hasTexture(texture: BaseTexture): boolean;
  54733. /**
  54734. * Dispose the material.
  54735. * @param forceDisposeEffect Force disposal of the associated effect.
  54736. * @param forceDisposeTextures Force disposal of the associated textures.
  54737. */
  54738. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54739. /**
  54740. * Clones the material.
  54741. * @param name The cloned name.
  54742. * @returns The cloned material.
  54743. */
  54744. clone(name: string): BackgroundMaterial;
  54745. /**
  54746. * Serializes the current material to its JSON representation.
  54747. * @returns The JSON representation.
  54748. */
  54749. serialize(): any;
  54750. /**
  54751. * Gets the class name of the material
  54752. * @returns "BackgroundMaterial"
  54753. */
  54754. getClassName(): string;
  54755. /**
  54756. * Parse a JSON input to create back a background material.
  54757. * @param source The JSON data to parse
  54758. * @param scene The scene to create the parsed material in
  54759. * @param rootUrl The root url of the assets the material depends upon
  54760. * @returns the instantiated BackgroundMaterial.
  54761. */
  54762. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54763. }
  54764. }
  54765. declare module BABYLON {
  54766. /**
  54767. * Represents the different options available during the creation of
  54768. * a Environment helper.
  54769. *
  54770. * This can control the default ground, skybox and image processing setup of your scene.
  54771. */
  54772. export interface IEnvironmentHelperOptions {
  54773. /**
  54774. * Specifies whether or not to create a ground.
  54775. * True by default.
  54776. */
  54777. createGround: boolean;
  54778. /**
  54779. * Specifies the ground size.
  54780. * 15 by default.
  54781. */
  54782. groundSize: number;
  54783. /**
  54784. * The texture used on the ground for the main color.
  54785. * Comes from the BabylonJS CDN by default.
  54786. *
  54787. * Remarks: Can be either a texture or a url.
  54788. */
  54789. groundTexture: string | BaseTexture;
  54790. /**
  54791. * The color mixed in the ground texture by default.
  54792. * BabylonJS clearColor by default.
  54793. */
  54794. groundColor: Color3;
  54795. /**
  54796. * Specifies the ground opacity.
  54797. * 1 by default.
  54798. */
  54799. groundOpacity: number;
  54800. /**
  54801. * Enables the ground to receive shadows.
  54802. * True by default.
  54803. */
  54804. enableGroundShadow: boolean;
  54805. /**
  54806. * Helps preventing the shadow to be fully black on the ground.
  54807. * 0.5 by default.
  54808. */
  54809. groundShadowLevel: number;
  54810. /**
  54811. * Creates a mirror texture attach to the ground.
  54812. * false by default.
  54813. */
  54814. enableGroundMirror: boolean;
  54815. /**
  54816. * Specifies the ground mirror size ratio.
  54817. * 0.3 by default as the default kernel is 64.
  54818. */
  54819. groundMirrorSizeRatio: number;
  54820. /**
  54821. * Specifies the ground mirror blur kernel size.
  54822. * 64 by default.
  54823. */
  54824. groundMirrorBlurKernel: number;
  54825. /**
  54826. * Specifies the ground mirror visibility amount.
  54827. * 1 by default
  54828. */
  54829. groundMirrorAmount: number;
  54830. /**
  54831. * Specifies the ground mirror reflectance weight.
  54832. * This uses the standard weight of the background material to setup the fresnel effect
  54833. * of the mirror.
  54834. * 1 by default.
  54835. */
  54836. groundMirrorFresnelWeight: number;
  54837. /**
  54838. * Specifies the ground mirror Falloff distance.
  54839. * This can helps reducing the size of the reflection.
  54840. * 0 by Default.
  54841. */
  54842. groundMirrorFallOffDistance: number;
  54843. /**
  54844. * Specifies the ground mirror texture type.
  54845. * Unsigned Int by Default.
  54846. */
  54847. groundMirrorTextureType: number;
  54848. /**
  54849. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54850. * the shown objects.
  54851. */
  54852. groundYBias: number;
  54853. /**
  54854. * Specifies whether or not to create a skybox.
  54855. * True by default.
  54856. */
  54857. createSkybox: boolean;
  54858. /**
  54859. * Specifies the skybox size.
  54860. * 20 by default.
  54861. */
  54862. skyboxSize: number;
  54863. /**
  54864. * The texture used on the skybox for the main color.
  54865. * Comes from the BabylonJS CDN by default.
  54866. *
  54867. * Remarks: Can be either a texture or a url.
  54868. */
  54869. skyboxTexture: string | BaseTexture;
  54870. /**
  54871. * The color mixed in the skybox texture by default.
  54872. * BabylonJS clearColor by default.
  54873. */
  54874. skyboxColor: Color3;
  54875. /**
  54876. * The background rotation around the Y axis of the scene.
  54877. * This helps aligning the key lights of your scene with the background.
  54878. * 0 by default.
  54879. */
  54880. backgroundYRotation: number;
  54881. /**
  54882. * Compute automatically the size of the elements to best fit with the scene.
  54883. */
  54884. sizeAuto: boolean;
  54885. /**
  54886. * Default position of the rootMesh if autoSize is not true.
  54887. */
  54888. rootPosition: Vector3;
  54889. /**
  54890. * Sets up the image processing in the scene.
  54891. * true by default.
  54892. */
  54893. setupImageProcessing: boolean;
  54894. /**
  54895. * The texture used as your environment texture in the scene.
  54896. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54897. *
  54898. * Remarks: Can be either a texture or a url.
  54899. */
  54900. environmentTexture: string | BaseTexture;
  54901. /**
  54902. * The value of the exposure to apply to the scene.
  54903. * 0.6 by default if setupImageProcessing is true.
  54904. */
  54905. cameraExposure: number;
  54906. /**
  54907. * The value of the contrast to apply to the scene.
  54908. * 1.6 by default if setupImageProcessing is true.
  54909. */
  54910. cameraContrast: number;
  54911. /**
  54912. * Specifies whether or not tonemapping should be enabled in the scene.
  54913. * true by default if setupImageProcessing is true.
  54914. */
  54915. toneMappingEnabled: boolean;
  54916. }
  54917. /**
  54918. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54919. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54920. * It also helps with the default setup of your imageProcessing configuration.
  54921. */
  54922. export class EnvironmentHelper {
  54923. /**
  54924. * Default ground texture URL.
  54925. */
  54926. private static _groundTextureCDNUrl;
  54927. /**
  54928. * Default skybox texture URL.
  54929. */
  54930. private static _skyboxTextureCDNUrl;
  54931. /**
  54932. * Default environment texture URL.
  54933. */
  54934. private static _environmentTextureCDNUrl;
  54935. /**
  54936. * Creates the default options for the helper.
  54937. */
  54938. private static _getDefaultOptions;
  54939. private _rootMesh;
  54940. /**
  54941. * Gets the root mesh created by the helper.
  54942. */
  54943. get rootMesh(): Mesh;
  54944. private _skybox;
  54945. /**
  54946. * Gets the skybox created by the helper.
  54947. */
  54948. get skybox(): Nullable<Mesh>;
  54949. private _skyboxTexture;
  54950. /**
  54951. * Gets the skybox texture created by the helper.
  54952. */
  54953. get skyboxTexture(): Nullable<BaseTexture>;
  54954. private _skyboxMaterial;
  54955. /**
  54956. * Gets the skybox material created by the helper.
  54957. */
  54958. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54959. private _ground;
  54960. /**
  54961. * Gets the ground mesh created by the helper.
  54962. */
  54963. get ground(): Nullable<Mesh>;
  54964. private _groundTexture;
  54965. /**
  54966. * Gets the ground texture created by the helper.
  54967. */
  54968. get groundTexture(): Nullable<BaseTexture>;
  54969. private _groundMirror;
  54970. /**
  54971. * Gets the ground mirror created by the helper.
  54972. */
  54973. get groundMirror(): Nullable<MirrorTexture>;
  54974. /**
  54975. * Gets the ground mirror render list to helps pushing the meshes
  54976. * you wish in the ground reflection.
  54977. */
  54978. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54979. private _groundMaterial;
  54980. /**
  54981. * Gets the ground material created by the helper.
  54982. */
  54983. get groundMaterial(): Nullable<BackgroundMaterial>;
  54984. /**
  54985. * Stores the creation options.
  54986. */
  54987. private readonly _scene;
  54988. private _options;
  54989. /**
  54990. * This observable will be notified with any error during the creation of the environment,
  54991. * mainly texture creation errors.
  54992. */
  54993. onErrorObservable: Observable<{
  54994. message?: string;
  54995. exception?: any;
  54996. }>;
  54997. /**
  54998. * constructor
  54999. * @param options Defines the options we want to customize the helper
  55000. * @param scene The scene to add the material to
  55001. */
  55002. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55003. /**
  55004. * Updates the background according to the new options
  55005. * @param options
  55006. */
  55007. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55008. /**
  55009. * Sets the primary color of all the available elements.
  55010. * @param color the main color to affect to the ground and the background
  55011. */
  55012. setMainColor(color: Color3): void;
  55013. /**
  55014. * Setup the image processing according to the specified options.
  55015. */
  55016. private _setupImageProcessing;
  55017. /**
  55018. * Setup the environment texture according to the specified options.
  55019. */
  55020. private _setupEnvironmentTexture;
  55021. /**
  55022. * Setup the background according to the specified options.
  55023. */
  55024. private _setupBackground;
  55025. /**
  55026. * Get the scene sizes according to the setup.
  55027. */
  55028. private _getSceneSize;
  55029. /**
  55030. * Setup the ground according to the specified options.
  55031. */
  55032. private _setupGround;
  55033. /**
  55034. * Setup the ground material according to the specified options.
  55035. */
  55036. private _setupGroundMaterial;
  55037. /**
  55038. * Setup the ground diffuse texture according to the specified options.
  55039. */
  55040. private _setupGroundDiffuseTexture;
  55041. /**
  55042. * Setup the ground mirror texture according to the specified options.
  55043. */
  55044. private _setupGroundMirrorTexture;
  55045. /**
  55046. * Setup the ground to receive the mirror texture.
  55047. */
  55048. private _setupMirrorInGroundMaterial;
  55049. /**
  55050. * Setup the skybox according to the specified options.
  55051. */
  55052. private _setupSkybox;
  55053. /**
  55054. * Setup the skybox material according to the specified options.
  55055. */
  55056. private _setupSkyboxMaterial;
  55057. /**
  55058. * Setup the skybox reflection texture according to the specified options.
  55059. */
  55060. private _setupSkyboxReflectionTexture;
  55061. private _errorHandler;
  55062. /**
  55063. * Dispose all the elements created by the Helper.
  55064. */
  55065. dispose(): void;
  55066. }
  55067. }
  55068. declare module BABYLON {
  55069. /**
  55070. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55071. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55072. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55073. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55074. */
  55075. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55076. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55077. /**
  55078. * Define the source as a Monoscopic panoramic 360/180.
  55079. */
  55080. static readonly MODE_MONOSCOPIC: number;
  55081. /**
  55082. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55083. */
  55084. static readonly MODE_TOPBOTTOM: number;
  55085. /**
  55086. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55087. */
  55088. static readonly MODE_SIDEBYSIDE: number;
  55089. private _halfDome;
  55090. protected _useDirectMapping: boolean;
  55091. /**
  55092. * The texture being displayed on the sphere
  55093. */
  55094. protected _texture: T;
  55095. /**
  55096. * Gets the texture being displayed on the sphere
  55097. */
  55098. get texture(): T;
  55099. /**
  55100. * Sets the texture being displayed on the sphere
  55101. */
  55102. set texture(newTexture: T);
  55103. /**
  55104. * The skybox material
  55105. */
  55106. protected _material: BackgroundMaterial;
  55107. /**
  55108. * The surface used for the dome
  55109. */
  55110. protected _mesh: Mesh;
  55111. /**
  55112. * Gets the mesh used for the dome.
  55113. */
  55114. get mesh(): Mesh;
  55115. /**
  55116. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55117. */
  55118. private _halfDomeMask;
  55119. /**
  55120. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55121. * Also see the options.resolution property.
  55122. */
  55123. get fovMultiplier(): number;
  55124. set fovMultiplier(value: number);
  55125. protected _textureMode: number;
  55126. /**
  55127. * Gets or set the current texture mode for the texture. It can be:
  55128. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55129. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55130. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55131. */
  55132. get textureMode(): number;
  55133. /**
  55134. * Sets the current texture mode for the texture. It can be:
  55135. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55136. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55137. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55138. */
  55139. set textureMode(value: number);
  55140. /**
  55141. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55142. */
  55143. get halfDome(): boolean;
  55144. /**
  55145. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55146. */
  55147. set halfDome(enabled: boolean);
  55148. /**
  55149. * Oberserver used in Stereoscopic VR Mode.
  55150. */
  55151. private _onBeforeCameraRenderObserver;
  55152. /**
  55153. * Observable raised when an error occured while loading the 360 image
  55154. */
  55155. onLoadErrorObservable: Observable<string>;
  55156. /**
  55157. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55158. * @param name Element's name, child elements will append suffixes for their own names.
  55159. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55160. * @param options An object containing optional or exposed sub element properties
  55161. */
  55162. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55163. resolution?: number;
  55164. clickToPlay?: boolean;
  55165. autoPlay?: boolean;
  55166. loop?: boolean;
  55167. size?: number;
  55168. poster?: string;
  55169. faceForward?: boolean;
  55170. useDirectMapping?: boolean;
  55171. halfDomeMode?: boolean;
  55172. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55173. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55174. protected _changeTextureMode(value: number): void;
  55175. /**
  55176. * Releases resources associated with this node.
  55177. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55178. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55179. */
  55180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55181. }
  55182. }
  55183. declare module BABYLON {
  55184. /**
  55185. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55186. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55187. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55188. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55189. */
  55190. export class PhotoDome extends TextureDome<Texture> {
  55191. /**
  55192. * Define the image as a Monoscopic panoramic 360 image.
  55193. */
  55194. static readonly MODE_MONOSCOPIC: number;
  55195. /**
  55196. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55197. */
  55198. static readonly MODE_TOPBOTTOM: number;
  55199. /**
  55200. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55201. */
  55202. static readonly MODE_SIDEBYSIDE: number;
  55203. /**
  55204. * Gets or sets the texture being displayed on the sphere
  55205. */
  55206. get photoTexture(): Texture;
  55207. /**
  55208. * sets the texture being displayed on the sphere
  55209. */
  55210. set photoTexture(value: Texture);
  55211. /**
  55212. * Gets the current video mode for the video. It can be:
  55213. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55214. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55215. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55216. */
  55217. get imageMode(): number;
  55218. /**
  55219. * Sets the current video mode for the video. It can be:
  55220. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55221. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55222. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55223. */
  55224. set imageMode(value: number);
  55225. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55226. }
  55227. }
  55228. declare module BABYLON {
  55229. /**
  55230. * Class used to host RGBD texture specific utilities
  55231. */
  55232. export class RGBDTextureTools {
  55233. /**
  55234. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55235. * @param texture the texture to expand.
  55236. */
  55237. static ExpandRGBDTexture(texture: Texture): void;
  55238. }
  55239. }
  55240. declare module BABYLON {
  55241. /**
  55242. * Class used to host texture specific utilities
  55243. */
  55244. export class BRDFTextureTools {
  55245. /**
  55246. * Prevents texture cache collision
  55247. */
  55248. private static _instanceNumber;
  55249. /**
  55250. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55251. * @param scene defines the hosting scene
  55252. * @returns the environment BRDF texture
  55253. */
  55254. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55255. private static _environmentBRDFBase64Texture;
  55256. }
  55257. }
  55258. declare module BABYLON {
  55259. /**
  55260. * @hidden
  55261. */
  55262. export interface IMaterialClearCoatDefines {
  55263. CLEARCOAT: boolean;
  55264. CLEARCOAT_DEFAULTIOR: boolean;
  55265. CLEARCOAT_TEXTURE: boolean;
  55266. CLEARCOAT_TEXTUREDIRECTUV: number;
  55267. CLEARCOAT_BUMP: boolean;
  55268. CLEARCOAT_BUMPDIRECTUV: number;
  55269. CLEARCOAT_TINT: boolean;
  55270. CLEARCOAT_TINT_TEXTURE: boolean;
  55271. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55272. /** @hidden */
  55273. _areTexturesDirty: boolean;
  55274. }
  55275. /**
  55276. * Define the code related to the clear coat parameters of the pbr material.
  55277. */
  55278. export class PBRClearCoatConfiguration {
  55279. /**
  55280. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55281. * The default fits with a polyurethane material.
  55282. */
  55283. private static readonly _DefaultIndexOfRefraction;
  55284. private _isEnabled;
  55285. /**
  55286. * Defines if the clear coat is enabled in the material.
  55287. */
  55288. isEnabled: boolean;
  55289. /**
  55290. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55291. */
  55292. intensity: number;
  55293. /**
  55294. * Defines the clear coat layer roughness.
  55295. */
  55296. roughness: number;
  55297. private _indexOfRefraction;
  55298. /**
  55299. * Defines the index of refraction of the clear coat.
  55300. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55301. * The default fits with a polyurethane material.
  55302. * Changing the default value is more performance intensive.
  55303. */
  55304. indexOfRefraction: number;
  55305. private _texture;
  55306. /**
  55307. * Stores the clear coat values in a texture.
  55308. */
  55309. texture: Nullable<BaseTexture>;
  55310. private _bumpTexture;
  55311. /**
  55312. * Define the clear coat specific bump texture.
  55313. */
  55314. bumpTexture: Nullable<BaseTexture>;
  55315. private _isTintEnabled;
  55316. /**
  55317. * Defines if the clear coat tint is enabled in the material.
  55318. */
  55319. isTintEnabled: boolean;
  55320. /**
  55321. * Defines the clear coat tint of the material.
  55322. * This is only use if tint is enabled
  55323. */
  55324. tintColor: Color3;
  55325. /**
  55326. * Defines the distance at which the tint color should be found in the
  55327. * clear coat media.
  55328. * This is only use if tint is enabled
  55329. */
  55330. tintColorAtDistance: number;
  55331. /**
  55332. * Defines the clear coat layer thickness.
  55333. * This is only use if tint is enabled
  55334. */
  55335. tintThickness: number;
  55336. private _tintTexture;
  55337. /**
  55338. * Stores the clear tint values in a texture.
  55339. * rgb is tint
  55340. * a is a thickness factor
  55341. */
  55342. tintTexture: Nullable<BaseTexture>;
  55343. /** @hidden */
  55344. private _internalMarkAllSubMeshesAsTexturesDirty;
  55345. /** @hidden */
  55346. _markAllSubMeshesAsTexturesDirty(): void;
  55347. /**
  55348. * Instantiate a new istance of clear coat configuration.
  55349. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55350. */
  55351. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55352. /**
  55353. * Gets wehter the submesh is ready to be used or not.
  55354. * @param defines the list of "defines" to update.
  55355. * @param scene defines the scene the material belongs to.
  55356. * @param engine defines the engine the material belongs to.
  55357. * @param disableBumpMap defines wether the material disables bump or not.
  55358. * @returns - boolean indicating that the submesh is ready or not.
  55359. */
  55360. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55361. /**
  55362. * Checks to see if a texture is used in the material.
  55363. * @param defines the list of "defines" to update.
  55364. * @param scene defines the scene to the material belongs to.
  55365. */
  55366. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55367. /**
  55368. * Binds the material data.
  55369. * @param uniformBuffer defines the Uniform buffer to fill in.
  55370. * @param scene defines the scene the material belongs to.
  55371. * @param engine defines the engine the material belongs to.
  55372. * @param disableBumpMap defines wether the material disables bump or not.
  55373. * @param isFrozen defines wether the material is frozen or not.
  55374. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55375. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55376. */
  55377. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55378. /**
  55379. * Checks to see if a texture is used in the material.
  55380. * @param texture - Base texture to use.
  55381. * @returns - Boolean specifying if a texture is used in the material.
  55382. */
  55383. hasTexture(texture: BaseTexture): boolean;
  55384. /**
  55385. * Returns an array of the actively used textures.
  55386. * @param activeTextures Array of BaseTextures
  55387. */
  55388. getActiveTextures(activeTextures: BaseTexture[]): void;
  55389. /**
  55390. * Returns the animatable textures.
  55391. * @param animatables Array of animatable textures.
  55392. */
  55393. getAnimatables(animatables: IAnimatable[]): void;
  55394. /**
  55395. * Disposes the resources of the material.
  55396. * @param forceDisposeTextures - Forces the disposal of all textures.
  55397. */
  55398. dispose(forceDisposeTextures?: boolean): void;
  55399. /**
  55400. * Get the current class name of the texture useful for serialization or dynamic coding.
  55401. * @returns "PBRClearCoatConfiguration"
  55402. */
  55403. getClassName(): string;
  55404. /**
  55405. * Add fallbacks to the effect fallbacks list.
  55406. * @param defines defines the Base texture to use.
  55407. * @param fallbacks defines the current fallback list.
  55408. * @param currentRank defines the current fallback rank.
  55409. * @returns the new fallback rank.
  55410. */
  55411. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55412. /**
  55413. * Add the required uniforms to the current list.
  55414. * @param uniforms defines the current uniform list.
  55415. */
  55416. static AddUniforms(uniforms: string[]): void;
  55417. /**
  55418. * Add the required samplers to the current list.
  55419. * @param samplers defines the current sampler list.
  55420. */
  55421. static AddSamplers(samplers: string[]): void;
  55422. /**
  55423. * Add the required uniforms to the current buffer.
  55424. * @param uniformBuffer defines the current uniform buffer.
  55425. */
  55426. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55427. /**
  55428. * Makes a duplicate of the current configuration into another one.
  55429. * @param clearCoatConfiguration define the config where to copy the info
  55430. */
  55431. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55432. /**
  55433. * Serializes this clear coat configuration.
  55434. * @returns - An object with the serialized config.
  55435. */
  55436. serialize(): any;
  55437. /**
  55438. * Parses a anisotropy Configuration from a serialized object.
  55439. * @param source - Serialized object.
  55440. * @param scene Defines the scene we are parsing for
  55441. * @param rootUrl Defines the rootUrl to load from
  55442. */
  55443. parse(source: any, scene: Scene, rootUrl: string): void;
  55444. }
  55445. }
  55446. declare module BABYLON {
  55447. /**
  55448. * @hidden
  55449. */
  55450. export interface IMaterialAnisotropicDefines {
  55451. ANISOTROPIC: boolean;
  55452. ANISOTROPIC_TEXTURE: boolean;
  55453. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55454. MAINUV1: boolean;
  55455. _areTexturesDirty: boolean;
  55456. _needUVs: boolean;
  55457. }
  55458. /**
  55459. * Define the code related to the anisotropic parameters of the pbr material.
  55460. */
  55461. export class PBRAnisotropicConfiguration {
  55462. private _isEnabled;
  55463. /**
  55464. * Defines if the anisotropy is enabled in the material.
  55465. */
  55466. isEnabled: boolean;
  55467. /**
  55468. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55469. */
  55470. intensity: number;
  55471. /**
  55472. * Defines if the effect is along the tangents, bitangents or in between.
  55473. * By default, the effect is "strectching" the highlights along the tangents.
  55474. */
  55475. direction: Vector2;
  55476. private _texture;
  55477. /**
  55478. * Stores the anisotropy values in a texture.
  55479. * rg is direction (like normal from -1 to 1)
  55480. * b is a intensity
  55481. */
  55482. texture: Nullable<BaseTexture>;
  55483. /** @hidden */
  55484. private _internalMarkAllSubMeshesAsTexturesDirty;
  55485. /** @hidden */
  55486. _markAllSubMeshesAsTexturesDirty(): void;
  55487. /**
  55488. * Instantiate a new istance of anisotropy configuration.
  55489. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55490. */
  55491. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55492. /**
  55493. * Specifies that the submesh is ready to be used.
  55494. * @param defines the list of "defines" to update.
  55495. * @param scene defines the scene the material belongs to.
  55496. * @returns - boolean indicating that the submesh is ready or not.
  55497. */
  55498. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55499. /**
  55500. * Checks to see if a texture is used in the material.
  55501. * @param defines the list of "defines" to update.
  55502. * @param mesh the mesh we are preparing the defines for.
  55503. * @param scene defines the scene the material belongs to.
  55504. */
  55505. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55506. /**
  55507. * Binds the material data.
  55508. * @param uniformBuffer defines the Uniform buffer to fill in.
  55509. * @param scene defines the scene the material belongs to.
  55510. * @param isFrozen defines wether the material is frozen or not.
  55511. */
  55512. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55513. /**
  55514. * Checks to see if a texture is used in the material.
  55515. * @param texture - Base texture to use.
  55516. * @returns - Boolean specifying if a texture is used in the material.
  55517. */
  55518. hasTexture(texture: BaseTexture): boolean;
  55519. /**
  55520. * Returns an array of the actively used textures.
  55521. * @param activeTextures Array of BaseTextures
  55522. */
  55523. getActiveTextures(activeTextures: BaseTexture[]): void;
  55524. /**
  55525. * Returns the animatable textures.
  55526. * @param animatables Array of animatable textures.
  55527. */
  55528. getAnimatables(animatables: IAnimatable[]): void;
  55529. /**
  55530. * Disposes the resources of the material.
  55531. * @param forceDisposeTextures - Forces the disposal of all textures.
  55532. */
  55533. dispose(forceDisposeTextures?: boolean): void;
  55534. /**
  55535. * Get the current class name of the texture useful for serialization or dynamic coding.
  55536. * @returns "PBRAnisotropicConfiguration"
  55537. */
  55538. getClassName(): string;
  55539. /**
  55540. * Add fallbacks to the effect fallbacks list.
  55541. * @param defines defines the Base texture to use.
  55542. * @param fallbacks defines the current fallback list.
  55543. * @param currentRank defines the current fallback rank.
  55544. * @returns the new fallback rank.
  55545. */
  55546. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55547. /**
  55548. * Add the required uniforms to the current list.
  55549. * @param uniforms defines the current uniform list.
  55550. */
  55551. static AddUniforms(uniforms: string[]): void;
  55552. /**
  55553. * Add the required uniforms to the current buffer.
  55554. * @param uniformBuffer defines the current uniform buffer.
  55555. */
  55556. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55557. /**
  55558. * Add the required samplers to the current list.
  55559. * @param samplers defines the current sampler list.
  55560. */
  55561. static AddSamplers(samplers: string[]): void;
  55562. /**
  55563. * Makes a duplicate of the current configuration into another one.
  55564. * @param anisotropicConfiguration define the config where to copy the info
  55565. */
  55566. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55567. /**
  55568. * Serializes this anisotropy configuration.
  55569. * @returns - An object with the serialized config.
  55570. */
  55571. serialize(): any;
  55572. /**
  55573. * Parses a anisotropy Configuration from a serialized object.
  55574. * @param source - Serialized object.
  55575. * @param scene Defines the scene we are parsing for
  55576. * @param rootUrl Defines the rootUrl to load from
  55577. */
  55578. parse(source: any, scene: Scene, rootUrl: string): void;
  55579. }
  55580. }
  55581. declare module BABYLON {
  55582. /**
  55583. * @hidden
  55584. */
  55585. export interface IMaterialBRDFDefines {
  55586. BRDF_V_HEIGHT_CORRELATED: boolean;
  55587. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55588. SPHERICAL_HARMONICS: boolean;
  55589. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55590. /** @hidden */
  55591. _areMiscDirty: boolean;
  55592. }
  55593. /**
  55594. * Define the code related to the BRDF parameters of the pbr material.
  55595. */
  55596. export class PBRBRDFConfiguration {
  55597. /**
  55598. * Default value used for the energy conservation.
  55599. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55600. */
  55601. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55602. /**
  55603. * Default value used for the Smith Visibility Height Correlated mode.
  55604. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55605. */
  55606. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55607. /**
  55608. * Default value used for the IBL diffuse part.
  55609. * This can help switching back to the polynomials mode globally which is a tiny bit
  55610. * less GPU intensive at the drawback of a lower quality.
  55611. */
  55612. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55613. /**
  55614. * Default value used for activating energy conservation for the specular workflow.
  55615. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55616. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55617. */
  55618. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55619. private _useEnergyConservation;
  55620. /**
  55621. * Defines if the material uses energy conservation.
  55622. */
  55623. useEnergyConservation: boolean;
  55624. private _useSmithVisibilityHeightCorrelated;
  55625. /**
  55626. * LEGACY Mode set to false
  55627. * Defines if the material uses height smith correlated visibility term.
  55628. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55629. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55630. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55631. * Not relying on height correlated will also disable energy conservation.
  55632. */
  55633. useSmithVisibilityHeightCorrelated: boolean;
  55634. private _useSphericalHarmonics;
  55635. /**
  55636. * LEGACY Mode set to false
  55637. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55638. * diffuse part of the IBL.
  55639. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55640. * to the ground truth.
  55641. */
  55642. useSphericalHarmonics: boolean;
  55643. private _useSpecularGlossinessInputEnergyConservation;
  55644. /**
  55645. * Defines if the material uses energy conservation, when the specular workflow is active.
  55646. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55647. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55648. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55649. */
  55650. useSpecularGlossinessInputEnergyConservation: boolean;
  55651. /** @hidden */
  55652. private _internalMarkAllSubMeshesAsMiscDirty;
  55653. /** @hidden */
  55654. _markAllSubMeshesAsMiscDirty(): void;
  55655. /**
  55656. * Instantiate a new istance of clear coat configuration.
  55657. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55658. */
  55659. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55660. /**
  55661. * Checks to see if a texture is used in the material.
  55662. * @param defines the list of "defines" to update.
  55663. */
  55664. prepareDefines(defines: IMaterialBRDFDefines): void;
  55665. /**
  55666. * Get the current class name of the texture useful for serialization or dynamic coding.
  55667. * @returns "PBRClearCoatConfiguration"
  55668. */
  55669. getClassName(): string;
  55670. /**
  55671. * Makes a duplicate of the current configuration into another one.
  55672. * @param brdfConfiguration define the config where to copy the info
  55673. */
  55674. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55675. /**
  55676. * Serializes this BRDF configuration.
  55677. * @returns - An object with the serialized config.
  55678. */
  55679. serialize(): any;
  55680. /**
  55681. * Parses a anisotropy Configuration from a serialized object.
  55682. * @param source - Serialized object.
  55683. * @param scene Defines the scene we are parsing for
  55684. * @param rootUrl Defines the rootUrl to load from
  55685. */
  55686. parse(source: any, scene: Scene, rootUrl: string): void;
  55687. }
  55688. }
  55689. declare module BABYLON {
  55690. /**
  55691. * @hidden
  55692. */
  55693. export interface IMaterialSheenDefines {
  55694. SHEEN: boolean;
  55695. SHEEN_TEXTURE: boolean;
  55696. SHEEN_TEXTUREDIRECTUV: number;
  55697. SHEEN_LINKWITHALBEDO: boolean;
  55698. SHEEN_ROUGHNESS: boolean;
  55699. SHEEN_ALBEDOSCALING: boolean;
  55700. /** @hidden */
  55701. _areTexturesDirty: boolean;
  55702. }
  55703. /**
  55704. * Define the code related to the Sheen parameters of the pbr material.
  55705. */
  55706. export class PBRSheenConfiguration {
  55707. private _isEnabled;
  55708. /**
  55709. * Defines if the material uses sheen.
  55710. */
  55711. isEnabled: boolean;
  55712. private _linkSheenWithAlbedo;
  55713. /**
  55714. * Defines if the sheen is linked to the sheen color.
  55715. */
  55716. linkSheenWithAlbedo: boolean;
  55717. /**
  55718. * Defines the sheen intensity.
  55719. */
  55720. intensity: number;
  55721. /**
  55722. * Defines the sheen color.
  55723. */
  55724. color: Color3;
  55725. private _texture;
  55726. /**
  55727. * Stores the sheen tint values in a texture.
  55728. * rgb is tint
  55729. * a is a intensity or roughness if roughness has been defined
  55730. */
  55731. texture: Nullable<BaseTexture>;
  55732. private _roughness;
  55733. /**
  55734. * Defines the sheen roughness.
  55735. * It is not taken into account if linkSheenWithAlbedo is true.
  55736. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55737. */
  55738. roughness: Nullable<number>;
  55739. private _albedoScaling;
  55740. /**
  55741. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55742. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55743. * making it easier to setup and tweak the effect
  55744. */
  55745. albedoScaling: boolean;
  55746. /** @hidden */
  55747. private _internalMarkAllSubMeshesAsTexturesDirty;
  55748. /** @hidden */
  55749. _markAllSubMeshesAsTexturesDirty(): void;
  55750. /**
  55751. * Instantiate a new istance of clear coat configuration.
  55752. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55753. */
  55754. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55755. /**
  55756. * Specifies that the submesh is ready to be used.
  55757. * @param defines the list of "defines" to update.
  55758. * @param scene defines the scene the material belongs to.
  55759. * @returns - boolean indicating that the submesh is ready or not.
  55760. */
  55761. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55762. /**
  55763. * Checks to see if a texture is used in the material.
  55764. * @param defines the list of "defines" to update.
  55765. * @param scene defines the scene the material belongs to.
  55766. */
  55767. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55768. /**
  55769. * Binds the material data.
  55770. * @param uniformBuffer defines the Uniform buffer to fill in.
  55771. * @param scene defines the scene the material belongs to.
  55772. * @param isFrozen defines wether the material is frozen or not.
  55773. */
  55774. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55775. /**
  55776. * Checks to see if a texture is used in the material.
  55777. * @param texture - Base texture to use.
  55778. * @returns - Boolean specifying if a texture is used in the material.
  55779. */
  55780. hasTexture(texture: BaseTexture): boolean;
  55781. /**
  55782. * Returns an array of the actively used textures.
  55783. * @param activeTextures Array of BaseTextures
  55784. */
  55785. getActiveTextures(activeTextures: BaseTexture[]): void;
  55786. /**
  55787. * Returns the animatable textures.
  55788. * @param animatables Array of animatable textures.
  55789. */
  55790. getAnimatables(animatables: IAnimatable[]): void;
  55791. /**
  55792. * Disposes the resources of the material.
  55793. * @param forceDisposeTextures - Forces the disposal of all textures.
  55794. */
  55795. dispose(forceDisposeTextures?: boolean): void;
  55796. /**
  55797. * Get the current class name of the texture useful for serialization or dynamic coding.
  55798. * @returns "PBRSheenConfiguration"
  55799. */
  55800. getClassName(): string;
  55801. /**
  55802. * Add fallbacks to the effect fallbacks list.
  55803. * @param defines defines the Base texture to use.
  55804. * @param fallbacks defines the current fallback list.
  55805. * @param currentRank defines the current fallback rank.
  55806. * @returns the new fallback rank.
  55807. */
  55808. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55809. /**
  55810. * Add the required uniforms to the current list.
  55811. * @param uniforms defines the current uniform list.
  55812. */
  55813. static AddUniforms(uniforms: string[]): void;
  55814. /**
  55815. * Add the required uniforms to the current buffer.
  55816. * @param uniformBuffer defines the current uniform buffer.
  55817. */
  55818. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55819. /**
  55820. * Add the required samplers to the current list.
  55821. * @param samplers defines the current sampler list.
  55822. */
  55823. static AddSamplers(samplers: string[]): void;
  55824. /**
  55825. * Makes a duplicate of the current configuration into another one.
  55826. * @param sheenConfiguration define the config where to copy the info
  55827. */
  55828. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55829. /**
  55830. * Serializes this BRDF configuration.
  55831. * @returns - An object with the serialized config.
  55832. */
  55833. serialize(): any;
  55834. /**
  55835. * Parses a anisotropy Configuration from a serialized object.
  55836. * @param source - Serialized object.
  55837. * @param scene Defines the scene we are parsing for
  55838. * @param rootUrl Defines the rootUrl to load from
  55839. */
  55840. parse(source: any, scene: Scene, rootUrl: string): void;
  55841. }
  55842. }
  55843. declare module BABYLON {
  55844. /**
  55845. * @hidden
  55846. */
  55847. export interface IMaterialSubSurfaceDefines {
  55848. SUBSURFACE: boolean;
  55849. SS_REFRACTION: boolean;
  55850. SS_TRANSLUCENCY: boolean;
  55851. SS_SCATTERING: boolean;
  55852. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55853. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55854. SS_REFRACTIONMAP_3D: boolean;
  55855. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55856. SS_LODINREFRACTIONALPHA: boolean;
  55857. SS_GAMMAREFRACTION: boolean;
  55858. SS_RGBDREFRACTION: boolean;
  55859. SS_LINEARSPECULARREFRACTION: boolean;
  55860. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55861. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55862. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55863. /** @hidden */
  55864. _areTexturesDirty: boolean;
  55865. }
  55866. /**
  55867. * Define the code related to the sub surface parameters of the pbr material.
  55868. */
  55869. export class PBRSubSurfaceConfiguration {
  55870. private _isRefractionEnabled;
  55871. /**
  55872. * Defines if the refraction is enabled in the material.
  55873. */
  55874. isRefractionEnabled: boolean;
  55875. private _isTranslucencyEnabled;
  55876. /**
  55877. * Defines if the translucency is enabled in the material.
  55878. */
  55879. isTranslucencyEnabled: boolean;
  55880. private _isScatteringEnabled;
  55881. /**
  55882. * Defines if the sub surface scattering is enabled in the material.
  55883. */
  55884. isScatteringEnabled: boolean;
  55885. private _scatteringDiffusionProfileIndex;
  55886. /**
  55887. * Diffusion profile for subsurface scattering.
  55888. * Useful for better scattering in the skins or foliages.
  55889. */
  55890. get scatteringDiffusionProfile(): Nullable<Color3>;
  55891. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55892. /**
  55893. * Defines the refraction intensity of the material.
  55894. * The refraction when enabled replaces the Diffuse part of the material.
  55895. * The intensity helps transitionning between diffuse and refraction.
  55896. */
  55897. refractionIntensity: number;
  55898. /**
  55899. * Defines the translucency intensity of the material.
  55900. * When translucency has been enabled, this defines how much of the "translucency"
  55901. * is addded to the diffuse part of the material.
  55902. */
  55903. translucencyIntensity: number;
  55904. /**
  55905. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55906. */
  55907. useAlbedoToTintRefraction: boolean;
  55908. private _thicknessTexture;
  55909. /**
  55910. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55911. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55912. * 0 would mean minimumThickness
  55913. * 1 would mean maximumThickness
  55914. * The other channels might be use as a mask to vary the different effects intensity.
  55915. */
  55916. thicknessTexture: Nullable<BaseTexture>;
  55917. private _refractionTexture;
  55918. /**
  55919. * Defines the texture to use for refraction.
  55920. */
  55921. refractionTexture: Nullable<BaseTexture>;
  55922. private _indexOfRefraction;
  55923. /**
  55924. * Index of refraction of the material base layer.
  55925. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55926. *
  55927. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55928. *
  55929. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55930. */
  55931. indexOfRefraction: number;
  55932. private _volumeIndexOfRefraction;
  55933. /**
  55934. * Index of refraction of the material's volume.
  55935. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55936. *
  55937. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55938. * the volume will use the same IOR as the surface.
  55939. */
  55940. get volumeIndexOfRefraction(): number;
  55941. set volumeIndexOfRefraction(value: number);
  55942. private _invertRefractionY;
  55943. /**
  55944. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55945. */
  55946. invertRefractionY: boolean;
  55947. private _linkRefractionWithTransparency;
  55948. /**
  55949. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55950. * Materials half opaque for instance using refraction could benefit from this control.
  55951. */
  55952. linkRefractionWithTransparency: boolean;
  55953. /**
  55954. * Defines the minimum thickness stored in the thickness map.
  55955. * If no thickness map is defined, this value will be used to simulate thickness.
  55956. */
  55957. minimumThickness: number;
  55958. /**
  55959. * Defines the maximum thickness stored in the thickness map.
  55960. */
  55961. maximumThickness: number;
  55962. /**
  55963. * Defines the volume tint of the material.
  55964. * This is used for both translucency and scattering.
  55965. */
  55966. tintColor: Color3;
  55967. /**
  55968. * Defines the distance at which the tint color should be found in the media.
  55969. * This is used for refraction only.
  55970. */
  55971. tintColorAtDistance: number;
  55972. /**
  55973. * Defines how far each channel transmit through the media.
  55974. * It is defined as a color to simplify it selection.
  55975. */
  55976. diffusionDistance: Color3;
  55977. private _useMaskFromThicknessTexture;
  55978. /**
  55979. * Stores the intensity of the different subsurface effects in the thickness texture.
  55980. * * the green channel is the translucency intensity.
  55981. * * the blue channel is the scattering intensity.
  55982. * * the alpha channel is the refraction intensity.
  55983. */
  55984. useMaskFromThicknessTexture: boolean;
  55985. private _scene;
  55986. /** @hidden */
  55987. private _internalMarkAllSubMeshesAsTexturesDirty;
  55988. private _internalMarkScenePrePassDirty;
  55989. /** @hidden */
  55990. _markAllSubMeshesAsTexturesDirty(): void;
  55991. /** @hidden */
  55992. _markScenePrePassDirty(): void;
  55993. /**
  55994. * Instantiate a new istance of sub surface configuration.
  55995. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55996. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55997. * @param scene The scene
  55998. */
  55999. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  56000. /**
  56001. * Gets wehter the submesh is ready to be used or not.
  56002. * @param defines the list of "defines" to update.
  56003. * @param scene defines the scene the material belongs to.
  56004. * @returns - boolean indicating that the submesh is ready or not.
  56005. */
  56006. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56007. /**
  56008. * Checks to see if a texture is used in the material.
  56009. * @param defines the list of "defines" to update.
  56010. * @param scene defines the scene to the material belongs to.
  56011. */
  56012. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56013. /**
  56014. * Binds the material data.
  56015. * @param uniformBuffer defines the Uniform buffer to fill in.
  56016. * @param scene defines the scene the material belongs to.
  56017. * @param engine defines the engine the material belongs to.
  56018. * @param isFrozen defines whether the material is frozen or not.
  56019. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56020. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56021. */
  56022. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56023. /**
  56024. * Unbinds the material from the mesh.
  56025. * @param activeEffect defines the effect that should be unbound from.
  56026. * @returns true if unbound, otherwise false
  56027. */
  56028. unbind(activeEffect: Effect): boolean;
  56029. /**
  56030. * Returns the texture used for refraction or null if none is used.
  56031. * @param scene defines the scene the material belongs to.
  56032. * @returns - Refraction texture if present. If no refraction texture and refraction
  56033. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56034. */
  56035. private _getRefractionTexture;
  56036. /**
  56037. * Returns true if alpha blending should be disabled.
  56038. */
  56039. get disableAlphaBlending(): boolean;
  56040. /**
  56041. * Fills the list of render target textures.
  56042. * @param renderTargets the list of render targets to update
  56043. */
  56044. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56045. /**
  56046. * Checks to see if a texture is used in the material.
  56047. * @param texture - Base texture to use.
  56048. * @returns - Boolean specifying if a texture is used in the material.
  56049. */
  56050. hasTexture(texture: BaseTexture): boolean;
  56051. /**
  56052. * Gets a boolean indicating that current material needs to register RTT
  56053. * @returns true if this uses a render target otherwise false.
  56054. */
  56055. hasRenderTargetTextures(): boolean;
  56056. /**
  56057. * Returns an array of the actively used textures.
  56058. * @param activeTextures Array of BaseTextures
  56059. */
  56060. getActiveTextures(activeTextures: BaseTexture[]): void;
  56061. /**
  56062. * Returns the animatable textures.
  56063. * @param animatables Array of animatable textures.
  56064. */
  56065. getAnimatables(animatables: IAnimatable[]): void;
  56066. /**
  56067. * Disposes the resources of the material.
  56068. * @param forceDisposeTextures - Forces the disposal of all textures.
  56069. */
  56070. dispose(forceDisposeTextures?: boolean): void;
  56071. /**
  56072. * Get the current class name of the texture useful for serialization or dynamic coding.
  56073. * @returns "PBRSubSurfaceConfiguration"
  56074. */
  56075. getClassName(): string;
  56076. /**
  56077. * Add fallbacks to the effect fallbacks list.
  56078. * @param defines defines the Base texture to use.
  56079. * @param fallbacks defines the current fallback list.
  56080. * @param currentRank defines the current fallback rank.
  56081. * @returns the new fallback rank.
  56082. */
  56083. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56084. /**
  56085. * Add the required uniforms to the current list.
  56086. * @param uniforms defines the current uniform list.
  56087. */
  56088. static AddUniforms(uniforms: string[]): void;
  56089. /**
  56090. * Add the required samplers to the current list.
  56091. * @param samplers defines the current sampler list.
  56092. */
  56093. static AddSamplers(samplers: string[]): void;
  56094. /**
  56095. * Add the required uniforms to the current buffer.
  56096. * @param uniformBuffer defines the current uniform buffer.
  56097. */
  56098. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56099. /**
  56100. * Makes a duplicate of the current configuration into another one.
  56101. * @param configuration define the config where to copy the info
  56102. */
  56103. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56104. /**
  56105. * Serializes this Sub Surface configuration.
  56106. * @returns - An object with the serialized config.
  56107. */
  56108. serialize(): any;
  56109. /**
  56110. * Parses a anisotropy Configuration from a serialized object.
  56111. * @param source - Serialized object.
  56112. * @param scene Defines the scene we are parsing for
  56113. * @param rootUrl Defines the rootUrl to load from
  56114. */
  56115. parse(source: any, scene: Scene, rootUrl: string): void;
  56116. }
  56117. }
  56118. declare module BABYLON {
  56119. /** @hidden */
  56120. export var pbrFragmentDeclaration: {
  56121. name: string;
  56122. shader: string;
  56123. };
  56124. }
  56125. declare module BABYLON {
  56126. /** @hidden */
  56127. export var pbrUboDeclaration: {
  56128. name: string;
  56129. shader: string;
  56130. };
  56131. }
  56132. declare module BABYLON {
  56133. /** @hidden */
  56134. export var pbrFragmentExtraDeclaration: {
  56135. name: string;
  56136. shader: string;
  56137. };
  56138. }
  56139. declare module BABYLON {
  56140. /** @hidden */
  56141. export var pbrFragmentSamplersDeclaration: {
  56142. name: string;
  56143. shader: string;
  56144. };
  56145. }
  56146. declare module BABYLON {
  56147. /** @hidden */
  56148. export var importanceSampling: {
  56149. name: string;
  56150. shader: string;
  56151. };
  56152. }
  56153. declare module BABYLON {
  56154. /** @hidden */
  56155. export var pbrHelperFunctions: {
  56156. name: string;
  56157. shader: string;
  56158. };
  56159. }
  56160. declare module BABYLON {
  56161. /** @hidden */
  56162. export var harmonicsFunctions: {
  56163. name: string;
  56164. shader: string;
  56165. };
  56166. }
  56167. declare module BABYLON {
  56168. /** @hidden */
  56169. export var pbrDirectLightingSetupFunctions: {
  56170. name: string;
  56171. shader: string;
  56172. };
  56173. }
  56174. declare module BABYLON {
  56175. /** @hidden */
  56176. export var pbrDirectLightingFalloffFunctions: {
  56177. name: string;
  56178. shader: string;
  56179. };
  56180. }
  56181. declare module BABYLON {
  56182. /** @hidden */
  56183. export var pbrBRDFFunctions: {
  56184. name: string;
  56185. shader: string;
  56186. };
  56187. }
  56188. declare module BABYLON {
  56189. /** @hidden */
  56190. export var hdrFilteringFunctions: {
  56191. name: string;
  56192. shader: string;
  56193. };
  56194. }
  56195. declare module BABYLON {
  56196. /** @hidden */
  56197. export var pbrDirectLightingFunctions: {
  56198. name: string;
  56199. shader: string;
  56200. };
  56201. }
  56202. declare module BABYLON {
  56203. /** @hidden */
  56204. export var pbrIBLFunctions: {
  56205. name: string;
  56206. shader: string;
  56207. };
  56208. }
  56209. declare module BABYLON {
  56210. /** @hidden */
  56211. export var pbrBlockAlbedoOpacity: {
  56212. name: string;
  56213. shader: string;
  56214. };
  56215. }
  56216. declare module BABYLON {
  56217. /** @hidden */
  56218. export var pbrBlockReflectivity: {
  56219. name: string;
  56220. shader: string;
  56221. };
  56222. }
  56223. declare module BABYLON {
  56224. /** @hidden */
  56225. export var pbrBlockAmbientOcclusion: {
  56226. name: string;
  56227. shader: string;
  56228. };
  56229. }
  56230. declare module BABYLON {
  56231. /** @hidden */
  56232. export var pbrBlockAlphaFresnel: {
  56233. name: string;
  56234. shader: string;
  56235. };
  56236. }
  56237. declare module BABYLON {
  56238. /** @hidden */
  56239. export var pbrBlockAnisotropic: {
  56240. name: string;
  56241. shader: string;
  56242. };
  56243. }
  56244. declare module BABYLON {
  56245. /** @hidden */
  56246. export var pbrBlockReflection: {
  56247. name: string;
  56248. shader: string;
  56249. };
  56250. }
  56251. declare module BABYLON {
  56252. /** @hidden */
  56253. export var pbrBlockSheen: {
  56254. name: string;
  56255. shader: string;
  56256. };
  56257. }
  56258. declare module BABYLON {
  56259. /** @hidden */
  56260. export var pbrBlockClearcoat: {
  56261. name: string;
  56262. shader: string;
  56263. };
  56264. }
  56265. declare module BABYLON {
  56266. /** @hidden */
  56267. export var pbrBlockSubSurface: {
  56268. name: string;
  56269. shader: string;
  56270. };
  56271. }
  56272. declare module BABYLON {
  56273. /** @hidden */
  56274. export var pbrBlockNormalGeometric: {
  56275. name: string;
  56276. shader: string;
  56277. };
  56278. }
  56279. declare module BABYLON {
  56280. /** @hidden */
  56281. export var pbrBlockNormalFinal: {
  56282. name: string;
  56283. shader: string;
  56284. };
  56285. }
  56286. declare module BABYLON {
  56287. /** @hidden */
  56288. export var pbrBlockLightmapInit: {
  56289. name: string;
  56290. shader: string;
  56291. };
  56292. }
  56293. declare module BABYLON {
  56294. /** @hidden */
  56295. export var pbrBlockGeometryInfo: {
  56296. name: string;
  56297. shader: string;
  56298. };
  56299. }
  56300. declare module BABYLON {
  56301. /** @hidden */
  56302. export var pbrBlockReflectance0: {
  56303. name: string;
  56304. shader: string;
  56305. };
  56306. }
  56307. declare module BABYLON {
  56308. /** @hidden */
  56309. export var pbrBlockReflectance: {
  56310. name: string;
  56311. shader: string;
  56312. };
  56313. }
  56314. declare module BABYLON {
  56315. /** @hidden */
  56316. export var pbrBlockDirectLighting: {
  56317. name: string;
  56318. shader: string;
  56319. };
  56320. }
  56321. declare module BABYLON {
  56322. /** @hidden */
  56323. export var pbrBlockFinalLitComponents: {
  56324. name: string;
  56325. shader: string;
  56326. };
  56327. }
  56328. declare module BABYLON {
  56329. /** @hidden */
  56330. export var pbrBlockFinalUnlitComponents: {
  56331. name: string;
  56332. shader: string;
  56333. };
  56334. }
  56335. declare module BABYLON {
  56336. /** @hidden */
  56337. export var pbrBlockFinalColorComposition: {
  56338. name: string;
  56339. shader: string;
  56340. };
  56341. }
  56342. declare module BABYLON {
  56343. /** @hidden */
  56344. export var pbrBlockImageProcessing: {
  56345. name: string;
  56346. shader: string;
  56347. };
  56348. }
  56349. declare module BABYLON {
  56350. /** @hidden */
  56351. export var pbrDebug: {
  56352. name: string;
  56353. shader: string;
  56354. };
  56355. }
  56356. declare module BABYLON {
  56357. /** @hidden */
  56358. export var pbrPixelShader: {
  56359. name: string;
  56360. shader: string;
  56361. };
  56362. }
  56363. declare module BABYLON {
  56364. /** @hidden */
  56365. export var pbrVertexDeclaration: {
  56366. name: string;
  56367. shader: string;
  56368. };
  56369. }
  56370. declare module BABYLON {
  56371. /** @hidden */
  56372. export var pbrVertexShader: {
  56373. name: string;
  56374. shader: string;
  56375. };
  56376. }
  56377. declare module BABYLON {
  56378. /**
  56379. * Manages the defines for the PBR Material.
  56380. * @hidden
  56381. */
  56382. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56383. PBR: boolean;
  56384. NUM_SAMPLES: string;
  56385. REALTIME_FILTERING: boolean;
  56386. MAINUV1: boolean;
  56387. MAINUV2: boolean;
  56388. UV1: boolean;
  56389. UV2: boolean;
  56390. ALBEDO: boolean;
  56391. GAMMAALBEDO: boolean;
  56392. ALBEDODIRECTUV: number;
  56393. VERTEXCOLOR: boolean;
  56394. DETAIL: boolean;
  56395. DETAILDIRECTUV: number;
  56396. DETAIL_NORMALBLENDMETHOD: number;
  56397. AMBIENT: boolean;
  56398. AMBIENTDIRECTUV: number;
  56399. AMBIENTINGRAYSCALE: boolean;
  56400. OPACITY: boolean;
  56401. VERTEXALPHA: boolean;
  56402. OPACITYDIRECTUV: number;
  56403. OPACITYRGB: boolean;
  56404. ALPHATEST: boolean;
  56405. DEPTHPREPASS: boolean;
  56406. ALPHABLEND: boolean;
  56407. ALPHAFROMALBEDO: boolean;
  56408. ALPHATESTVALUE: string;
  56409. SPECULAROVERALPHA: boolean;
  56410. RADIANCEOVERALPHA: boolean;
  56411. ALPHAFRESNEL: boolean;
  56412. LINEARALPHAFRESNEL: boolean;
  56413. PREMULTIPLYALPHA: boolean;
  56414. EMISSIVE: boolean;
  56415. EMISSIVEDIRECTUV: number;
  56416. REFLECTIVITY: boolean;
  56417. REFLECTIVITYDIRECTUV: number;
  56418. SPECULARTERM: boolean;
  56419. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56420. MICROSURFACEAUTOMATIC: boolean;
  56421. LODBASEDMICROSFURACE: boolean;
  56422. MICROSURFACEMAP: boolean;
  56423. MICROSURFACEMAPDIRECTUV: number;
  56424. METALLICWORKFLOW: boolean;
  56425. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56426. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56427. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56428. AOSTOREINMETALMAPRED: boolean;
  56429. METALLIC_REFLECTANCE: boolean;
  56430. METALLIC_REFLECTANCEDIRECTUV: number;
  56431. ENVIRONMENTBRDF: boolean;
  56432. ENVIRONMENTBRDF_RGBD: boolean;
  56433. NORMAL: boolean;
  56434. TANGENT: boolean;
  56435. BUMP: boolean;
  56436. BUMPDIRECTUV: number;
  56437. OBJECTSPACE_NORMALMAP: boolean;
  56438. PARALLAX: boolean;
  56439. PARALLAXOCCLUSION: boolean;
  56440. NORMALXYSCALE: boolean;
  56441. LIGHTMAP: boolean;
  56442. LIGHTMAPDIRECTUV: number;
  56443. USELIGHTMAPASSHADOWMAP: boolean;
  56444. GAMMALIGHTMAP: boolean;
  56445. RGBDLIGHTMAP: boolean;
  56446. REFLECTION: boolean;
  56447. REFLECTIONMAP_3D: boolean;
  56448. REFLECTIONMAP_SPHERICAL: boolean;
  56449. REFLECTIONMAP_PLANAR: boolean;
  56450. REFLECTIONMAP_CUBIC: boolean;
  56451. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56452. REFLECTIONMAP_PROJECTION: boolean;
  56453. REFLECTIONMAP_SKYBOX: boolean;
  56454. REFLECTIONMAP_EXPLICIT: boolean;
  56455. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56456. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56457. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56458. INVERTCUBICMAP: boolean;
  56459. USESPHERICALFROMREFLECTIONMAP: boolean;
  56460. USEIRRADIANCEMAP: boolean;
  56461. SPHERICAL_HARMONICS: boolean;
  56462. USESPHERICALINVERTEX: boolean;
  56463. REFLECTIONMAP_OPPOSITEZ: boolean;
  56464. LODINREFLECTIONALPHA: boolean;
  56465. GAMMAREFLECTION: boolean;
  56466. RGBDREFLECTION: boolean;
  56467. LINEARSPECULARREFLECTION: boolean;
  56468. RADIANCEOCCLUSION: boolean;
  56469. HORIZONOCCLUSION: boolean;
  56470. INSTANCES: boolean;
  56471. THIN_INSTANCES: boolean;
  56472. PREPASS: boolean;
  56473. SCENE_MRT_COUNT: number;
  56474. NUM_BONE_INFLUENCERS: number;
  56475. BonesPerMesh: number;
  56476. BONETEXTURE: boolean;
  56477. NONUNIFORMSCALING: boolean;
  56478. MORPHTARGETS: boolean;
  56479. MORPHTARGETS_NORMAL: boolean;
  56480. MORPHTARGETS_TANGENT: boolean;
  56481. MORPHTARGETS_UV: boolean;
  56482. NUM_MORPH_INFLUENCERS: number;
  56483. IMAGEPROCESSING: boolean;
  56484. VIGNETTE: boolean;
  56485. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56486. VIGNETTEBLENDMODEOPAQUE: boolean;
  56487. TONEMAPPING: boolean;
  56488. TONEMAPPING_ACES: boolean;
  56489. CONTRAST: boolean;
  56490. COLORCURVES: boolean;
  56491. COLORGRADING: boolean;
  56492. COLORGRADING3D: boolean;
  56493. SAMPLER3DGREENDEPTH: boolean;
  56494. SAMPLER3DBGRMAP: boolean;
  56495. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56496. EXPOSURE: boolean;
  56497. MULTIVIEW: boolean;
  56498. USEPHYSICALLIGHTFALLOFF: boolean;
  56499. USEGLTFLIGHTFALLOFF: boolean;
  56500. TWOSIDEDLIGHTING: boolean;
  56501. SHADOWFLOAT: boolean;
  56502. CLIPPLANE: boolean;
  56503. CLIPPLANE2: boolean;
  56504. CLIPPLANE3: boolean;
  56505. CLIPPLANE4: boolean;
  56506. CLIPPLANE5: boolean;
  56507. CLIPPLANE6: boolean;
  56508. POINTSIZE: boolean;
  56509. FOG: boolean;
  56510. LOGARITHMICDEPTH: boolean;
  56511. FORCENORMALFORWARD: boolean;
  56512. SPECULARAA: boolean;
  56513. CLEARCOAT: boolean;
  56514. CLEARCOAT_DEFAULTIOR: boolean;
  56515. CLEARCOAT_TEXTURE: boolean;
  56516. CLEARCOAT_TEXTUREDIRECTUV: number;
  56517. CLEARCOAT_BUMP: boolean;
  56518. CLEARCOAT_BUMPDIRECTUV: number;
  56519. CLEARCOAT_TINT: boolean;
  56520. CLEARCOAT_TINT_TEXTURE: boolean;
  56521. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56522. ANISOTROPIC: boolean;
  56523. ANISOTROPIC_TEXTURE: boolean;
  56524. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56525. BRDF_V_HEIGHT_CORRELATED: boolean;
  56526. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56527. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56528. SHEEN: boolean;
  56529. SHEEN_TEXTURE: boolean;
  56530. SHEEN_TEXTUREDIRECTUV: number;
  56531. SHEEN_LINKWITHALBEDO: boolean;
  56532. SHEEN_ROUGHNESS: boolean;
  56533. SHEEN_ALBEDOSCALING: boolean;
  56534. SUBSURFACE: boolean;
  56535. SS_REFRACTION: boolean;
  56536. SS_TRANSLUCENCY: boolean;
  56537. SS_SCATTERING: boolean;
  56538. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56539. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56540. SS_REFRACTIONMAP_3D: boolean;
  56541. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56542. SS_LODINREFRACTIONALPHA: boolean;
  56543. SS_GAMMAREFRACTION: boolean;
  56544. SS_RGBDREFRACTION: boolean;
  56545. SS_LINEARSPECULARREFRACTION: boolean;
  56546. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56547. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56548. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56549. UNLIT: boolean;
  56550. DEBUGMODE: number;
  56551. /**
  56552. * Initializes the PBR Material defines.
  56553. */
  56554. constructor();
  56555. /**
  56556. * Resets the PBR Material defines.
  56557. */
  56558. reset(): void;
  56559. }
  56560. /**
  56561. * The Physically based material base class of BJS.
  56562. *
  56563. * This offers the main features of a standard PBR material.
  56564. * For more information, please refer to the documentation :
  56565. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56566. */
  56567. export abstract class PBRBaseMaterial extends PushMaterial {
  56568. /**
  56569. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56570. */
  56571. static readonly PBRMATERIAL_OPAQUE: number;
  56572. /**
  56573. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56574. */
  56575. static readonly PBRMATERIAL_ALPHATEST: number;
  56576. /**
  56577. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56578. */
  56579. static readonly PBRMATERIAL_ALPHABLEND: number;
  56580. /**
  56581. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56582. * They are also discarded below the alpha cutoff threshold to improve performances.
  56583. */
  56584. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56585. /**
  56586. * Defines the default value of how much AO map is occluding the analytical lights
  56587. * (point spot...).
  56588. */
  56589. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56590. /**
  56591. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56592. */
  56593. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56594. /**
  56595. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56596. * to enhance interoperability with other engines.
  56597. */
  56598. static readonly LIGHTFALLOFF_GLTF: number;
  56599. /**
  56600. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56601. * to enhance interoperability with other materials.
  56602. */
  56603. static readonly LIGHTFALLOFF_STANDARD: number;
  56604. /**
  56605. * Intensity of the direct lights e.g. the four lights available in your scene.
  56606. * This impacts both the direct diffuse and specular highlights.
  56607. */
  56608. protected _directIntensity: number;
  56609. /**
  56610. * Intensity of the emissive part of the material.
  56611. * This helps controlling the emissive effect without modifying the emissive color.
  56612. */
  56613. protected _emissiveIntensity: number;
  56614. /**
  56615. * Intensity of the environment e.g. how much the environment will light the object
  56616. * either through harmonics for rough material or through the refelction for shiny ones.
  56617. */
  56618. protected _environmentIntensity: number;
  56619. /**
  56620. * This is a special control allowing the reduction of the specular highlights coming from the
  56621. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56622. */
  56623. protected _specularIntensity: number;
  56624. /**
  56625. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56626. */
  56627. private _lightingInfos;
  56628. /**
  56629. * Debug Control allowing disabling the bump map on this material.
  56630. */
  56631. protected _disableBumpMap: boolean;
  56632. /**
  56633. * AKA Diffuse Texture in standard nomenclature.
  56634. */
  56635. protected _albedoTexture: Nullable<BaseTexture>;
  56636. /**
  56637. * AKA Occlusion Texture in other nomenclature.
  56638. */
  56639. protected _ambientTexture: Nullable<BaseTexture>;
  56640. /**
  56641. * AKA Occlusion Texture Intensity in other nomenclature.
  56642. */
  56643. protected _ambientTextureStrength: number;
  56644. /**
  56645. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56646. * 1 means it completely occludes it
  56647. * 0 mean it has no impact
  56648. */
  56649. protected _ambientTextureImpactOnAnalyticalLights: number;
  56650. /**
  56651. * Stores the alpha values in a texture.
  56652. */
  56653. protected _opacityTexture: Nullable<BaseTexture>;
  56654. /**
  56655. * Stores the reflection values in a texture.
  56656. */
  56657. protected _reflectionTexture: Nullable<BaseTexture>;
  56658. /**
  56659. * Stores the emissive values in a texture.
  56660. */
  56661. protected _emissiveTexture: Nullable<BaseTexture>;
  56662. /**
  56663. * AKA Specular texture in other nomenclature.
  56664. */
  56665. protected _reflectivityTexture: Nullable<BaseTexture>;
  56666. /**
  56667. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56668. */
  56669. protected _metallicTexture: Nullable<BaseTexture>;
  56670. /**
  56671. * Specifies the metallic scalar of the metallic/roughness workflow.
  56672. * Can also be used to scale the metalness values of the metallic texture.
  56673. */
  56674. protected _metallic: Nullable<number>;
  56675. /**
  56676. * Specifies the roughness scalar of the metallic/roughness workflow.
  56677. * Can also be used to scale the roughness values of the metallic texture.
  56678. */
  56679. protected _roughness: Nullable<number>;
  56680. /**
  56681. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56682. * By default the indexOfrefraction is used to compute F0;
  56683. *
  56684. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56685. *
  56686. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56687. * F90 = metallicReflectanceColor;
  56688. */
  56689. protected _metallicF0Factor: number;
  56690. /**
  56691. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56692. * By default the F90 is always 1;
  56693. *
  56694. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56695. *
  56696. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56697. * F90 = metallicReflectanceColor;
  56698. */
  56699. protected _metallicReflectanceColor: Color3;
  56700. /**
  56701. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56702. * This is multiply against the scalar values defined in the material.
  56703. */
  56704. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56705. /**
  56706. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56707. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56708. */
  56709. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56710. /**
  56711. * Stores surface normal data used to displace a mesh in a texture.
  56712. */
  56713. protected _bumpTexture: Nullable<BaseTexture>;
  56714. /**
  56715. * Stores the pre-calculated light information of a mesh in a texture.
  56716. */
  56717. protected _lightmapTexture: Nullable<BaseTexture>;
  56718. /**
  56719. * The color of a material in ambient lighting.
  56720. */
  56721. protected _ambientColor: Color3;
  56722. /**
  56723. * AKA Diffuse Color in other nomenclature.
  56724. */
  56725. protected _albedoColor: Color3;
  56726. /**
  56727. * AKA Specular Color in other nomenclature.
  56728. */
  56729. protected _reflectivityColor: Color3;
  56730. /**
  56731. * The color applied when light is reflected from a material.
  56732. */
  56733. protected _reflectionColor: Color3;
  56734. /**
  56735. * The color applied when light is emitted from a material.
  56736. */
  56737. protected _emissiveColor: Color3;
  56738. /**
  56739. * AKA Glossiness in other nomenclature.
  56740. */
  56741. protected _microSurface: number;
  56742. /**
  56743. * Specifies that the material will use the light map as a show map.
  56744. */
  56745. protected _useLightmapAsShadowmap: boolean;
  56746. /**
  56747. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56748. * makes the reflect vector face the model (under horizon).
  56749. */
  56750. protected _useHorizonOcclusion: boolean;
  56751. /**
  56752. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56753. * too much the area relying on ambient texture to define their ambient occlusion.
  56754. */
  56755. protected _useRadianceOcclusion: boolean;
  56756. /**
  56757. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56758. */
  56759. protected _useAlphaFromAlbedoTexture: boolean;
  56760. /**
  56761. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56762. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56763. */
  56764. protected _useSpecularOverAlpha: boolean;
  56765. /**
  56766. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56767. */
  56768. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56769. /**
  56770. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56771. */
  56772. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56773. /**
  56774. * Specifies if the metallic texture contains the roughness information in its green channel.
  56775. */
  56776. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56777. /**
  56778. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56779. */
  56780. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56781. /**
  56782. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56783. */
  56784. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56785. /**
  56786. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56787. */
  56788. protected _useAmbientInGrayScale: boolean;
  56789. /**
  56790. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56791. * The material will try to infer what glossiness each pixel should be.
  56792. */
  56793. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56794. /**
  56795. * Defines the falloff type used in this material.
  56796. * It by default is Physical.
  56797. */
  56798. protected _lightFalloff: number;
  56799. /**
  56800. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56801. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56802. */
  56803. protected _useRadianceOverAlpha: boolean;
  56804. /**
  56805. * Allows using an object space normal map (instead of tangent space).
  56806. */
  56807. protected _useObjectSpaceNormalMap: boolean;
  56808. /**
  56809. * Allows using the bump map in parallax mode.
  56810. */
  56811. protected _useParallax: boolean;
  56812. /**
  56813. * Allows using the bump map in parallax occlusion mode.
  56814. */
  56815. protected _useParallaxOcclusion: boolean;
  56816. /**
  56817. * Controls the scale bias of the parallax mode.
  56818. */
  56819. protected _parallaxScaleBias: number;
  56820. /**
  56821. * If sets to true, disables all the lights affecting the material.
  56822. */
  56823. protected _disableLighting: boolean;
  56824. /**
  56825. * Number of Simultaneous lights allowed on the material.
  56826. */
  56827. protected _maxSimultaneousLights: number;
  56828. /**
  56829. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56830. */
  56831. protected _invertNormalMapX: boolean;
  56832. /**
  56833. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56834. */
  56835. protected _invertNormalMapY: boolean;
  56836. /**
  56837. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56838. */
  56839. protected _twoSidedLighting: boolean;
  56840. /**
  56841. * Defines the alpha limits in alpha test mode.
  56842. */
  56843. protected _alphaCutOff: number;
  56844. /**
  56845. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56846. */
  56847. protected _forceAlphaTest: boolean;
  56848. /**
  56849. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56850. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56851. */
  56852. protected _useAlphaFresnel: boolean;
  56853. /**
  56854. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56855. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56856. */
  56857. protected _useLinearAlphaFresnel: boolean;
  56858. /**
  56859. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56860. * from cos thetav and roughness:
  56861. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56862. */
  56863. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56864. /**
  56865. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56866. */
  56867. protected _forceIrradianceInFragment: boolean;
  56868. private _realTimeFiltering;
  56869. /**
  56870. * Enables realtime filtering on the texture.
  56871. */
  56872. get realTimeFiltering(): boolean;
  56873. set realTimeFiltering(b: boolean);
  56874. private _realTimeFilteringQuality;
  56875. /**
  56876. * Quality switch for realtime filtering
  56877. */
  56878. get realTimeFilteringQuality(): number;
  56879. set realTimeFilteringQuality(n: number);
  56880. /**
  56881. * Can this material render to several textures at once
  56882. */
  56883. get canRenderToMRT(): boolean;
  56884. /**
  56885. * Force normal to face away from face.
  56886. */
  56887. protected _forceNormalForward: boolean;
  56888. /**
  56889. * Enables specular anti aliasing in the PBR shader.
  56890. * It will both interacts on the Geometry for analytical and IBL lighting.
  56891. * It also prefilter the roughness map based on the bump values.
  56892. */
  56893. protected _enableSpecularAntiAliasing: boolean;
  56894. /**
  56895. * Default configuration related to image processing available in the PBR Material.
  56896. */
  56897. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56898. /**
  56899. * Keep track of the image processing observer to allow dispose and replace.
  56900. */
  56901. private _imageProcessingObserver;
  56902. /**
  56903. * Attaches a new image processing configuration to the PBR Material.
  56904. * @param configuration
  56905. */
  56906. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56907. /**
  56908. * Stores the available render targets.
  56909. */
  56910. private _renderTargets;
  56911. /**
  56912. * Sets the global ambient color for the material used in lighting calculations.
  56913. */
  56914. private _globalAmbientColor;
  56915. /**
  56916. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56917. */
  56918. private _useLogarithmicDepth;
  56919. /**
  56920. * If set to true, no lighting calculations will be applied.
  56921. */
  56922. private _unlit;
  56923. private _debugMode;
  56924. /**
  56925. * @hidden
  56926. * This is reserved for the inspector.
  56927. * Defines the material debug mode.
  56928. * It helps seeing only some components of the material while troubleshooting.
  56929. */
  56930. debugMode: number;
  56931. /**
  56932. * @hidden
  56933. * This is reserved for the inspector.
  56934. * Specify from where on screen the debug mode should start.
  56935. * The value goes from -1 (full screen) to 1 (not visible)
  56936. * It helps with side by side comparison against the final render
  56937. * This defaults to -1
  56938. */
  56939. private debugLimit;
  56940. /**
  56941. * @hidden
  56942. * This is reserved for the inspector.
  56943. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56944. * You can use the factor to better multiply the final value.
  56945. */
  56946. private debugFactor;
  56947. /**
  56948. * Defines the clear coat layer parameters for the material.
  56949. */
  56950. readonly clearCoat: PBRClearCoatConfiguration;
  56951. /**
  56952. * Defines the anisotropic parameters for the material.
  56953. */
  56954. readonly anisotropy: PBRAnisotropicConfiguration;
  56955. /**
  56956. * Defines the BRDF parameters for the material.
  56957. */
  56958. readonly brdf: PBRBRDFConfiguration;
  56959. /**
  56960. * Defines the Sheen parameters for the material.
  56961. */
  56962. readonly sheen: PBRSheenConfiguration;
  56963. /**
  56964. * Defines the SubSurface parameters for the material.
  56965. */
  56966. readonly subSurface: PBRSubSurfaceConfiguration;
  56967. /**
  56968. * Defines the detail map parameters for the material.
  56969. */
  56970. readonly detailMap: DetailMapConfiguration;
  56971. protected _rebuildInParallel: boolean;
  56972. /**
  56973. * Instantiates a new PBRMaterial instance.
  56974. *
  56975. * @param name The material name
  56976. * @param scene The scene the material will be use in.
  56977. */
  56978. constructor(name: string, scene: Scene);
  56979. /**
  56980. * Gets a boolean indicating that current material needs to register RTT
  56981. */
  56982. get hasRenderTargetTextures(): boolean;
  56983. /**
  56984. * Gets the name of the material class.
  56985. */
  56986. getClassName(): string;
  56987. /**
  56988. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56989. */
  56990. get useLogarithmicDepth(): boolean;
  56991. /**
  56992. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56993. */
  56994. set useLogarithmicDepth(value: boolean);
  56995. /**
  56996. * Returns true if alpha blending should be disabled.
  56997. */
  56998. protected get _disableAlphaBlending(): boolean;
  56999. /**
  57000. * Specifies whether or not this material should be rendered in alpha blend mode.
  57001. */
  57002. needAlphaBlending(): boolean;
  57003. /**
  57004. * Specifies whether or not this material should be rendered in alpha test mode.
  57005. */
  57006. needAlphaTesting(): boolean;
  57007. /**
  57008. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57009. */
  57010. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57011. /**
  57012. * Gets the texture used for the alpha test.
  57013. */
  57014. getAlphaTestTexture(): Nullable<BaseTexture>;
  57015. /**
  57016. * Specifies that the submesh is ready to be used.
  57017. * @param mesh - BJS mesh.
  57018. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57019. * @param useInstances - Specifies that instances should be used.
  57020. * @returns - boolean indicating that the submesh is ready or not.
  57021. */
  57022. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57023. /**
  57024. * Specifies if the material uses metallic roughness workflow.
  57025. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57026. */
  57027. isMetallicWorkflow(): boolean;
  57028. private _prepareEffect;
  57029. private _prepareDefines;
  57030. /**
  57031. * Force shader compilation
  57032. */
  57033. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57034. /**
  57035. * Initializes the uniform buffer layout for the shader.
  57036. */
  57037. buildUniformLayout(): void;
  57038. /**
  57039. * Unbinds the material from the mesh
  57040. */
  57041. unbind(): void;
  57042. /**
  57043. * Binds the submesh data.
  57044. * @param world - The world matrix.
  57045. * @param mesh - The BJS mesh.
  57046. * @param subMesh - A submesh of the BJS mesh.
  57047. */
  57048. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57049. /**
  57050. * Returns the animatable textures.
  57051. * @returns - Array of animatable textures.
  57052. */
  57053. getAnimatables(): IAnimatable[];
  57054. /**
  57055. * Returns the texture used for reflections.
  57056. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57057. */
  57058. private _getReflectionTexture;
  57059. /**
  57060. * Returns an array of the actively used textures.
  57061. * @returns - Array of BaseTextures
  57062. */
  57063. getActiveTextures(): BaseTexture[];
  57064. /**
  57065. * Checks to see if a texture is used in the material.
  57066. * @param texture - Base texture to use.
  57067. * @returns - Boolean specifying if a texture is used in the material.
  57068. */
  57069. hasTexture(texture: BaseTexture): boolean;
  57070. /**
  57071. * Sets the required values to the prepass renderer.
  57072. * @param prePassRenderer defines the prepass renderer to setup
  57073. */
  57074. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57075. /**
  57076. * Disposes the resources of the material.
  57077. * @param forceDisposeEffect - Forces the disposal of effects.
  57078. * @param forceDisposeTextures - Forces the disposal of all textures.
  57079. */
  57080. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57081. }
  57082. }
  57083. declare module BABYLON {
  57084. /**
  57085. * The Physically based material of BJS.
  57086. *
  57087. * This offers the main features of a standard PBR material.
  57088. * For more information, please refer to the documentation :
  57089. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57090. */
  57091. export class PBRMaterial extends PBRBaseMaterial {
  57092. /**
  57093. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57094. */
  57095. static readonly PBRMATERIAL_OPAQUE: number;
  57096. /**
  57097. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57098. */
  57099. static readonly PBRMATERIAL_ALPHATEST: number;
  57100. /**
  57101. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57102. */
  57103. static readonly PBRMATERIAL_ALPHABLEND: number;
  57104. /**
  57105. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57106. * They are also discarded below the alpha cutoff threshold to improve performances.
  57107. */
  57108. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57109. /**
  57110. * Defines the default value of how much AO map is occluding the analytical lights
  57111. * (point spot...).
  57112. */
  57113. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57114. /**
  57115. * Intensity of the direct lights e.g. the four lights available in your scene.
  57116. * This impacts both the direct diffuse and specular highlights.
  57117. */
  57118. directIntensity: number;
  57119. /**
  57120. * Intensity of the emissive part of the material.
  57121. * This helps controlling the emissive effect without modifying the emissive color.
  57122. */
  57123. emissiveIntensity: number;
  57124. /**
  57125. * Intensity of the environment e.g. how much the environment will light the object
  57126. * either through harmonics for rough material or through the refelction for shiny ones.
  57127. */
  57128. environmentIntensity: number;
  57129. /**
  57130. * This is a special control allowing the reduction of the specular highlights coming from the
  57131. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57132. */
  57133. specularIntensity: number;
  57134. /**
  57135. * Debug Control allowing disabling the bump map on this material.
  57136. */
  57137. disableBumpMap: boolean;
  57138. /**
  57139. * AKA Diffuse Texture in standard nomenclature.
  57140. */
  57141. albedoTexture: BaseTexture;
  57142. /**
  57143. * AKA Occlusion Texture in other nomenclature.
  57144. */
  57145. ambientTexture: BaseTexture;
  57146. /**
  57147. * AKA Occlusion Texture Intensity in other nomenclature.
  57148. */
  57149. ambientTextureStrength: number;
  57150. /**
  57151. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57152. * 1 means it completely occludes it
  57153. * 0 mean it has no impact
  57154. */
  57155. ambientTextureImpactOnAnalyticalLights: number;
  57156. /**
  57157. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57158. */
  57159. opacityTexture: BaseTexture;
  57160. /**
  57161. * Stores the reflection values in a texture.
  57162. */
  57163. reflectionTexture: Nullable<BaseTexture>;
  57164. /**
  57165. * Stores the emissive values in a texture.
  57166. */
  57167. emissiveTexture: BaseTexture;
  57168. /**
  57169. * AKA Specular texture in other nomenclature.
  57170. */
  57171. reflectivityTexture: BaseTexture;
  57172. /**
  57173. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57174. */
  57175. metallicTexture: BaseTexture;
  57176. /**
  57177. * Specifies the metallic scalar of the metallic/roughness workflow.
  57178. * Can also be used to scale the metalness values of the metallic texture.
  57179. */
  57180. metallic: Nullable<number>;
  57181. /**
  57182. * Specifies the roughness scalar of the metallic/roughness workflow.
  57183. * Can also be used to scale the roughness values of the metallic texture.
  57184. */
  57185. roughness: Nullable<number>;
  57186. /**
  57187. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57188. * By default the indexOfrefraction is used to compute F0;
  57189. *
  57190. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57191. *
  57192. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57193. * F90 = metallicReflectanceColor;
  57194. */
  57195. metallicF0Factor: number;
  57196. /**
  57197. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57198. * By default the F90 is always 1;
  57199. *
  57200. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57201. *
  57202. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57203. * F90 = metallicReflectanceColor;
  57204. */
  57205. metallicReflectanceColor: Color3;
  57206. /**
  57207. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57208. * This is multiply against the scalar values defined in the material.
  57209. */
  57210. metallicReflectanceTexture: Nullable<BaseTexture>;
  57211. /**
  57212. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57213. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57214. */
  57215. microSurfaceTexture: BaseTexture;
  57216. /**
  57217. * Stores surface normal data used to displace a mesh in a texture.
  57218. */
  57219. bumpTexture: BaseTexture;
  57220. /**
  57221. * Stores the pre-calculated light information of a mesh in a texture.
  57222. */
  57223. lightmapTexture: BaseTexture;
  57224. /**
  57225. * Stores the refracted light information in a texture.
  57226. */
  57227. get refractionTexture(): Nullable<BaseTexture>;
  57228. set refractionTexture(value: Nullable<BaseTexture>);
  57229. /**
  57230. * The color of a material in ambient lighting.
  57231. */
  57232. ambientColor: Color3;
  57233. /**
  57234. * AKA Diffuse Color in other nomenclature.
  57235. */
  57236. albedoColor: Color3;
  57237. /**
  57238. * AKA Specular Color in other nomenclature.
  57239. */
  57240. reflectivityColor: Color3;
  57241. /**
  57242. * The color reflected from the material.
  57243. */
  57244. reflectionColor: Color3;
  57245. /**
  57246. * The color emitted from the material.
  57247. */
  57248. emissiveColor: Color3;
  57249. /**
  57250. * AKA Glossiness in other nomenclature.
  57251. */
  57252. microSurface: number;
  57253. /**
  57254. * Index of refraction of the material base layer.
  57255. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57256. *
  57257. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57258. *
  57259. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57260. */
  57261. get indexOfRefraction(): number;
  57262. set indexOfRefraction(value: number);
  57263. /**
  57264. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57265. */
  57266. get invertRefractionY(): boolean;
  57267. set invertRefractionY(value: boolean);
  57268. /**
  57269. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57270. * Materials half opaque for instance using refraction could benefit from this control.
  57271. */
  57272. get linkRefractionWithTransparency(): boolean;
  57273. set linkRefractionWithTransparency(value: boolean);
  57274. /**
  57275. * If true, the light map contains occlusion information instead of lighting info.
  57276. */
  57277. useLightmapAsShadowmap: boolean;
  57278. /**
  57279. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57280. */
  57281. useAlphaFromAlbedoTexture: boolean;
  57282. /**
  57283. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57284. */
  57285. forceAlphaTest: boolean;
  57286. /**
  57287. * Defines the alpha limits in alpha test mode.
  57288. */
  57289. alphaCutOff: number;
  57290. /**
  57291. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57292. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57293. */
  57294. useSpecularOverAlpha: boolean;
  57295. /**
  57296. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57297. */
  57298. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57299. /**
  57300. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57301. */
  57302. useRoughnessFromMetallicTextureAlpha: boolean;
  57303. /**
  57304. * Specifies if the metallic texture contains the roughness information in its green channel.
  57305. */
  57306. useRoughnessFromMetallicTextureGreen: boolean;
  57307. /**
  57308. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57309. */
  57310. useMetallnessFromMetallicTextureBlue: boolean;
  57311. /**
  57312. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57313. */
  57314. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57315. /**
  57316. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57317. */
  57318. useAmbientInGrayScale: boolean;
  57319. /**
  57320. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57321. * The material will try to infer what glossiness each pixel should be.
  57322. */
  57323. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57324. /**
  57325. * BJS is using an harcoded light falloff based on a manually sets up range.
  57326. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57327. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57328. */
  57329. get usePhysicalLightFalloff(): boolean;
  57330. /**
  57331. * BJS is using an harcoded light falloff based on a manually sets up range.
  57332. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57333. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57334. */
  57335. set usePhysicalLightFalloff(value: boolean);
  57336. /**
  57337. * In order to support the falloff compatibility with gltf, a special mode has been added
  57338. * to reproduce the gltf light falloff.
  57339. */
  57340. get useGLTFLightFalloff(): boolean;
  57341. /**
  57342. * In order to support the falloff compatibility with gltf, a special mode has been added
  57343. * to reproduce the gltf light falloff.
  57344. */
  57345. set useGLTFLightFalloff(value: boolean);
  57346. /**
  57347. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57348. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57349. */
  57350. useRadianceOverAlpha: boolean;
  57351. /**
  57352. * Allows using an object space normal map (instead of tangent space).
  57353. */
  57354. useObjectSpaceNormalMap: boolean;
  57355. /**
  57356. * Allows using the bump map in parallax mode.
  57357. */
  57358. useParallax: boolean;
  57359. /**
  57360. * Allows using the bump map in parallax occlusion mode.
  57361. */
  57362. useParallaxOcclusion: boolean;
  57363. /**
  57364. * Controls the scale bias of the parallax mode.
  57365. */
  57366. parallaxScaleBias: number;
  57367. /**
  57368. * If sets to true, disables all the lights affecting the material.
  57369. */
  57370. disableLighting: boolean;
  57371. /**
  57372. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57373. */
  57374. forceIrradianceInFragment: boolean;
  57375. /**
  57376. * Number of Simultaneous lights allowed on the material.
  57377. */
  57378. maxSimultaneousLights: number;
  57379. /**
  57380. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57381. */
  57382. invertNormalMapX: boolean;
  57383. /**
  57384. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57385. */
  57386. invertNormalMapY: boolean;
  57387. /**
  57388. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57389. */
  57390. twoSidedLighting: boolean;
  57391. /**
  57392. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57393. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57394. */
  57395. useAlphaFresnel: boolean;
  57396. /**
  57397. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57398. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57399. */
  57400. useLinearAlphaFresnel: boolean;
  57401. /**
  57402. * Let user defines the brdf lookup texture used for IBL.
  57403. * A default 8bit version is embedded but you could point at :
  57404. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57405. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57406. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57407. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57408. */
  57409. environmentBRDFTexture: Nullable<BaseTexture>;
  57410. /**
  57411. * Force normal to face away from face.
  57412. */
  57413. forceNormalForward: boolean;
  57414. /**
  57415. * Enables specular anti aliasing in the PBR shader.
  57416. * It will both interacts on the Geometry for analytical and IBL lighting.
  57417. * It also prefilter the roughness map based on the bump values.
  57418. */
  57419. enableSpecularAntiAliasing: boolean;
  57420. /**
  57421. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57422. * makes the reflect vector face the model (under horizon).
  57423. */
  57424. useHorizonOcclusion: boolean;
  57425. /**
  57426. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57427. * too much the area relying on ambient texture to define their ambient occlusion.
  57428. */
  57429. useRadianceOcclusion: boolean;
  57430. /**
  57431. * If set to true, no lighting calculations will be applied.
  57432. */
  57433. unlit: boolean;
  57434. /**
  57435. * Gets the image processing configuration used either in this material.
  57436. */
  57437. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57438. /**
  57439. * Sets the Default image processing configuration used either in the this material.
  57440. *
  57441. * If sets to null, the scene one is in use.
  57442. */
  57443. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57444. /**
  57445. * Gets wether the color curves effect is enabled.
  57446. */
  57447. get cameraColorCurvesEnabled(): boolean;
  57448. /**
  57449. * Sets wether the color curves effect is enabled.
  57450. */
  57451. set cameraColorCurvesEnabled(value: boolean);
  57452. /**
  57453. * Gets wether the color grading effect is enabled.
  57454. */
  57455. get cameraColorGradingEnabled(): boolean;
  57456. /**
  57457. * Gets wether the color grading effect is enabled.
  57458. */
  57459. set cameraColorGradingEnabled(value: boolean);
  57460. /**
  57461. * Gets wether tonemapping is enabled or not.
  57462. */
  57463. get cameraToneMappingEnabled(): boolean;
  57464. /**
  57465. * Sets wether tonemapping is enabled or not
  57466. */
  57467. set cameraToneMappingEnabled(value: boolean);
  57468. /**
  57469. * The camera exposure used on this material.
  57470. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57471. * This corresponds to a photographic exposure.
  57472. */
  57473. get cameraExposure(): number;
  57474. /**
  57475. * The camera exposure used on this material.
  57476. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57477. * This corresponds to a photographic exposure.
  57478. */
  57479. set cameraExposure(value: number);
  57480. /**
  57481. * Gets The camera contrast used on this material.
  57482. */
  57483. get cameraContrast(): number;
  57484. /**
  57485. * Sets The camera contrast used on this material.
  57486. */
  57487. set cameraContrast(value: number);
  57488. /**
  57489. * Gets the Color Grading 2D Lookup Texture.
  57490. */
  57491. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57492. /**
  57493. * Sets the Color Grading 2D Lookup Texture.
  57494. */
  57495. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57496. /**
  57497. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57498. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57499. * 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;
  57500. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57501. */
  57502. get cameraColorCurves(): Nullable<ColorCurves>;
  57503. /**
  57504. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57505. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57506. * 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;
  57507. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57508. */
  57509. set cameraColorCurves(value: Nullable<ColorCurves>);
  57510. /**
  57511. * Instantiates a new PBRMaterial instance.
  57512. *
  57513. * @param name The material name
  57514. * @param scene The scene the material will be use in.
  57515. */
  57516. constructor(name: string, scene: Scene);
  57517. /**
  57518. * Returns the name of this material class.
  57519. */
  57520. getClassName(): string;
  57521. /**
  57522. * Makes a duplicate of the current material.
  57523. * @param name - name to use for the new material.
  57524. */
  57525. clone(name: string): PBRMaterial;
  57526. /**
  57527. * Serializes this PBR Material.
  57528. * @returns - An object with the serialized material.
  57529. */
  57530. serialize(): any;
  57531. /**
  57532. * Parses a PBR Material from a serialized object.
  57533. * @param source - Serialized object.
  57534. * @param scene - BJS scene instance.
  57535. * @param rootUrl - url for the scene object
  57536. * @returns - PBRMaterial
  57537. */
  57538. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57539. }
  57540. }
  57541. declare module BABYLON {
  57542. /**
  57543. * Direct draw surface info
  57544. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57545. */
  57546. export interface DDSInfo {
  57547. /**
  57548. * Width of the texture
  57549. */
  57550. width: number;
  57551. /**
  57552. * Width of the texture
  57553. */
  57554. height: number;
  57555. /**
  57556. * Number of Mipmaps for the texture
  57557. * @see https://en.wikipedia.org/wiki/Mipmap
  57558. */
  57559. mipmapCount: number;
  57560. /**
  57561. * If the textures format is a known fourCC format
  57562. * @see https://www.fourcc.org/
  57563. */
  57564. isFourCC: boolean;
  57565. /**
  57566. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57567. */
  57568. isRGB: boolean;
  57569. /**
  57570. * If the texture is a lumincance format
  57571. */
  57572. isLuminance: boolean;
  57573. /**
  57574. * If this is a cube texture
  57575. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57576. */
  57577. isCube: boolean;
  57578. /**
  57579. * If the texture is a compressed format eg. FOURCC_DXT1
  57580. */
  57581. isCompressed: boolean;
  57582. /**
  57583. * The dxgiFormat of the texture
  57584. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57585. */
  57586. dxgiFormat: number;
  57587. /**
  57588. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57589. */
  57590. textureType: number;
  57591. /**
  57592. * Sphericle polynomial created for the dds texture
  57593. */
  57594. sphericalPolynomial?: SphericalPolynomial;
  57595. }
  57596. /**
  57597. * Class used to provide DDS decompression tools
  57598. */
  57599. export class DDSTools {
  57600. /**
  57601. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57602. */
  57603. static StoreLODInAlphaChannel: boolean;
  57604. /**
  57605. * Gets DDS information from an array buffer
  57606. * @param data defines the array buffer view to read data from
  57607. * @returns the DDS information
  57608. */
  57609. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57610. private static _FloatView;
  57611. private static _Int32View;
  57612. private static _ToHalfFloat;
  57613. private static _FromHalfFloat;
  57614. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57615. private static _GetHalfFloatRGBAArrayBuffer;
  57616. private static _GetFloatRGBAArrayBuffer;
  57617. private static _GetFloatAsUIntRGBAArrayBuffer;
  57618. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57619. private static _GetRGBAArrayBuffer;
  57620. private static _ExtractLongWordOrder;
  57621. private static _GetRGBArrayBuffer;
  57622. private static _GetLuminanceArrayBuffer;
  57623. /**
  57624. * Uploads DDS Levels to a Babylon Texture
  57625. * @hidden
  57626. */
  57627. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57628. }
  57629. interface ThinEngine {
  57630. /**
  57631. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57632. * @param rootUrl defines the url where the file to load is located
  57633. * @param scene defines the current scene
  57634. * @param lodScale defines scale to apply to the mip map selection
  57635. * @param lodOffset defines offset to apply to the mip map selection
  57636. * @param onLoad defines an optional callback raised when the texture is loaded
  57637. * @param onError defines an optional callback raised if there is an issue to load the texture
  57638. * @param format defines the format of the data
  57639. * @param forcedExtension defines the extension to use to pick the right loader
  57640. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57641. * @returns the cube texture as an InternalTexture
  57642. */
  57643. 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;
  57644. }
  57645. }
  57646. declare module BABYLON {
  57647. /**
  57648. * Implementation of the DDS Texture Loader.
  57649. * @hidden
  57650. */
  57651. export class _DDSTextureLoader implements IInternalTextureLoader {
  57652. /**
  57653. * Defines wether the loader supports cascade loading the different faces.
  57654. */
  57655. readonly supportCascades: boolean;
  57656. /**
  57657. * This returns if the loader support the current file information.
  57658. * @param extension defines the file extension of the file being loaded
  57659. * @returns true if the loader can load the specified file
  57660. */
  57661. canLoad(extension: string): boolean;
  57662. /**
  57663. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57664. * @param data contains the texture data
  57665. * @param texture defines the BabylonJS internal texture
  57666. * @param createPolynomials will be true if polynomials have been requested
  57667. * @param onLoad defines the callback to trigger once the texture is ready
  57668. * @param onError defines the callback to trigger in case of error
  57669. */
  57670. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57671. /**
  57672. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57673. * @param data contains the texture data
  57674. * @param texture defines the BabylonJS internal texture
  57675. * @param callback defines the method to call once ready to upload
  57676. */
  57677. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57678. }
  57679. }
  57680. declare module BABYLON {
  57681. /**
  57682. * Implementation of the ENV Texture Loader.
  57683. * @hidden
  57684. */
  57685. export class _ENVTextureLoader implements IInternalTextureLoader {
  57686. /**
  57687. * Defines wether the loader supports cascade loading the different faces.
  57688. */
  57689. readonly supportCascades: boolean;
  57690. /**
  57691. * This returns if the loader support the current file information.
  57692. * @param extension defines the file extension of the file being loaded
  57693. * @returns true if the loader can load the specified file
  57694. */
  57695. canLoad(extension: string): boolean;
  57696. /**
  57697. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57698. * @param data contains the texture data
  57699. * @param texture defines the BabylonJS internal texture
  57700. * @param createPolynomials will be true if polynomials have been requested
  57701. * @param onLoad defines the callback to trigger once the texture is ready
  57702. * @param onError defines the callback to trigger in case of error
  57703. */
  57704. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57705. /**
  57706. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57707. * @param data contains the texture data
  57708. * @param texture defines the BabylonJS internal texture
  57709. * @param callback defines the method to call once ready to upload
  57710. */
  57711. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57712. }
  57713. }
  57714. declare module BABYLON {
  57715. /**
  57716. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57717. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57718. */
  57719. export class KhronosTextureContainer {
  57720. /** contents of the KTX container file */
  57721. data: ArrayBufferView;
  57722. private static HEADER_LEN;
  57723. private static COMPRESSED_2D;
  57724. private static COMPRESSED_3D;
  57725. private static TEX_2D;
  57726. private static TEX_3D;
  57727. /**
  57728. * Gets the openGL type
  57729. */
  57730. glType: number;
  57731. /**
  57732. * Gets the openGL type size
  57733. */
  57734. glTypeSize: number;
  57735. /**
  57736. * Gets the openGL format
  57737. */
  57738. glFormat: number;
  57739. /**
  57740. * Gets the openGL internal format
  57741. */
  57742. glInternalFormat: number;
  57743. /**
  57744. * Gets the base internal format
  57745. */
  57746. glBaseInternalFormat: number;
  57747. /**
  57748. * Gets image width in pixel
  57749. */
  57750. pixelWidth: number;
  57751. /**
  57752. * Gets image height in pixel
  57753. */
  57754. pixelHeight: number;
  57755. /**
  57756. * Gets image depth in pixels
  57757. */
  57758. pixelDepth: number;
  57759. /**
  57760. * Gets the number of array elements
  57761. */
  57762. numberOfArrayElements: number;
  57763. /**
  57764. * Gets the number of faces
  57765. */
  57766. numberOfFaces: number;
  57767. /**
  57768. * Gets the number of mipmap levels
  57769. */
  57770. numberOfMipmapLevels: number;
  57771. /**
  57772. * Gets the bytes of key value data
  57773. */
  57774. bytesOfKeyValueData: number;
  57775. /**
  57776. * Gets the load type
  57777. */
  57778. loadType: number;
  57779. /**
  57780. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57781. */
  57782. isInvalid: boolean;
  57783. /**
  57784. * Creates a new KhronosTextureContainer
  57785. * @param data contents of the KTX container file
  57786. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57787. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57788. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57789. */
  57790. constructor(
  57791. /** contents of the KTX container file */
  57792. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57793. /**
  57794. * Uploads KTX content to a Babylon Texture.
  57795. * It is assumed that the texture has already been created & is currently bound
  57796. * @hidden
  57797. */
  57798. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57799. private _upload2DCompressedLevels;
  57800. /**
  57801. * Checks if the given data starts with a KTX file identifier.
  57802. * @param data the data to check
  57803. * @returns true if the data is a KTX file or false otherwise
  57804. */
  57805. static IsValid(data: ArrayBufferView): boolean;
  57806. }
  57807. }
  57808. declare module BABYLON {
  57809. /**
  57810. * Helper class to push actions to a pool of workers.
  57811. */
  57812. export class WorkerPool implements IDisposable {
  57813. private _workerInfos;
  57814. private _pendingActions;
  57815. /**
  57816. * Constructor
  57817. * @param workers Array of workers to use for actions
  57818. */
  57819. constructor(workers: Array<Worker>);
  57820. /**
  57821. * Terminates all workers and clears any pending actions.
  57822. */
  57823. dispose(): void;
  57824. /**
  57825. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57826. * pended until a worker has completed its action.
  57827. * @param action The action to perform. Call onComplete when the action is complete.
  57828. */
  57829. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57830. private _execute;
  57831. }
  57832. }
  57833. declare module BABYLON {
  57834. /**
  57835. * Class for loading KTX2 files
  57836. * @hidden
  57837. */
  57838. export class KhronosTextureContainer2 {
  57839. private static _WorkerPoolPromise?;
  57840. private static _Initialized;
  57841. private static _Ktx2Decoder;
  57842. /**
  57843. * URL to use when loading the KTX2 decoder module
  57844. */
  57845. static JSModuleURL: string;
  57846. /**
  57847. * Default number of workers used to handle data decoding
  57848. */
  57849. static DefaultNumWorkers: number;
  57850. private static GetDefaultNumWorkers;
  57851. private _engine;
  57852. private static _CreateWorkerPool;
  57853. /**
  57854. * Constructor
  57855. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57856. */
  57857. constructor(engine: ThinEngine, numWorkers?: number);
  57858. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57859. /**
  57860. * Stop all async operations and release resources.
  57861. */
  57862. dispose(): void;
  57863. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  57864. /**
  57865. * Checks if the given data starts with a KTX2 file identifier.
  57866. * @param data the data to check
  57867. * @returns true if the data is a KTX2 file or false otherwise
  57868. */
  57869. static IsValid(data: ArrayBufferView): boolean;
  57870. }
  57871. export function workerFunc(): void;
  57872. }
  57873. declare module BABYLON {
  57874. /**
  57875. * Implementation of the KTX Texture Loader.
  57876. * @hidden
  57877. */
  57878. export class _KTXTextureLoader implements IInternalTextureLoader {
  57879. /**
  57880. * Defines wether the loader supports cascade loading the different faces.
  57881. */
  57882. readonly supportCascades: boolean;
  57883. /**
  57884. * This returns if the loader support the current file information.
  57885. * @param extension defines the file extension of the file being loaded
  57886. * @param mimeType defines the optional mime type of the file being loaded
  57887. * @returns true if the loader can load the specified file
  57888. */
  57889. canLoad(extension: string, mimeType?: string): boolean;
  57890. /**
  57891. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57892. * @param data contains the texture data
  57893. * @param texture defines the BabylonJS internal texture
  57894. * @param createPolynomials will be true if polynomials have been requested
  57895. * @param onLoad defines the callback to trigger once the texture is ready
  57896. * @param onError defines the callback to trigger in case of error
  57897. */
  57898. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57899. /**
  57900. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57901. * @param data contains the texture data
  57902. * @param texture defines the BabylonJS internal texture
  57903. * @param callback defines the method to call once ready to upload
  57904. */
  57905. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57906. }
  57907. }
  57908. declare module BABYLON {
  57909. /** @hidden */
  57910. export var _forceSceneHelpersToBundle: boolean;
  57911. interface Scene {
  57912. /**
  57913. * Creates a default light for the scene.
  57914. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57915. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57916. */
  57917. createDefaultLight(replace?: boolean): void;
  57918. /**
  57919. * Creates a default camera for the scene.
  57920. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57921. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57922. * @param replace has default false, when true replaces the active camera in the scene
  57923. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57924. */
  57925. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57926. /**
  57927. * Creates a default camera and a default light.
  57928. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57929. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57930. * @param replace has the default false, when true replaces the active camera/light in the scene
  57931. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57932. */
  57933. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57934. /**
  57935. * Creates a new sky box
  57936. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57937. * @param environmentTexture defines the texture to use as environment texture
  57938. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57939. * @param scale defines the overall scale of the skybox
  57940. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57941. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57942. * @returns a new mesh holding the sky box
  57943. */
  57944. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57945. /**
  57946. * Creates a new environment
  57947. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57948. * @param options defines the options you can use to configure the environment
  57949. * @returns the new EnvironmentHelper
  57950. */
  57951. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57952. /**
  57953. * Creates a new VREXperienceHelper
  57954. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57955. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57956. * @returns a new VREXperienceHelper
  57957. */
  57958. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57959. /**
  57960. * Creates a new WebXRDefaultExperience
  57961. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57962. * @param options experience options
  57963. * @returns a promise for a new WebXRDefaultExperience
  57964. */
  57965. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57966. }
  57967. }
  57968. declare module BABYLON {
  57969. /**
  57970. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57971. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57972. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57973. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57974. */
  57975. export class VideoDome extends TextureDome<VideoTexture> {
  57976. /**
  57977. * Define the video source as a Monoscopic panoramic 360 video.
  57978. */
  57979. static readonly MODE_MONOSCOPIC: number;
  57980. /**
  57981. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57982. */
  57983. static readonly MODE_TOPBOTTOM: number;
  57984. /**
  57985. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57986. */
  57987. static readonly MODE_SIDEBYSIDE: number;
  57988. /**
  57989. * Get the video texture associated with this video dome
  57990. */
  57991. get videoTexture(): VideoTexture;
  57992. /**
  57993. * Get the video mode of this dome
  57994. */
  57995. get videoMode(): number;
  57996. /**
  57997. * Set the video mode of this dome.
  57998. * @see textureMode
  57999. */
  58000. set videoMode(value: number);
  58001. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58002. }
  58003. }
  58004. declare module BABYLON {
  58005. /**
  58006. * This class can be used to get instrumentation data from a Babylon engine
  58007. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58008. */
  58009. export class EngineInstrumentation implements IDisposable {
  58010. /**
  58011. * Define the instrumented engine.
  58012. */
  58013. engine: Engine;
  58014. private _captureGPUFrameTime;
  58015. private _gpuFrameTimeToken;
  58016. private _gpuFrameTime;
  58017. private _captureShaderCompilationTime;
  58018. private _shaderCompilationTime;
  58019. private _onBeginFrameObserver;
  58020. private _onEndFrameObserver;
  58021. private _onBeforeShaderCompilationObserver;
  58022. private _onAfterShaderCompilationObserver;
  58023. /**
  58024. * Gets the perf counter used for GPU frame time
  58025. */
  58026. get gpuFrameTimeCounter(): PerfCounter;
  58027. /**
  58028. * Gets the GPU frame time capture status
  58029. */
  58030. get captureGPUFrameTime(): boolean;
  58031. /**
  58032. * Enable or disable the GPU frame time capture
  58033. */
  58034. set captureGPUFrameTime(value: boolean);
  58035. /**
  58036. * Gets the perf counter used for shader compilation time
  58037. */
  58038. get shaderCompilationTimeCounter(): PerfCounter;
  58039. /**
  58040. * Gets the shader compilation time capture status
  58041. */
  58042. get captureShaderCompilationTime(): boolean;
  58043. /**
  58044. * Enable or disable the shader compilation time capture
  58045. */
  58046. set captureShaderCompilationTime(value: boolean);
  58047. /**
  58048. * Instantiates a new engine instrumentation.
  58049. * This class can be used to get instrumentation data from a Babylon engine
  58050. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58051. * @param engine Defines the engine to instrument
  58052. */
  58053. constructor(
  58054. /**
  58055. * Define the instrumented engine.
  58056. */
  58057. engine: Engine);
  58058. /**
  58059. * Dispose and release associated resources.
  58060. */
  58061. dispose(): void;
  58062. }
  58063. }
  58064. declare module BABYLON {
  58065. /**
  58066. * This class can be used to get instrumentation data from a Babylon engine
  58067. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58068. */
  58069. export class SceneInstrumentation implements IDisposable {
  58070. /**
  58071. * Defines the scene to instrument
  58072. */
  58073. scene: Scene;
  58074. private _captureActiveMeshesEvaluationTime;
  58075. private _activeMeshesEvaluationTime;
  58076. private _captureRenderTargetsRenderTime;
  58077. private _renderTargetsRenderTime;
  58078. private _captureFrameTime;
  58079. private _frameTime;
  58080. private _captureRenderTime;
  58081. private _renderTime;
  58082. private _captureInterFrameTime;
  58083. private _interFrameTime;
  58084. private _captureParticlesRenderTime;
  58085. private _particlesRenderTime;
  58086. private _captureSpritesRenderTime;
  58087. private _spritesRenderTime;
  58088. private _capturePhysicsTime;
  58089. private _physicsTime;
  58090. private _captureAnimationsTime;
  58091. private _animationsTime;
  58092. private _captureCameraRenderTime;
  58093. private _cameraRenderTime;
  58094. private _onBeforeActiveMeshesEvaluationObserver;
  58095. private _onAfterActiveMeshesEvaluationObserver;
  58096. private _onBeforeRenderTargetsRenderObserver;
  58097. private _onAfterRenderTargetsRenderObserver;
  58098. private _onAfterRenderObserver;
  58099. private _onBeforeDrawPhaseObserver;
  58100. private _onAfterDrawPhaseObserver;
  58101. private _onBeforeAnimationsObserver;
  58102. private _onBeforeParticlesRenderingObserver;
  58103. private _onAfterParticlesRenderingObserver;
  58104. private _onBeforeSpritesRenderingObserver;
  58105. private _onAfterSpritesRenderingObserver;
  58106. private _onBeforePhysicsObserver;
  58107. private _onAfterPhysicsObserver;
  58108. private _onAfterAnimationsObserver;
  58109. private _onBeforeCameraRenderObserver;
  58110. private _onAfterCameraRenderObserver;
  58111. /**
  58112. * Gets the perf counter used for active meshes evaluation time
  58113. */
  58114. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58115. /**
  58116. * Gets the active meshes evaluation time capture status
  58117. */
  58118. get captureActiveMeshesEvaluationTime(): boolean;
  58119. /**
  58120. * Enable or disable the active meshes evaluation time capture
  58121. */
  58122. set captureActiveMeshesEvaluationTime(value: boolean);
  58123. /**
  58124. * Gets the perf counter used for render targets render time
  58125. */
  58126. get renderTargetsRenderTimeCounter(): PerfCounter;
  58127. /**
  58128. * Gets the render targets render time capture status
  58129. */
  58130. get captureRenderTargetsRenderTime(): boolean;
  58131. /**
  58132. * Enable or disable the render targets render time capture
  58133. */
  58134. set captureRenderTargetsRenderTime(value: boolean);
  58135. /**
  58136. * Gets the perf counter used for particles render time
  58137. */
  58138. get particlesRenderTimeCounter(): PerfCounter;
  58139. /**
  58140. * Gets the particles render time capture status
  58141. */
  58142. get captureParticlesRenderTime(): boolean;
  58143. /**
  58144. * Enable or disable the particles render time capture
  58145. */
  58146. set captureParticlesRenderTime(value: boolean);
  58147. /**
  58148. * Gets the perf counter used for sprites render time
  58149. */
  58150. get spritesRenderTimeCounter(): PerfCounter;
  58151. /**
  58152. * Gets the sprites render time capture status
  58153. */
  58154. get captureSpritesRenderTime(): boolean;
  58155. /**
  58156. * Enable or disable the sprites render time capture
  58157. */
  58158. set captureSpritesRenderTime(value: boolean);
  58159. /**
  58160. * Gets the perf counter used for physics time
  58161. */
  58162. get physicsTimeCounter(): PerfCounter;
  58163. /**
  58164. * Gets the physics time capture status
  58165. */
  58166. get capturePhysicsTime(): boolean;
  58167. /**
  58168. * Enable or disable the physics time capture
  58169. */
  58170. set capturePhysicsTime(value: boolean);
  58171. /**
  58172. * Gets the perf counter used for animations time
  58173. */
  58174. get animationsTimeCounter(): PerfCounter;
  58175. /**
  58176. * Gets the animations time capture status
  58177. */
  58178. get captureAnimationsTime(): boolean;
  58179. /**
  58180. * Enable or disable the animations time capture
  58181. */
  58182. set captureAnimationsTime(value: boolean);
  58183. /**
  58184. * Gets the perf counter used for frame time capture
  58185. */
  58186. get frameTimeCounter(): PerfCounter;
  58187. /**
  58188. * Gets the frame time capture status
  58189. */
  58190. get captureFrameTime(): boolean;
  58191. /**
  58192. * Enable or disable the frame time capture
  58193. */
  58194. set captureFrameTime(value: boolean);
  58195. /**
  58196. * Gets the perf counter used for inter-frames time capture
  58197. */
  58198. get interFrameTimeCounter(): PerfCounter;
  58199. /**
  58200. * Gets the inter-frames time capture status
  58201. */
  58202. get captureInterFrameTime(): boolean;
  58203. /**
  58204. * Enable or disable the inter-frames time capture
  58205. */
  58206. set captureInterFrameTime(value: boolean);
  58207. /**
  58208. * Gets the perf counter used for render time capture
  58209. */
  58210. get renderTimeCounter(): PerfCounter;
  58211. /**
  58212. * Gets the render time capture status
  58213. */
  58214. get captureRenderTime(): boolean;
  58215. /**
  58216. * Enable or disable the render time capture
  58217. */
  58218. set captureRenderTime(value: boolean);
  58219. /**
  58220. * Gets the perf counter used for camera render time capture
  58221. */
  58222. get cameraRenderTimeCounter(): PerfCounter;
  58223. /**
  58224. * Gets the camera render time capture status
  58225. */
  58226. get captureCameraRenderTime(): boolean;
  58227. /**
  58228. * Enable or disable the camera render time capture
  58229. */
  58230. set captureCameraRenderTime(value: boolean);
  58231. /**
  58232. * Gets the perf counter used for draw calls
  58233. */
  58234. get drawCallsCounter(): PerfCounter;
  58235. /**
  58236. * Instantiates a new scene instrumentation.
  58237. * This class can be used to get instrumentation data from a Babylon engine
  58238. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58239. * @param scene Defines the scene to instrument
  58240. */
  58241. constructor(
  58242. /**
  58243. * Defines the scene to instrument
  58244. */
  58245. scene: Scene);
  58246. /**
  58247. * Dispose and release associated resources.
  58248. */
  58249. dispose(): void;
  58250. }
  58251. }
  58252. declare module BABYLON {
  58253. /** @hidden */
  58254. export var glowMapGenerationPixelShader: {
  58255. name: string;
  58256. shader: string;
  58257. };
  58258. }
  58259. declare module BABYLON {
  58260. /** @hidden */
  58261. export var glowMapGenerationVertexShader: {
  58262. name: string;
  58263. shader: string;
  58264. };
  58265. }
  58266. declare module BABYLON {
  58267. /**
  58268. * Effect layer options. This helps customizing the behaviour
  58269. * of the effect layer.
  58270. */
  58271. export interface IEffectLayerOptions {
  58272. /**
  58273. * Multiplication factor apply to the canvas size to compute the render target size
  58274. * used to generated the objects (the smaller the faster).
  58275. */
  58276. mainTextureRatio: number;
  58277. /**
  58278. * Enforces a fixed size texture to ensure effect stability across devices.
  58279. */
  58280. mainTextureFixedSize?: number;
  58281. /**
  58282. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58283. */
  58284. alphaBlendingMode: number;
  58285. /**
  58286. * The camera attached to the layer.
  58287. */
  58288. camera: Nullable<Camera>;
  58289. /**
  58290. * The rendering group to draw the layer in.
  58291. */
  58292. renderingGroupId: number;
  58293. }
  58294. /**
  58295. * The effect layer Helps adding post process effect blended with the main pass.
  58296. *
  58297. * This can be for instance use to generate glow or higlight effects on the scene.
  58298. *
  58299. * The effect layer class can not be used directly and is intented to inherited from to be
  58300. * customized per effects.
  58301. */
  58302. export abstract class EffectLayer {
  58303. private _vertexBuffers;
  58304. private _indexBuffer;
  58305. private _cachedDefines;
  58306. private _effectLayerMapGenerationEffect;
  58307. private _effectLayerOptions;
  58308. private _mergeEffect;
  58309. protected _scene: Scene;
  58310. protected _engine: Engine;
  58311. protected _maxSize: number;
  58312. protected _mainTextureDesiredSize: ISize;
  58313. protected _mainTexture: RenderTargetTexture;
  58314. protected _shouldRender: boolean;
  58315. protected _postProcesses: PostProcess[];
  58316. protected _textures: BaseTexture[];
  58317. protected _emissiveTextureAndColor: {
  58318. texture: Nullable<BaseTexture>;
  58319. color: Color4;
  58320. };
  58321. /**
  58322. * The name of the layer
  58323. */
  58324. name: string;
  58325. /**
  58326. * The clear color of the texture used to generate the glow map.
  58327. */
  58328. neutralColor: Color4;
  58329. /**
  58330. * Specifies whether the highlight layer is enabled or not.
  58331. */
  58332. isEnabled: boolean;
  58333. /**
  58334. * Gets the camera attached to the layer.
  58335. */
  58336. get camera(): Nullable<Camera>;
  58337. /**
  58338. * Gets the rendering group id the layer should render in.
  58339. */
  58340. get renderingGroupId(): number;
  58341. set renderingGroupId(renderingGroupId: number);
  58342. /**
  58343. * An event triggered when the effect layer has been disposed.
  58344. */
  58345. onDisposeObservable: Observable<EffectLayer>;
  58346. /**
  58347. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58348. */
  58349. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58350. /**
  58351. * An event triggered when the generated texture is being merged in the scene.
  58352. */
  58353. onBeforeComposeObservable: Observable<EffectLayer>;
  58354. /**
  58355. * An event triggered when the mesh is rendered into the effect render target.
  58356. */
  58357. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58358. /**
  58359. * An event triggered after the mesh has been rendered into the effect render target.
  58360. */
  58361. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58362. /**
  58363. * An event triggered when the generated texture has been merged in the scene.
  58364. */
  58365. onAfterComposeObservable: Observable<EffectLayer>;
  58366. /**
  58367. * An event triggered when the efffect layer changes its size.
  58368. */
  58369. onSizeChangedObservable: Observable<EffectLayer>;
  58370. /** @hidden */
  58371. static _SceneComponentInitialization: (scene: Scene) => void;
  58372. /**
  58373. * Instantiates a new effect Layer and references it in the scene.
  58374. * @param name The name of the layer
  58375. * @param scene The scene to use the layer in
  58376. */
  58377. constructor(
  58378. /** The Friendly of the effect in the scene */
  58379. name: string, scene: Scene);
  58380. /**
  58381. * Get the effect name of the layer.
  58382. * @return The effect name
  58383. */
  58384. abstract getEffectName(): string;
  58385. /**
  58386. * Checks for the readiness of the element composing the layer.
  58387. * @param subMesh the mesh to check for
  58388. * @param useInstances specify whether or not to use instances to render the mesh
  58389. * @return true if ready otherwise, false
  58390. */
  58391. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58392. /**
  58393. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58394. * @returns true if the effect requires stencil during the main canvas render pass.
  58395. */
  58396. abstract needStencil(): boolean;
  58397. /**
  58398. * Create the merge effect. This is the shader use to blit the information back
  58399. * to the main canvas at the end of the scene rendering.
  58400. * @returns The effect containing the shader used to merge the effect on the main canvas
  58401. */
  58402. protected abstract _createMergeEffect(): Effect;
  58403. /**
  58404. * Creates the render target textures and post processes used in the effect layer.
  58405. */
  58406. protected abstract _createTextureAndPostProcesses(): void;
  58407. /**
  58408. * Implementation specific of rendering the generating effect on the main canvas.
  58409. * @param effect The effect used to render through
  58410. */
  58411. protected abstract _internalRender(effect: Effect): void;
  58412. /**
  58413. * Sets the required values for both the emissive texture and and the main color.
  58414. */
  58415. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58416. /**
  58417. * Free any resources and references associated to a mesh.
  58418. * Internal use
  58419. * @param mesh The mesh to free.
  58420. */
  58421. abstract _disposeMesh(mesh: Mesh): void;
  58422. /**
  58423. * Serializes this layer (Glow or Highlight for example)
  58424. * @returns a serialized layer object
  58425. */
  58426. abstract serialize?(): any;
  58427. /**
  58428. * Initializes the effect layer with the required options.
  58429. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58430. */
  58431. protected _init(options: Partial<IEffectLayerOptions>): void;
  58432. /**
  58433. * Generates the index buffer of the full screen quad blending to the main canvas.
  58434. */
  58435. private _generateIndexBuffer;
  58436. /**
  58437. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58438. */
  58439. private _generateVertexBuffer;
  58440. /**
  58441. * Sets the main texture desired size which is the closest power of two
  58442. * of the engine canvas size.
  58443. */
  58444. private _setMainTextureSize;
  58445. /**
  58446. * Creates the main texture for the effect layer.
  58447. */
  58448. protected _createMainTexture(): void;
  58449. /**
  58450. * Adds specific effects defines.
  58451. * @param defines The defines to add specifics to.
  58452. */
  58453. protected _addCustomEffectDefines(defines: string[]): void;
  58454. /**
  58455. * Checks for the readiness of the element composing the layer.
  58456. * @param subMesh the mesh to check for
  58457. * @param useInstances specify whether or not to use instances to render the mesh
  58458. * @param emissiveTexture the associated emissive texture used to generate the glow
  58459. * @return true if ready otherwise, false
  58460. */
  58461. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58462. /**
  58463. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58464. */
  58465. render(): void;
  58466. /**
  58467. * Determine if a given mesh will be used in the current effect.
  58468. * @param mesh mesh to test
  58469. * @returns true if the mesh will be used
  58470. */
  58471. hasMesh(mesh: AbstractMesh): boolean;
  58472. /**
  58473. * Returns true if the layer contains information to display, otherwise false.
  58474. * @returns true if the glow layer should be rendered
  58475. */
  58476. shouldRender(): boolean;
  58477. /**
  58478. * Returns true if the mesh should render, otherwise false.
  58479. * @param mesh The mesh to render
  58480. * @returns true if it should render otherwise false
  58481. */
  58482. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58483. /**
  58484. * Returns true if the mesh can be rendered, otherwise false.
  58485. * @param mesh The mesh to render
  58486. * @param material The material used on the mesh
  58487. * @returns true if it can be rendered otherwise false
  58488. */
  58489. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58490. /**
  58491. * Returns true if the mesh should render, otherwise false.
  58492. * @param mesh The mesh to render
  58493. * @returns true if it should render otherwise false
  58494. */
  58495. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58496. /**
  58497. * Renders the submesh passed in parameter to the generation map.
  58498. */
  58499. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58500. /**
  58501. * Defines whether the current material of the mesh should be use to render the effect.
  58502. * @param mesh defines the current mesh to render
  58503. */
  58504. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58505. /**
  58506. * Rebuild the required buffers.
  58507. * @hidden Internal use only.
  58508. */
  58509. _rebuild(): void;
  58510. /**
  58511. * Dispose only the render target textures and post process.
  58512. */
  58513. private _disposeTextureAndPostProcesses;
  58514. /**
  58515. * Dispose the highlight layer and free resources.
  58516. */
  58517. dispose(): void;
  58518. /**
  58519. * Gets the class name of the effect layer
  58520. * @returns the string with the class name of the effect layer
  58521. */
  58522. getClassName(): string;
  58523. /**
  58524. * Creates an effect layer from parsed effect layer data
  58525. * @param parsedEffectLayer defines effect layer data
  58526. * @param scene defines the current scene
  58527. * @param rootUrl defines the root URL containing the effect layer information
  58528. * @returns a parsed effect Layer
  58529. */
  58530. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58531. }
  58532. }
  58533. declare module BABYLON {
  58534. interface AbstractScene {
  58535. /**
  58536. * The list of effect layers (highlights/glow) added to the scene
  58537. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58538. * @see https://doc.babylonjs.com/how_to/glow_layer
  58539. */
  58540. effectLayers: Array<EffectLayer>;
  58541. /**
  58542. * Removes the given effect layer from this scene.
  58543. * @param toRemove defines the effect layer to remove
  58544. * @returns the index of the removed effect layer
  58545. */
  58546. removeEffectLayer(toRemove: EffectLayer): number;
  58547. /**
  58548. * Adds the given effect layer to this scene
  58549. * @param newEffectLayer defines the effect layer to add
  58550. */
  58551. addEffectLayer(newEffectLayer: EffectLayer): void;
  58552. }
  58553. /**
  58554. * Defines the layer scene component responsible to manage any effect layers
  58555. * in a given scene.
  58556. */
  58557. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58558. /**
  58559. * The component name helpfull to identify the component in the list of scene components.
  58560. */
  58561. readonly name: string;
  58562. /**
  58563. * The scene the component belongs to.
  58564. */
  58565. scene: Scene;
  58566. private _engine;
  58567. private _renderEffects;
  58568. private _needStencil;
  58569. private _previousStencilState;
  58570. /**
  58571. * Creates a new instance of the component for the given scene
  58572. * @param scene Defines the scene to register the component in
  58573. */
  58574. constructor(scene: Scene);
  58575. /**
  58576. * Registers the component in a given scene
  58577. */
  58578. register(): void;
  58579. /**
  58580. * Rebuilds the elements related to this component in case of
  58581. * context lost for instance.
  58582. */
  58583. rebuild(): void;
  58584. /**
  58585. * Serializes the component data to the specified json object
  58586. * @param serializationObject The object to serialize to
  58587. */
  58588. serialize(serializationObject: any): void;
  58589. /**
  58590. * Adds all the elements from the container to the scene
  58591. * @param container the container holding the elements
  58592. */
  58593. addFromContainer(container: AbstractScene): void;
  58594. /**
  58595. * Removes all the elements in the container from the scene
  58596. * @param container contains the elements to remove
  58597. * @param dispose if the removed element should be disposed (default: false)
  58598. */
  58599. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58600. /**
  58601. * Disposes the component and the associated ressources.
  58602. */
  58603. dispose(): void;
  58604. private _isReadyForMesh;
  58605. private _renderMainTexture;
  58606. private _setStencil;
  58607. private _setStencilBack;
  58608. private _draw;
  58609. private _drawCamera;
  58610. private _drawRenderingGroup;
  58611. }
  58612. }
  58613. declare module BABYLON {
  58614. /** @hidden */
  58615. export var glowMapMergePixelShader: {
  58616. name: string;
  58617. shader: string;
  58618. };
  58619. }
  58620. declare module BABYLON {
  58621. /** @hidden */
  58622. export var glowMapMergeVertexShader: {
  58623. name: string;
  58624. shader: string;
  58625. };
  58626. }
  58627. declare module BABYLON {
  58628. interface AbstractScene {
  58629. /**
  58630. * Return a the first highlight layer of the scene with a given name.
  58631. * @param name The name of the highlight layer to look for.
  58632. * @return The highlight layer if found otherwise null.
  58633. */
  58634. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58635. }
  58636. /**
  58637. * Glow layer options. This helps customizing the behaviour
  58638. * of the glow layer.
  58639. */
  58640. export interface IGlowLayerOptions {
  58641. /**
  58642. * Multiplication factor apply to the canvas size to compute the render target size
  58643. * used to generated the glowing objects (the smaller the faster).
  58644. */
  58645. mainTextureRatio: number;
  58646. /**
  58647. * Enforces a fixed size texture to ensure resize independant blur.
  58648. */
  58649. mainTextureFixedSize?: number;
  58650. /**
  58651. * How big is the kernel of the blur texture.
  58652. */
  58653. blurKernelSize: number;
  58654. /**
  58655. * The camera attached to the layer.
  58656. */
  58657. camera: Nullable<Camera>;
  58658. /**
  58659. * Enable MSAA by chosing the number of samples.
  58660. */
  58661. mainTextureSamples?: number;
  58662. /**
  58663. * The rendering group to draw the layer in.
  58664. */
  58665. renderingGroupId: number;
  58666. }
  58667. /**
  58668. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58669. *
  58670. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58671. *
  58672. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58673. */
  58674. export class GlowLayer extends EffectLayer {
  58675. /**
  58676. * Effect Name of the layer.
  58677. */
  58678. static readonly EffectName: string;
  58679. /**
  58680. * The default blur kernel size used for the glow.
  58681. */
  58682. static DefaultBlurKernelSize: number;
  58683. /**
  58684. * The default texture size ratio used for the glow.
  58685. */
  58686. static DefaultTextureRatio: number;
  58687. /**
  58688. * Sets the kernel size of the blur.
  58689. */
  58690. set blurKernelSize(value: number);
  58691. /**
  58692. * Gets the kernel size of the blur.
  58693. */
  58694. get blurKernelSize(): number;
  58695. /**
  58696. * Sets the glow intensity.
  58697. */
  58698. set intensity(value: number);
  58699. /**
  58700. * Gets the glow intensity.
  58701. */
  58702. get intensity(): number;
  58703. private _options;
  58704. private _intensity;
  58705. private _horizontalBlurPostprocess1;
  58706. private _verticalBlurPostprocess1;
  58707. private _horizontalBlurPostprocess2;
  58708. private _verticalBlurPostprocess2;
  58709. private _blurTexture1;
  58710. private _blurTexture2;
  58711. private _postProcesses1;
  58712. private _postProcesses2;
  58713. private _includedOnlyMeshes;
  58714. private _excludedMeshes;
  58715. private _meshesUsingTheirOwnMaterials;
  58716. /**
  58717. * Callback used to let the user override the color selection on a per mesh basis
  58718. */
  58719. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58720. /**
  58721. * Callback used to let the user override the texture selection on a per mesh basis
  58722. */
  58723. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58724. /**
  58725. * Instantiates a new glow Layer and references it to the scene.
  58726. * @param name The name of the layer
  58727. * @param scene The scene to use the layer in
  58728. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58729. */
  58730. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58731. /**
  58732. * Get the effect name of the layer.
  58733. * @return The effect name
  58734. */
  58735. getEffectName(): string;
  58736. /**
  58737. * Create the merge effect. This is the shader use to blit the information back
  58738. * to the main canvas at the end of the scene rendering.
  58739. */
  58740. protected _createMergeEffect(): Effect;
  58741. /**
  58742. * Creates the render target textures and post processes used in the glow layer.
  58743. */
  58744. protected _createTextureAndPostProcesses(): void;
  58745. /**
  58746. * Checks for the readiness of the element composing the layer.
  58747. * @param subMesh the mesh to check for
  58748. * @param useInstances specify wether or not to use instances to render the mesh
  58749. * @param emissiveTexture the associated emissive texture used to generate the glow
  58750. * @return true if ready otherwise, false
  58751. */
  58752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58753. /**
  58754. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58755. */
  58756. needStencil(): boolean;
  58757. /**
  58758. * Returns true if the mesh can be rendered, otherwise false.
  58759. * @param mesh The mesh to render
  58760. * @param material The material used on the mesh
  58761. * @returns true if it can be rendered otherwise false
  58762. */
  58763. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58764. /**
  58765. * Implementation specific of rendering the generating effect on the main canvas.
  58766. * @param effect The effect used to render through
  58767. */
  58768. protected _internalRender(effect: Effect): void;
  58769. /**
  58770. * Sets the required values for both the emissive texture and and the main color.
  58771. */
  58772. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58773. /**
  58774. * Returns true if the mesh should render, otherwise false.
  58775. * @param mesh The mesh to render
  58776. * @returns true if it should render otherwise false
  58777. */
  58778. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58779. /**
  58780. * Adds specific effects defines.
  58781. * @param defines The defines to add specifics to.
  58782. */
  58783. protected _addCustomEffectDefines(defines: string[]): void;
  58784. /**
  58785. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58786. * @param mesh The mesh to exclude from the glow layer
  58787. */
  58788. addExcludedMesh(mesh: Mesh): void;
  58789. /**
  58790. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58791. * @param mesh The mesh to remove
  58792. */
  58793. removeExcludedMesh(mesh: Mesh): void;
  58794. /**
  58795. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58796. * @param mesh The mesh to include in the glow layer
  58797. */
  58798. addIncludedOnlyMesh(mesh: Mesh): void;
  58799. /**
  58800. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58801. * @param mesh The mesh to remove
  58802. */
  58803. removeIncludedOnlyMesh(mesh: Mesh): void;
  58804. /**
  58805. * Determine if a given mesh will be used in the glow layer
  58806. * @param mesh The mesh to test
  58807. * @returns true if the mesh will be highlighted by the current glow layer
  58808. */
  58809. hasMesh(mesh: AbstractMesh): boolean;
  58810. /**
  58811. * Defines whether the current material of the mesh should be use to render the effect.
  58812. * @param mesh defines the current mesh to render
  58813. */
  58814. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58815. /**
  58816. * Add a mesh to be rendered through its own material and not with emissive only.
  58817. * @param mesh The mesh for which we need to use its material
  58818. */
  58819. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58820. /**
  58821. * Remove a mesh from being rendered through its own material and not with emissive only.
  58822. * @param mesh The mesh for which we need to not use its material
  58823. */
  58824. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58825. /**
  58826. * Free any resources and references associated to a mesh.
  58827. * Internal use
  58828. * @param mesh The mesh to free.
  58829. * @hidden
  58830. */
  58831. _disposeMesh(mesh: Mesh): void;
  58832. /**
  58833. * Gets the class name of the effect layer
  58834. * @returns the string with the class name of the effect layer
  58835. */
  58836. getClassName(): string;
  58837. /**
  58838. * Serializes this glow layer
  58839. * @returns a serialized glow layer object
  58840. */
  58841. serialize(): any;
  58842. /**
  58843. * Creates a Glow Layer from parsed glow layer data
  58844. * @param parsedGlowLayer defines glow layer data
  58845. * @param scene defines the current scene
  58846. * @param rootUrl defines the root URL containing the glow layer information
  58847. * @returns a parsed Glow Layer
  58848. */
  58849. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58850. }
  58851. }
  58852. declare module BABYLON {
  58853. /** @hidden */
  58854. export var glowBlurPostProcessPixelShader: {
  58855. name: string;
  58856. shader: string;
  58857. };
  58858. }
  58859. declare module BABYLON {
  58860. interface AbstractScene {
  58861. /**
  58862. * Return a the first highlight layer of the scene with a given name.
  58863. * @param name The name of the highlight layer to look for.
  58864. * @return The highlight layer if found otherwise null.
  58865. */
  58866. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58867. }
  58868. /**
  58869. * Highlight layer options. This helps customizing the behaviour
  58870. * of the highlight layer.
  58871. */
  58872. export interface IHighlightLayerOptions {
  58873. /**
  58874. * Multiplication factor apply to the canvas size to compute the render target size
  58875. * used to generated the glowing objects (the smaller the faster).
  58876. */
  58877. mainTextureRatio: number;
  58878. /**
  58879. * Enforces a fixed size texture to ensure resize independant blur.
  58880. */
  58881. mainTextureFixedSize?: number;
  58882. /**
  58883. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58884. * of the picture to blur (the smaller the faster).
  58885. */
  58886. blurTextureSizeRatio: number;
  58887. /**
  58888. * How big in texel of the blur texture is the vertical blur.
  58889. */
  58890. blurVerticalSize: number;
  58891. /**
  58892. * How big in texel of the blur texture is the horizontal blur.
  58893. */
  58894. blurHorizontalSize: number;
  58895. /**
  58896. * Alpha blending mode used to apply the blur. Default is combine.
  58897. */
  58898. alphaBlendingMode: number;
  58899. /**
  58900. * The camera attached to the layer.
  58901. */
  58902. camera: Nullable<Camera>;
  58903. /**
  58904. * Should we display highlight as a solid stroke?
  58905. */
  58906. isStroke?: boolean;
  58907. /**
  58908. * The rendering group to draw the layer in.
  58909. */
  58910. renderingGroupId: number;
  58911. }
  58912. /**
  58913. * The highlight layer Helps adding a glow effect around a mesh.
  58914. *
  58915. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58916. * glowy meshes to your scene.
  58917. *
  58918. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58919. */
  58920. export class HighlightLayer extends EffectLayer {
  58921. name: string;
  58922. /**
  58923. * Effect Name of the highlight layer.
  58924. */
  58925. static readonly EffectName: string;
  58926. /**
  58927. * The neutral color used during the preparation of the glow effect.
  58928. * This is black by default as the blend operation is a blend operation.
  58929. */
  58930. static NeutralColor: Color4;
  58931. /**
  58932. * Stencil value used for glowing meshes.
  58933. */
  58934. static GlowingMeshStencilReference: number;
  58935. /**
  58936. * Stencil value used for the other meshes in the scene.
  58937. */
  58938. static NormalMeshStencilReference: number;
  58939. /**
  58940. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58941. */
  58942. innerGlow: boolean;
  58943. /**
  58944. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58945. */
  58946. outerGlow: boolean;
  58947. /**
  58948. * Specifies the horizontal size of the blur.
  58949. */
  58950. set blurHorizontalSize(value: number);
  58951. /**
  58952. * Specifies the vertical size of the blur.
  58953. */
  58954. set blurVerticalSize(value: number);
  58955. /**
  58956. * Gets the horizontal size of the blur.
  58957. */
  58958. get blurHorizontalSize(): number;
  58959. /**
  58960. * Gets the vertical size of the blur.
  58961. */
  58962. get blurVerticalSize(): number;
  58963. /**
  58964. * An event triggered when the highlight layer is being blurred.
  58965. */
  58966. onBeforeBlurObservable: Observable<HighlightLayer>;
  58967. /**
  58968. * An event triggered when the highlight layer has been blurred.
  58969. */
  58970. onAfterBlurObservable: Observable<HighlightLayer>;
  58971. private _instanceGlowingMeshStencilReference;
  58972. private _options;
  58973. private _downSamplePostprocess;
  58974. private _horizontalBlurPostprocess;
  58975. private _verticalBlurPostprocess;
  58976. private _blurTexture;
  58977. private _meshes;
  58978. private _excludedMeshes;
  58979. /**
  58980. * Instantiates a new highlight Layer and references it to the scene..
  58981. * @param name The name of the layer
  58982. * @param scene The scene to use the layer in
  58983. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58984. */
  58985. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58986. /**
  58987. * Get the effect name of the layer.
  58988. * @return The effect name
  58989. */
  58990. getEffectName(): string;
  58991. /**
  58992. * Create the merge effect. This is the shader use to blit the information back
  58993. * to the main canvas at the end of the scene rendering.
  58994. */
  58995. protected _createMergeEffect(): Effect;
  58996. /**
  58997. * Creates the render target textures and post processes used in the highlight layer.
  58998. */
  58999. protected _createTextureAndPostProcesses(): void;
  59000. /**
  59001. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59002. */
  59003. needStencil(): boolean;
  59004. /**
  59005. * Checks for the readiness of the element composing the layer.
  59006. * @param subMesh the mesh to check for
  59007. * @param useInstances specify wether or not to use instances to render the mesh
  59008. * @param emissiveTexture the associated emissive texture used to generate the glow
  59009. * @return true if ready otherwise, false
  59010. */
  59011. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59012. /**
  59013. * Implementation specific of rendering the generating effect on the main canvas.
  59014. * @param effect The effect used to render through
  59015. */
  59016. protected _internalRender(effect: Effect): void;
  59017. /**
  59018. * Returns true if the layer contains information to display, otherwise false.
  59019. */
  59020. shouldRender(): boolean;
  59021. /**
  59022. * Returns true if the mesh should render, otherwise false.
  59023. * @param mesh The mesh to render
  59024. * @returns true if it should render otherwise false
  59025. */
  59026. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59027. /**
  59028. * Returns true if the mesh can be rendered, otherwise false.
  59029. * @param mesh The mesh to render
  59030. * @param material The material used on the mesh
  59031. * @returns true if it can be rendered otherwise false
  59032. */
  59033. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59034. /**
  59035. * Adds specific effects defines.
  59036. * @param defines The defines to add specifics to.
  59037. */
  59038. protected _addCustomEffectDefines(defines: string[]): void;
  59039. /**
  59040. * Sets the required values for both the emissive texture and and the main color.
  59041. */
  59042. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59043. /**
  59044. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59045. * @param mesh The mesh to exclude from the highlight layer
  59046. */
  59047. addExcludedMesh(mesh: Mesh): void;
  59048. /**
  59049. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59050. * @param mesh The mesh to highlight
  59051. */
  59052. removeExcludedMesh(mesh: Mesh): void;
  59053. /**
  59054. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59055. * @param mesh mesh to test
  59056. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59057. */
  59058. hasMesh(mesh: AbstractMesh): boolean;
  59059. /**
  59060. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59061. * @param mesh The mesh to highlight
  59062. * @param color The color of the highlight
  59063. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59064. */
  59065. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59066. /**
  59067. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59068. * @param mesh The mesh to highlight
  59069. */
  59070. removeMesh(mesh: Mesh): void;
  59071. /**
  59072. * Remove all the meshes currently referenced in the highlight layer
  59073. */
  59074. removeAllMeshes(): void;
  59075. /**
  59076. * Force the stencil to the normal expected value for none glowing parts
  59077. */
  59078. private _defaultStencilReference;
  59079. /**
  59080. * Free any resources and references associated to a mesh.
  59081. * Internal use
  59082. * @param mesh The mesh to free.
  59083. * @hidden
  59084. */
  59085. _disposeMesh(mesh: Mesh): void;
  59086. /**
  59087. * Dispose the highlight layer and free resources.
  59088. */
  59089. dispose(): void;
  59090. /**
  59091. * Gets the class name of the effect layer
  59092. * @returns the string with the class name of the effect layer
  59093. */
  59094. getClassName(): string;
  59095. /**
  59096. * Serializes this Highlight layer
  59097. * @returns a serialized Highlight layer object
  59098. */
  59099. serialize(): any;
  59100. /**
  59101. * Creates a Highlight layer from parsed Highlight layer data
  59102. * @param parsedHightlightLayer defines the Highlight layer data
  59103. * @param scene defines the current scene
  59104. * @param rootUrl defines the root URL containing the Highlight layer information
  59105. * @returns a parsed Highlight layer
  59106. */
  59107. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59108. }
  59109. }
  59110. declare module BABYLON {
  59111. interface AbstractScene {
  59112. /**
  59113. * The list of layers (background and foreground) of the scene
  59114. */
  59115. layers: Array<Layer>;
  59116. }
  59117. /**
  59118. * Defines the layer scene component responsible to manage any layers
  59119. * in a given scene.
  59120. */
  59121. export class LayerSceneComponent implements ISceneComponent {
  59122. /**
  59123. * The component name helpfull to identify the component in the list of scene components.
  59124. */
  59125. readonly name: string;
  59126. /**
  59127. * The scene the component belongs to.
  59128. */
  59129. scene: Scene;
  59130. private _engine;
  59131. /**
  59132. * Creates a new instance of the component for the given scene
  59133. * @param scene Defines the scene to register the component in
  59134. */
  59135. constructor(scene: Scene);
  59136. /**
  59137. * Registers the component in a given scene
  59138. */
  59139. register(): void;
  59140. /**
  59141. * Rebuilds the elements related to this component in case of
  59142. * context lost for instance.
  59143. */
  59144. rebuild(): void;
  59145. /**
  59146. * Disposes the component and the associated ressources.
  59147. */
  59148. dispose(): void;
  59149. private _draw;
  59150. private _drawCameraPredicate;
  59151. private _drawCameraBackground;
  59152. private _drawCameraForeground;
  59153. private _drawRenderTargetPredicate;
  59154. private _drawRenderTargetBackground;
  59155. private _drawRenderTargetForeground;
  59156. /**
  59157. * Adds all the elements from the container to the scene
  59158. * @param container the container holding the elements
  59159. */
  59160. addFromContainer(container: AbstractScene): void;
  59161. /**
  59162. * Removes all the elements in the container from the scene
  59163. * @param container contains the elements to remove
  59164. * @param dispose if the removed element should be disposed (default: false)
  59165. */
  59166. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59167. }
  59168. }
  59169. declare module BABYLON {
  59170. /** @hidden */
  59171. export var layerPixelShader: {
  59172. name: string;
  59173. shader: string;
  59174. };
  59175. }
  59176. declare module BABYLON {
  59177. /** @hidden */
  59178. export var layerVertexShader: {
  59179. name: string;
  59180. shader: string;
  59181. };
  59182. }
  59183. declare module BABYLON {
  59184. /**
  59185. * This represents a full screen 2d layer.
  59186. * This can be useful to display a picture in the background of your scene for instance.
  59187. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59188. */
  59189. export class Layer {
  59190. /**
  59191. * Define the name of the layer.
  59192. */
  59193. name: string;
  59194. /**
  59195. * Define the texture the layer should display.
  59196. */
  59197. texture: Nullable<Texture>;
  59198. /**
  59199. * Is the layer in background or foreground.
  59200. */
  59201. isBackground: boolean;
  59202. /**
  59203. * Define the color of the layer (instead of texture).
  59204. */
  59205. color: Color4;
  59206. /**
  59207. * Define the scale of the layer in order to zoom in out of the texture.
  59208. */
  59209. scale: Vector2;
  59210. /**
  59211. * Define an offset for the layer in order to shift the texture.
  59212. */
  59213. offset: Vector2;
  59214. /**
  59215. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59216. */
  59217. alphaBlendingMode: number;
  59218. /**
  59219. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59220. * Alpha test will not mix with the background color in case of transparency.
  59221. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59222. */
  59223. alphaTest: boolean;
  59224. /**
  59225. * Define a mask to restrict the layer to only some of the scene cameras.
  59226. */
  59227. layerMask: number;
  59228. /**
  59229. * Define the list of render target the layer is visible into.
  59230. */
  59231. renderTargetTextures: RenderTargetTexture[];
  59232. /**
  59233. * Define if the layer is only used in renderTarget or if it also
  59234. * renders in the main frame buffer of the canvas.
  59235. */
  59236. renderOnlyInRenderTargetTextures: boolean;
  59237. private _scene;
  59238. private _vertexBuffers;
  59239. private _indexBuffer;
  59240. private _effect;
  59241. private _previousDefines;
  59242. /**
  59243. * An event triggered when the layer is disposed.
  59244. */
  59245. onDisposeObservable: Observable<Layer>;
  59246. private _onDisposeObserver;
  59247. /**
  59248. * Back compatibility with callback before the onDisposeObservable existed.
  59249. * The set callback will be triggered when the layer has been disposed.
  59250. */
  59251. set onDispose(callback: () => void);
  59252. /**
  59253. * An event triggered before rendering the scene
  59254. */
  59255. onBeforeRenderObservable: Observable<Layer>;
  59256. private _onBeforeRenderObserver;
  59257. /**
  59258. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59259. * The set callback will be triggered just before rendering the layer.
  59260. */
  59261. set onBeforeRender(callback: () => void);
  59262. /**
  59263. * An event triggered after rendering the scene
  59264. */
  59265. onAfterRenderObservable: Observable<Layer>;
  59266. private _onAfterRenderObserver;
  59267. /**
  59268. * Back compatibility with callback before the onAfterRenderObservable existed.
  59269. * The set callback will be triggered just after rendering the layer.
  59270. */
  59271. set onAfterRender(callback: () => void);
  59272. /**
  59273. * Instantiates a new layer.
  59274. * This represents a full screen 2d layer.
  59275. * This can be useful to display a picture in the background of your scene for instance.
  59276. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59277. * @param name Define the name of the layer in the scene
  59278. * @param imgUrl Define the url of the texture to display in the layer
  59279. * @param scene Define the scene the layer belongs to
  59280. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59281. * @param color Defines a color for the layer
  59282. */
  59283. constructor(
  59284. /**
  59285. * Define the name of the layer.
  59286. */
  59287. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59288. private _createIndexBuffer;
  59289. /** @hidden */
  59290. _rebuild(): void;
  59291. /**
  59292. * Renders the layer in the scene.
  59293. */
  59294. render(): void;
  59295. /**
  59296. * Disposes and releases the associated ressources.
  59297. */
  59298. dispose(): void;
  59299. }
  59300. }
  59301. declare module BABYLON {
  59302. /** @hidden */
  59303. export var lensFlarePixelShader: {
  59304. name: string;
  59305. shader: string;
  59306. };
  59307. }
  59308. declare module BABYLON {
  59309. /** @hidden */
  59310. export var lensFlareVertexShader: {
  59311. name: string;
  59312. shader: string;
  59313. };
  59314. }
  59315. declare module BABYLON {
  59316. /**
  59317. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59318. * It is usually composed of several `lensFlare`.
  59319. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59320. */
  59321. export class LensFlareSystem {
  59322. /**
  59323. * Define the name of the lens flare system
  59324. */
  59325. name: string;
  59326. /**
  59327. * List of lens flares used in this system.
  59328. */
  59329. lensFlares: LensFlare[];
  59330. /**
  59331. * Define a limit from the border the lens flare can be visible.
  59332. */
  59333. borderLimit: number;
  59334. /**
  59335. * Define a viewport border we do not want to see the lens flare in.
  59336. */
  59337. viewportBorder: number;
  59338. /**
  59339. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59340. */
  59341. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59342. /**
  59343. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59344. */
  59345. layerMask: number;
  59346. /**
  59347. * Define the id of the lens flare system in the scene.
  59348. * (equal to name by default)
  59349. */
  59350. id: string;
  59351. private _scene;
  59352. private _emitter;
  59353. private _vertexBuffers;
  59354. private _indexBuffer;
  59355. private _effect;
  59356. private _positionX;
  59357. private _positionY;
  59358. private _isEnabled;
  59359. /** @hidden */
  59360. static _SceneComponentInitialization: (scene: Scene) => void;
  59361. /**
  59362. * Instantiates a lens flare system.
  59363. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59364. * It is usually composed of several `lensFlare`.
  59365. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59366. * @param name Define the name of the lens flare system in the scene
  59367. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59368. * @param scene Define the scene the lens flare system belongs to
  59369. */
  59370. constructor(
  59371. /**
  59372. * Define the name of the lens flare system
  59373. */
  59374. name: string, emitter: any, scene: Scene);
  59375. /**
  59376. * Define if the lens flare system is enabled.
  59377. */
  59378. get isEnabled(): boolean;
  59379. set isEnabled(value: boolean);
  59380. /**
  59381. * Get the scene the effects belongs to.
  59382. * @returns the scene holding the lens flare system
  59383. */
  59384. getScene(): Scene;
  59385. /**
  59386. * Get the emitter of the lens flare system.
  59387. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59388. * @returns the emitter of the lens flare system
  59389. */
  59390. getEmitter(): any;
  59391. /**
  59392. * Set the emitter of the lens flare system.
  59393. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59394. * @param newEmitter Define the new emitter of the system
  59395. */
  59396. setEmitter(newEmitter: any): void;
  59397. /**
  59398. * Get the lens flare system emitter position.
  59399. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59400. * @returns the position
  59401. */
  59402. getEmitterPosition(): Vector3;
  59403. /**
  59404. * @hidden
  59405. */
  59406. computeEffectivePosition(globalViewport: Viewport): boolean;
  59407. /** @hidden */
  59408. _isVisible(): boolean;
  59409. /**
  59410. * @hidden
  59411. */
  59412. render(): boolean;
  59413. /**
  59414. * Dispose and release the lens flare with its associated resources.
  59415. */
  59416. dispose(): void;
  59417. /**
  59418. * Parse a lens flare system from a JSON repressentation
  59419. * @param parsedLensFlareSystem Define the JSON to parse
  59420. * @param scene Define the scene the parsed system should be instantiated in
  59421. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59422. * @returns the parsed system
  59423. */
  59424. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59425. /**
  59426. * Serialize the current Lens Flare System into a JSON representation.
  59427. * @returns the serialized JSON
  59428. */
  59429. serialize(): any;
  59430. }
  59431. }
  59432. declare module BABYLON {
  59433. /**
  59434. * This represents one of the lens effect in a `lensFlareSystem`.
  59435. * It controls one of the indiviual texture used in the effect.
  59436. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59437. */
  59438. export class LensFlare {
  59439. /**
  59440. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59441. */
  59442. size: number;
  59443. /**
  59444. * 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.
  59445. */
  59446. position: number;
  59447. /**
  59448. * Define the lens color.
  59449. */
  59450. color: Color3;
  59451. /**
  59452. * Define the lens texture.
  59453. */
  59454. texture: Nullable<Texture>;
  59455. /**
  59456. * Define the alpha mode to render this particular lens.
  59457. */
  59458. alphaMode: number;
  59459. private _system;
  59460. /**
  59461. * Creates a new Lens Flare.
  59462. * This represents one of the lens effect in a `lensFlareSystem`.
  59463. * It controls one of the indiviual texture used in the effect.
  59464. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59465. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59466. * @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.
  59467. * @param color Define the lens color
  59468. * @param imgUrl Define the lens texture url
  59469. * @param system Define the `lensFlareSystem` this flare is part of
  59470. * @returns The newly created Lens Flare
  59471. */
  59472. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59473. /**
  59474. * Instantiates a new Lens Flare.
  59475. * This represents one of the lens effect in a `lensFlareSystem`.
  59476. * It controls one of the indiviual texture used in the effect.
  59477. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59478. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59479. * @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.
  59480. * @param color Define the lens color
  59481. * @param imgUrl Define the lens texture url
  59482. * @param system Define the `lensFlareSystem` this flare is part of
  59483. */
  59484. constructor(
  59485. /**
  59486. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59487. */
  59488. size: number,
  59489. /**
  59490. * 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.
  59491. */
  59492. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59493. /**
  59494. * Dispose and release the lens flare with its associated resources.
  59495. */
  59496. dispose(): void;
  59497. }
  59498. }
  59499. declare module BABYLON {
  59500. interface AbstractScene {
  59501. /**
  59502. * The list of lens flare system added to the scene
  59503. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59504. */
  59505. lensFlareSystems: Array<LensFlareSystem>;
  59506. /**
  59507. * Removes the given lens flare system from this scene.
  59508. * @param toRemove The lens flare system to remove
  59509. * @returns The index of the removed lens flare system
  59510. */
  59511. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59512. /**
  59513. * Adds the given lens flare system to this scene
  59514. * @param newLensFlareSystem The lens flare system to add
  59515. */
  59516. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59517. /**
  59518. * Gets a lens flare system using its name
  59519. * @param name defines the name to look for
  59520. * @returns the lens flare system or null if not found
  59521. */
  59522. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59523. /**
  59524. * Gets a lens flare system using its id
  59525. * @param id defines the id to look for
  59526. * @returns the lens flare system or null if not found
  59527. */
  59528. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59529. }
  59530. /**
  59531. * Defines the lens flare scene component responsible to manage any lens flares
  59532. * in a given scene.
  59533. */
  59534. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59535. /**
  59536. * The component name helpfull to identify the component in the list of scene components.
  59537. */
  59538. readonly name: string;
  59539. /**
  59540. * The scene the component belongs to.
  59541. */
  59542. scene: Scene;
  59543. /**
  59544. * Creates a new instance of the component for the given scene
  59545. * @param scene Defines the scene to register the component in
  59546. */
  59547. constructor(scene: Scene);
  59548. /**
  59549. * Registers the component in a given scene
  59550. */
  59551. register(): void;
  59552. /**
  59553. * Rebuilds the elements related to this component in case of
  59554. * context lost for instance.
  59555. */
  59556. rebuild(): void;
  59557. /**
  59558. * Adds all the elements from the container to the scene
  59559. * @param container the container holding the elements
  59560. */
  59561. addFromContainer(container: AbstractScene): void;
  59562. /**
  59563. * Removes all the elements in the container from the scene
  59564. * @param container contains the elements to remove
  59565. * @param dispose if the removed element should be disposed (default: false)
  59566. */
  59567. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59568. /**
  59569. * Serializes the component data to the specified json object
  59570. * @param serializationObject The object to serialize to
  59571. */
  59572. serialize(serializationObject: any): void;
  59573. /**
  59574. * Disposes the component and the associated ressources.
  59575. */
  59576. dispose(): void;
  59577. private _draw;
  59578. }
  59579. }
  59580. declare module BABYLON {
  59581. /** @hidden */
  59582. export var depthPixelShader: {
  59583. name: string;
  59584. shader: string;
  59585. };
  59586. }
  59587. declare module BABYLON {
  59588. /** @hidden */
  59589. export var depthVertexShader: {
  59590. name: string;
  59591. shader: string;
  59592. };
  59593. }
  59594. declare module BABYLON {
  59595. /**
  59596. * This represents a depth renderer in Babylon.
  59597. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59598. */
  59599. export class DepthRenderer {
  59600. private _scene;
  59601. private _depthMap;
  59602. private _effect;
  59603. private readonly _storeNonLinearDepth;
  59604. private readonly _clearColor;
  59605. /** Get if the depth renderer is using packed depth or not */
  59606. readonly isPacked: boolean;
  59607. private _cachedDefines;
  59608. private _camera;
  59609. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59610. enabled: boolean;
  59611. /**
  59612. * Specifiess that the depth renderer will only be used within
  59613. * the camera it is created for.
  59614. * This can help forcing its rendering during the camera processing.
  59615. */
  59616. useOnlyInActiveCamera: boolean;
  59617. /** @hidden */
  59618. static _SceneComponentInitialization: (scene: Scene) => void;
  59619. /**
  59620. * Instantiates a depth renderer
  59621. * @param scene The scene the renderer belongs to
  59622. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59623. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59624. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59625. */
  59626. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59627. /**
  59628. * Creates the depth rendering effect and checks if the effect is ready.
  59629. * @param subMesh The submesh to be used to render the depth map of
  59630. * @param useInstances If multiple world instances should be used
  59631. * @returns if the depth renderer is ready to render the depth map
  59632. */
  59633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59634. /**
  59635. * Gets the texture which the depth map will be written to.
  59636. * @returns The depth map texture
  59637. */
  59638. getDepthMap(): RenderTargetTexture;
  59639. /**
  59640. * Disposes of the depth renderer.
  59641. */
  59642. dispose(): void;
  59643. }
  59644. }
  59645. declare module BABYLON {
  59646. /** @hidden */
  59647. export var minmaxReduxPixelShader: {
  59648. name: string;
  59649. shader: string;
  59650. };
  59651. }
  59652. declare module BABYLON {
  59653. /**
  59654. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59655. * and maximum values from all values of the texture.
  59656. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59657. * The source values are read from the red channel of the texture.
  59658. */
  59659. export class MinMaxReducer {
  59660. /**
  59661. * Observable triggered when the computation has been performed
  59662. */
  59663. onAfterReductionPerformed: Observable<{
  59664. min: number;
  59665. max: number;
  59666. }>;
  59667. protected _camera: Camera;
  59668. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59669. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59670. protected _postProcessManager: PostProcessManager;
  59671. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59672. protected _forceFullscreenViewport: boolean;
  59673. /**
  59674. * Creates a min/max reducer
  59675. * @param camera The camera to use for the post processes
  59676. */
  59677. constructor(camera: Camera);
  59678. /**
  59679. * Gets the texture used to read the values from.
  59680. */
  59681. get sourceTexture(): Nullable<RenderTargetTexture>;
  59682. /**
  59683. * Sets the source texture to read the values from.
  59684. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59685. * because in such textures '1' value must not be taken into account to compute the maximum
  59686. * as this value is used to clear the texture.
  59687. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59688. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59689. * @param depthRedux Indicates if the texture is a depth texture or not
  59690. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59691. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59692. */
  59693. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59694. /**
  59695. * Defines the refresh rate of the computation.
  59696. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59697. */
  59698. get refreshRate(): number;
  59699. set refreshRate(value: number);
  59700. protected _activated: boolean;
  59701. /**
  59702. * Gets the activation status of the reducer
  59703. */
  59704. get activated(): boolean;
  59705. /**
  59706. * Activates the reduction computation.
  59707. * When activated, the observers registered in onAfterReductionPerformed are
  59708. * called after the compuation is performed
  59709. */
  59710. activate(): void;
  59711. /**
  59712. * Deactivates the reduction computation.
  59713. */
  59714. deactivate(): void;
  59715. /**
  59716. * Disposes the min/max reducer
  59717. * @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.
  59718. */
  59719. dispose(disposeAll?: boolean): void;
  59720. }
  59721. }
  59722. declare module BABYLON {
  59723. /**
  59724. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59725. */
  59726. export class DepthReducer extends MinMaxReducer {
  59727. private _depthRenderer;
  59728. private _depthRendererId;
  59729. /**
  59730. * Gets the depth renderer used for the computation.
  59731. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59732. */
  59733. get depthRenderer(): Nullable<DepthRenderer>;
  59734. /**
  59735. * Creates a depth reducer
  59736. * @param camera The camera used to render the depth texture
  59737. */
  59738. constructor(camera: Camera);
  59739. /**
  59740. * Sets the depth renderer to use to generate the depth map
  59741. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59742. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59743. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59744. */
  59745. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59746. /** @hidden */
  59747. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59748. /**
  59749. * Activates the reduction computation.
  59750. * When activated, the observers registered in onAfterReductionPerformed are
  59751. * called after the compuation is performed
  59752. */
  59753. activate(): void;
  59754. /**
  59755. * Deactivates the reduction computation.
  59756. */
  59757. deactivate(): void;
  59758. /**
  59759. * Disposes the depth reducer
  59760. * @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.
  59761. */
  59762. dispose(disposeAll?: boolean): void;
  59763. }
  59764. }
  59765. declare module BABYLON {
  59766. /**
  59767. * A CSM implementation allowing casting shadows on large scenes.
  59768. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59769. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59770. */
  59771. export class CascadedShadowGenerator extends ShadowGenerator {
  59772. private static readonly frustumCornersNDCSpace;
  59773. /**
  59774. * Name of the CSM class
  59775. */
  59776. static CLASSNAME: string;
  59777. /**
  59778. * Defines the default number of cascades used by the CSM.
  59779. */
  59780. static readonly DEFAULT_CASCADES_COUNT: number;
  59781. /**
  59782. * Defines the minimum number of cascades used by the CSM.
  59783. */
  59784. static readonly MIN_CASCADES_COUNT: number;
  59785. /**
  59786. * Defines the maximum number of cascades used by the CSM.
  59787. */
  59788. static readonly MAX_CASCADES_COUNT: number;
  59789. protected _validateFilter(filter: number): number;
  59790. /**
  59791. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59792. */
  59793. penumbraDarkness: number;
  59794. private _numCascades;
  59795. /**
  59796. * Gets or set the number of cascades used by the CSM.
  59797. */
  59798. get numCascades(): number;
  59799. set numCascades(value: number);
  59800. /**
  59801. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59802. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59803. */
  59804. stabilizeCascades: boolean;
  59805. private _freezeShadowCastersBoundingInfo;
  59806. private _freezeShadowCastersBoundingInfoObservable;
  59807. /**
  59808. * Enables or disables the shadow casters bounding info computation.
  59809. * If your shadow casters don't move, you can disable this feature.
  59810. * If it is enabled, the bounding box computation is done every frame.
  59811. */
  59812. get freezeShadowCastersBoundingInfo(): boolean;
  59813. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59814. private _scbiMin;
  59815. private _scbiMax;
  59816. protected _computeShadowCastersBoundingInfo(): void;
  59817. protected _shadowCastersBoundingInfo: BoundingInfo;
  59818. /**
  59819. * Gets or sets the shadow casters bounding info.
  59820. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59821. * so that the system won't overwrite the bounds you provide
  59822. */
  59823. get shadowCastersBoundingInfo(): BoundingInfo;
  59824. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59825. protected _breaksAreDirty: boolean;
  59826. protected _minDistance: number;
  59827. protected _maxDistance: number;
  59828. /**
  59829. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59830. *
  59831. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59832. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59833. * @param min minimal distance for the breaks (default to 0.)
  59834. * @param max maximal distance for the breaks (default to 1.)
  59835. */
  59836. setMinMaxDistance(min: number, max: number): void;
  59837. /** Gets the minimal distance used in the cascade break computation */
  59838. get minDistance(): number;
  59839. /** Gets the maximal distance used in the cascade break computation */
  59840. get maxDistance(): number;
  59841. /**
  59842. * Gets the class name of that object
  59843. * @returns "CascadedShadowGenerator"
  59844. */
  59845. getClassName(): string;
  59846. private _cascadeMinExtents;
  59847. private _cascadeMaxExtents;
  59848. /**
  59849. * Gets a cascade minimum extents
  59850. * @param cascadeIndex index of the cascade
  59851. * @returns the minimum cascade extents
  59852. */
  59853. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59854. /**
  59855. * Gets a cascade maximum extents
  59856. * @param cascadeIndex index of the cascade
  59857. * @returns the maximum cascade extents
  59858. */
  59859. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59860. private _cascades;
  59861. private _currentLayer;
  59862. private _viewSpaceFrustumsZ;
  59863. private _viewMatrices;
  59864. private _projectionMatrices;
  59865. private _transformMatrices;
  59866. private _transformMatricesAsArray;
  59867. private _frustumLengths;
  59868. private _lightSizeUVCorrection;
  59869. private _depthCorrection;
  59870. private _frustumCornersWorldSpace;
  59871. private _frustumCenter;
  59872. private _shadowCameraPos;
  59873. private _shadowMaxZ;
  59874. /**
  59875. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59876. * It defaults to camera.maxZ
  59877. */
  59878. get shadowMaxZ(): number;
  59879. /**
  59880. * Sets the shadow max z distance.
  59881. */
  59882. set shadowMaxZ(value: number);
  59883. protected _debug: boolean;
  59884. /**
  59885. * Gets or sets the debug flag.
  59886. * When enabled, the cascades are materialized by different colors on the screen.
  59887. */
  59888. get debug(): boolean;
  59889. set debug(dbg: boolean);
  59890. private _depthClamp;
  59891. /**
  59892. * Gets or sets the depth clamping value.
  59893. *
  59894. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59895. * to account for the shadow casters far away.
  59896. *
  59897. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59898. */
  59899. get depthClamp(): boolean;
  59900. set depthClamp(value: boolean);
  59901. private _cascadeBlendPercentage;
  59902. /**
  59903. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59904. * It defaults to 0.1 (10% blending).
  59905. */
  59906. get cascadeBlendPercentage(): number;
  59907. set cascadeBlendPercentage(value: number);
  59908. private _lambda;
  59909. /**
  59910. * Gets or set the lambda parameter.
  59911. * This parameter is used to split the camera frustum and create the cascades.
  59912. * 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.
  59913. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59914. */
  59915. get lambda(): number;
  59916. set lambda(value: number);
  59917. /**
  59918. * Gets the view matrix corresponding to a given cascade
  59919. * @param cascadeNum cascade to retrieve the view matrix from
  59920. * @returns the cascade view matrix
  59921. */
  59922. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59923. /**
  59924. * Gets the projection matrix corresponding to a given cascade
  59925. * @param cascadeNum cascade to retrieve the projection matrix from
  59926. * @returns the cascade projection matrix
  59927. */
  59928. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59929. /**
  59930. * Gets the transformation matrix corresponding to a given cascade
  59931. * @param cascadeNum cascade to retrieve the transformation matrix from
  59932. * @returns the cascade transformation matrix
  59933. */
  59934. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59935. private _depthRenderer;
  59936. /**
  59937. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59938. *
  59939. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59940. *
  59941. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59942. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59943. * @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
  59944. */
  59945. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59946. private _depthReducer;
  59947. private _autoCalcDepthBounds;
  59948. /**
  59949. * Gets or sets the autoCalcDepthBounds property.
  59950. *
  59951. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59952. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59953. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59954. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59955. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59956. */
  59957. get autoCalcDepthBounds(): boolean;
  59958. set autoCalcDepthBounds(value: boolean);
  59959. /**
  59960. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59961. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59962. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59963. * for setting the refresh rate on the renderer yourself!
  59964. */
  59965. get autoCalcDepthBoundsRefreshRate(): number;
  59966. set autoCalcDepthBoundsRefreshRate(value: number);
  59967. /**
  59968. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59969. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59970. * you change the camera near/far planes!
  59971. */
  59972. splitFrustum(): void;
  59973. private _splitFrustum;
  59974. private _computeMatrices;
  59975. private _computeFrustumInWorldSpace;
  59976. private _computeCascadeFrustum;
  59977. /**
  59978. * Support test.
  59979. */
  59980. static get IsSupported(): boolean;
  59981. /** @hidden */
  59982. static _SceneComponentInitialization: (scene: Scene) => void;
  59983. /**
  59984. * Creates a Cascaded Shadow Generator object.
  59985. * A ShadowGenerator is the required tool to use the shadows.
  59986. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59987. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59988. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59989. * @param light The directional light object generating the shadows.
  59990. * @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.
  59991. */
  59992. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59993. protected _initializeGenerator(): void;
  59994. protected _createTargetRenderTexture(): void;
  59995. protected _initializeShadowMap(): void;
  59996. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59997. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59998. /**
  59999. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60000. * @param defines Defines of the material we want to update
  60001. * @param lightIndex Index of the light in the enabled light list of the material
  60002. */
  60003. prepareDefines(defines: any, lightIndex: number): void;
  60004. /**
  60005. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60006. * defined in the generator but impacting the effect).
  60007. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60008. * @param effect The effect we are binfing the information for
  60009. */
  60010. bindShadowLight(lightIndex: string, effect: Effect): void;
  60011. /**
  60012. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60013. * (eq to view projection * shadow projection matrices)
  60014. * @returns The transform matrix used to create the shadow map
  60015. */
  60016. getTransformMatrix(): Matrix;
  60017. /**
  60018. * Disposes the ShadowGenerator.
  60019. * Returns nothing.
  60020. */
  60021. dispose(): void;
  60022. /**
  60023. * Serializes the shadow generator setup to a json object.
  60024. * @returns The serialized JSON object
  60025. */
  60026. serialize(): any;
  60027. /**
  60028. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60029. * @param parsedShadowGenerator The JSON object to parse
  60030. * @param scene The scene to create the shadow map for
  60031. * @returns The parsed shadow generator
  60032. */
  60033. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60034. }
  60035. }
  60036. declare module BABYLON {
  60037. /**
  60038. * Defines the shadow generator component responsible to manage any shadow generators
  60039. * in a given scene.
  60040. */
  60041. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60042. /**
  60043. * The component name helpfull to identify the component in the list of scene components.
  60044. */
  60045. readonly name: string;
  60046. /**
  60047. * The scene the component belongs to.
  60048. */
  60049. scene: Scene;
  60050. /**
  60051. * Creates a new instance of the component for the given scene
  60052. * @param scene Defines the scene to register the component in
  60053. */
  60054. constructor(scene: Scene);
  60055. /**
  60056. * Registers the component in a given scene
  60057. */
  60058. register(): void;
  60059. /**
  60060. * Rebuilds the elements related to this component in case of
  60061. * context lost for instance.
  60062. */
  60063. rebuild(): void;
  60064. /**
  60065. * Serializes the component data to the specified json object
  60066. * @param serializationObject The object to serialize to
  60067. */
  60068. serialize(serializationObject: any): void;
  60069. /**
  60070. * Adds all the elements from the container to the scene
  60071. * @param container the container holding the elements
  60072. */
  60073. addFromContainer(container: AbstractScene): void;
  60074. /**
  60075. * Removes all the elements in the container from the scene
  60076. * @param container contains the elements to remove
  60077. * @param dispose if the removed element should be disposed (default: false)
  60078. */
  60079. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60080. /**
  60081. * Rebuilds the elements related to this component in case of
  60082. * context lost for instance.
  60083. */
  60084. dispose(): void;
  60085. private _gatherRenderTargets;
  60086. }
  60087. }
  60088. declare module BABYLON {
  60089. /**
  60090. * A point light is a light defined by an unique point in world space.
  60091. * The light is emitted in every direction from this point.
  60092. * A good example of a point light is a standard light bulb.
  60093. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60094. */
  60095. export class PointLight extends ShadowLight {
  60096. private _shadowAngle;
  60097. /**
  60098. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60099. * This specifies what angle the shadow will use to be created.
  60100. *
  60101. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60102. */
  60103. get shadowAngle(): number;
  60104. /**
  60105. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60106. * This specifies what angle the shadow will use to be created.
  60107. *
  60108. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60109. */
  60110. set shadowAngle(value: number);
  60111. /**
  60112. * Gets the direction if it has been set.
  60113. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60114. */
  60115. get direction(): Vector3;
  60116. /**
  60117. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60118. */
  60119. set direction(value: Vector3);
  60120. /**
  60121. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60122. * A PointLight emits the light in every direction.
  60123. * It can cast shadows.
  60124. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60125. * ```javascript
  60126. * var pointLight = new PointLight("pl", camera.position, scene);
  60127. * ```
  60128. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60129. * @param name The light friendly name
  60130. * @param position The position of the point light in the scene
  60131. * @param scene The scene the lights belongs to
  60132. */
  60133. constructor(name: string, position: Vector3, scene: Scene);
  60134. /**
  60135. * Returns the string "PointLight"
  60136. * @returns the class name
  60137. */
  60138. getClassName(): string;
  60139. /**
  60140. * Returns the integer 0.
  60141. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60142. */
  60143. getTypeID(): number;
  60144. /**
  60145. * Specifies wether or not the shadowmap should be a cube texture.
  60146. * @returns true if the shadowmap needs to be a cube texture.
  60147. */
  60148. needCube(): boolean;
  60149. /**
  60150. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60151. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60152. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60153. */
  60154. getShadowDirection(faceIndex?: number): Vector3;
  60155. /**
  60156. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60157. * - fov = PI / 2
  60158. * - aspect ratio : 1.0
  60159. * - z-near and far equal to the active camera minZ and maxZ.
  60160. * Returns the PointLight.
  60161. */
  60162. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60163. protected _buildUniformLayout(): void;
  60164. /**
  60165. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60166. * @param effect The effect to update
  60167. * @param lightIndex The index of the light in the effect to update
  60168. * @returns The point light
  60169. */
  60170. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60171. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60172. /**
  60173. * Prepares the list of defines specific to the light type.
  60174. * @param defines the list of defines
  60175. * @param lightIndex defines the index of the light for the effect
  60176. */
  60177. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60178. }
  60179. }
  60180. declare module BABYLON {
  60181. /**
  60182. * Header information of HDR texture files.
  60183. */
  60184. export interface HDRInfo {
  60185. /**
  60186. * The height of the texture in pixels.
  60187. */
  60188. height: number;
  60189. /**
  60190. * The width of the texture in pixels.
  60191. */
  60192. width: number;
  60193. /**
  60194. * The index of the beginning of the data in the binary file.
  60195. */
  60196. dataPosition: number;
  60197. }
  60198. /**
  60199. * This groups tools to convert HDR texture to native colors array.
  60200. */
  60201. export class HDRTools {
  60202. private static Ldexp;
  60203. private static Rgbe2float;
  60204. private static readStringLine;
  60205. /**
  60206. * Reads header information from an RGBE texture stored in a native array.
  60207. * More information on this format are available here:
  60208. * https://en.wikipedia.org/wiki/RGBE_image_format
  60209. *
  60210. * @param uint8array The binary file stored in native array.
  60211. * @return The header information.
  60212. */
  60213. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60214. /**
  60215. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60216. * This RGBE texture needs to store the information as a panorama.
  60217. *
  60218. * More information on this format are available here:
  60219. * https://en.wikipedia.org/wiki/RGBE_image_format
  60220. *
  60221. * @param buffer The binary file stored in an array buffer.
  60222. * @param size The expected size of the extracted cubemap.
  60223. * @return The Cube Map information.
  60224. */
  60225. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60226. /**
  60227. * Returns the pixels data extracted from an RGBE texture.
  60228. * This pixels will be stored left to right up to down in the R G B order in one array.
  60229. *
  60230. * More information on this format are available here:
  60231. * https://en.wikipedia.org/wiki/RGBE_image_format
  60232. *
  60233. * @param uint8array The binary file stored in an array buffer.
  60234. * @param hdrInfo The header information of the file.
  60235. * @return The pixels data in RGB right to left up to down order.
  60236. */
  60237. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60238. private static RGBE_ReadPixels_RLE;
  60239. private static RGBE_ReadPixels_NOT_RLE;
  60240. }
  60241. }
  60242. declare module BABYLON {
  60243. /**
  60244. * Effect Render Options
  60245. */
  60246. export interface IEffectRendererOptions {
  60247. /**
  60248. * Defines the vertices positions.
  60249. */
  60250. positions?: number[];
  60251. /**
  60252. * Defines the indices.
  60253. */
  60254. indices?: number[];
  60255. }
  60256. /**
  60257. * Helper class to render one or more effects.
  60258. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60259. */
  60260. export class EffectRenderer {
  60261. private engine;
  60262. private static _DefaultOptions;
  60263. private _vertexBuffers;
  60264. private _indexBuffer;
  60265. private _fullscreenViewport;
  60266. /**
  60267. * Creates an effect renderer
  60268. * @param engine the engine to use for rendering
  60269. * @param options defines the options of the effect renderer
  60270. */
  60271. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60272. /**
  60273. * Sets the current viewport in normalized coordinates 0-1
  60274. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60275. */
  60276. setViewport(viewport?: Viewport): void;
  60277. /**
  60278. * Binds the embedded attributes buffer to the effect.
  60279. * @param effect Defines the effect to bind the attributes for
  60280. */
  60281. bindBuffers(effect: Effect): void;
  60282. /**
  60283. * Sets the current effect wrapper to use during draw.
  60284. * The effect needs to be ready before calling this api.
  60285. * This also sets the default full screen position attribute.
  60286. * @param effectWrapper Defines the effect to draw with
  60287. */
  60288. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60289. /**
  60290. * Restores engine states
  60291. */
  60292. restoreStates(): void;
  60293. /**
  60294. * Draws a full screen quad.
  60295. */
  60296. draw(): void;
  60297. private isRenderTargetTexture;
  60298. /**
  60299. * renders one or more effects to a specified texture
  60300. * @param effectWrapper the effect to renderer
  60301. * @param outputTexture texture to draw to, if null it will render to the screen.
  60302. */
  60303. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60304. /**
  60305. * Disposes of the effect renderer
  60306. */
  60307. dispose(): void;
  60308. }
  60309. /**
  60310. * Options to create an EffectWrapper
  60311. */
  60312. interface EffectWrapperCreationOptions {
  60313. /**
  60314. * Engine to use to create the effect
  60315. */
  60316. engine: ThinEngine;
  60317. /**
  60318. * Fragment shader for the effect
  60319. */
  60320. fragmentShader: string;
  60321. /**
  60322. * Use the shader store instead of direct source code
  60323. */
  60324. useShaderStore?: boolean;
  60325. /**
  60326. * Vertex shader for the effect
  60327. */
  60328. vertexShader?: string;
  60329. /**
  60330. * Attributes to use in the shader
  60331. */
  60332. attributeNames?: Array<string>;
  60333. /**
  60334. * Uniforms to use in the shader
  60335. */
  60336. uniformNames?: Array<string>;
  60337. /**
  60338. * Texture sampler names to use in the shader
  60339. */
  60340. samplerNames?: Array<string>;
  60341. /**
  60342. * Defines to use in the shader
  60343. */
  60344. defines?: Array<string>;
  60345. /**
  60346. * Callback when effect is compiled
  60347. */
  60348. onCompiled?: Nullable<(effect: Effect) => void>;
  60349. /**
  60350. * The friendly name of the effect displayed in Spector.
  60351. */
  60352. name?: string;
  60353. }
  60354. /**
  60355. * Wraps an effect to be used for rendering
  60356. */
  60357. export class EffectWrapper {
  60358. /**
  60359. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60360. */
  60361. onApplyObservable: Observable<{}>;
  60362. /**
  60363. * The underlying effect
  60364. */
  60365. effect: Effect;
  60366. /**
  60367. * Creates an effect to be renderer
  60368. * @param creationOptions options to create the effect
  60369. */
  60370. constructor(creationOptions: EffectWrapperCreationOptions);
  60371. /**
  60372. * Disposes of the effect wrapper
  60373. */
  60374. dispose(): void;
  60375. }
  60376. }
  60377. declare module BABYLON {
  60378. /** @hidden */
  60379. export var hdrFilteringVertexShader: {
  60380. name: string;
  60381. shader: string;
  60382. };
  60383. }
  60384. declare module BABYLON {
  60385. /** @hidden */
  60386. export var hdrFilteringPixelShader: {
  60387. name: string;
  60388. shader: string;
  60389. };
  60390. }
  60391. declare module BABYLON {
  60392. /**
  60393. * Options for texture filtering
  60394. */
  60395. interface IHDRFilteringOptions {
  60396. /**
  60397. * Scales pixel intensity for the input HDR map.
  60398. */
  60399. hdrScale?: number;
  60400. /**
  60401. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60402. */
  60403. quality?: number;
  60404. }
  60405. /**
  60406. * Filters HDR maps to get correct renderings of PBR reflections
  60407. */
  60408. export class HDRFiltering {
  60409. private _engine;
  60410. private _effectRenderer;
  60411. private _effectWrapper;
  60412. private _lodGenerationOffset;
  60413. private _lodGenerationScale;
  60414. /**
  60415. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60416. * you care about baking speed.
  60417. */
  60418. quality: number;
  60419. /**
  60420. * Scales pixel intensity for the input HDR map.
  60421. */
  60422. hdrScale: number;
  60423. /**
  60424. * Instantiates HDR filter for reflection maps
  60425. *
  60426. * @param engine Thin engine
  60427. * @param options Options
  60428. */
  60429. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60430. private _createRenderTarget;
  60431. private _prefilterInternal;
  60432. private _createEffect;
  60433. /**
  60434. * Get a value indicating if the filter is ready to be used
  60435. * @param texture Texture to filter
  60436. * @returns true if the filter is ready
  60437. */
  60438. isReady(texture: BaseTexture): boolean;
  60439. /**
  60440. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60441. * Prefiltering will be invoked at the end of next rendering pass.
  60442. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60443. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60444. * @param texture Texture to filter
  60445. * @param onFinished Callback when filtering is done
  60446. * @return Promise called when prefiltering is done
  60447. */
  60448. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60449. }
  60450. }
  60451. declare module BABYLON {
  60452. /**
  60453. * This represents a texture coming from an HDR input.
  60454. *
  60455. * The only supported format is currently panorama picture stored in RGBE format.
  60456. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60457. */
  60458. export class HDRCubeTexture extends BaseTexture {
  60459. private static _facesMapping;
  60460. private _generateHarmonics;
  60461. private _noMipmap;
  60462. private _prefilterOnLoad;
  60463. private _textureMatrix;
  60464. private _size;
  60465. private _onLoad;
  60466. private _onError;
  60467. /**
  60468. * The texture URL.
  60469. */
  60470. url: string;
  60471. protected _isBlocking: boolean;
  60472. /**
  60473. * Sets wether or not the texture is blocking during loading.
  60474. */
  60475. set isBlocking(value: boolean);
  60476. /**
  60477. * Gets wether or not the texture is blocking during loading.
  60478. */
  60479. get isBlocking(): boolean;
  60480. protected _rotationY: number;
  60481. /**
  60482. * Sets texture matrix rotation angle around Y axis in radians.
  60483. */
  60484. set rotationY(value: number);
  60485. /**
  60486. * Gets texture matrix rotation angle around Y axis radians.
  60487. */
  60488. get rotationY(): number;
  60489. /**
  60490. * Gets or sets the center of the bounding box associated with the cube texture
  60491. * It must define where the camera used to render the texture was set
  60492. */
  60493. boundingBoxPosition: Vector3;
  60494. private _boundingBoxSize;
  60495. /**
  60496. * Gets or sets the size of the bounding box associated with the cube texture
  60497. * When defined, the cubemap will switch to local mode
  60498. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60499. * @example https://www.babylonjs-playground.com/#RNASML
  60500. */
  60501. set boundingBoxSize(value: Vector3);
  60502. get boundingBoxSize(): Vector3;
  60503. /**
  60504. * Instantiates an HDRTexture from the following parameters.
  60505. *
  60506. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60507. * @param sceneOrEngine The scene or engine the texture will be used in
  60508. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60509. * @param noMipmap Forces to not generate the mipmap if true
  60510. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60511. * @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)
  60512. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60513. */
  60514. 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>);
  60515. /**
  60516. * Get the current class name of the texture useful for serialization or dynamic coding.
  60517. * @returns "HDRCubeTexture"
  60518. */
  60519. getClassName(): string;
  60520. /**
  60521. * Occurs when the file is raw .hdr file.
  60522. */
  60523. private loadTexture;
  60524. clone(): HDRCubeTexture;
  60525. delayLoad(): void;
  60526. /**
  60527. * Get the texture reflection matrix used to rotate/transform the reflection.
  60528. * @returns the reflection matrix
  60529. */
  60530. getReflectionTextureMatrix(): Matrix;
  60531. /**
  60532. * Set the texture reflection matrix used to rotate/transform the reflection.
  60533. * @param value Define the reflection matrix to set
  60534. */
  60535. setReflectionTextureMatrix(value: Matrix): void;
  60536. /**
  60537. * Parses a JSON representation of an HDR Texture in order to create the texture
  60538. * @param parsedTexture Define the JSON representation
  60539. * @param scene Define the scene the texture should be created in
  60540. * @param rootUrl Define the root url in case we need to load relative dependencies
  60541. * @returns the newly created texture after parsing
  60542. */
  60543. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60544. serialize(): any;
  60545. }
  60546. }
  60547. declare module BABYLON {
  60548. /**
  60549. * Class used to control physics engine
  60550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60551. */
  60552. export class PhysicsEngine implements IPhysicsEngine {
  60553. private _physicsPlugin;
  60554. /**
  60555. * Global value used to control the smallest number supported by the simulation
  60556. */
  60557. static Epsilon: number;
  60558. private _impostors;
  60559. private _joints;
  60560. private _subTimeStep;
  60561. /**
  60562. * Gets the gravity vector used by the simulation
  60563. */
  60564. gravity: Vector3;
  60565. /**
  60566. * Factory used to create the default physics plugin.
  60567. * @returns The default physics plugin
  60568. */
  60569. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60570. /**
  60571. * Creates a new Physics Engine
  60572. * @param gravity defines the gravity vector used by the simulation
  60573. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60574. */
  60575. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60576. /**
  60577. * Sets the gravity vector used by the simulation
  60578. * @param gravity defines the gravity vector to use
  60579. */
  60580. setGravity(gravity: Vector3): void;
  60581. /**
  60582. * Set the time step of the physics engine.
  60583. * Default is 1/60.
  60584. * To slow it down, enter 1/600 for example.
  60585. * To speed it up, 1/30
  60586. * @param newTimeStep defines the new timestep to apply to this world.
  60587. */
  60588. setTimeStep(newTimeStep?: number): void;
  60589. /**
  60590. * Get the time step of the physics engine.
  60591. * @returns the current time step
  60592. */
  60593. getTimeStep(): number;
  60594. /**
  60595. * Set the sub time step of the physics engine.
  60596. * Default is 0 meaning there is no sub steps
  60597. * To increase physics resolution precision, set a small value (like 1 ms)
  60598. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60599. */
  60600. setSubTimeStep(subTimeStep?: number): void;
  60601. /**
  60602. * Get the sub time step of the physics engine.
  60603. * @returns the current sub time step
  60604. */
  60605. getSubTimeStep(): number;
  60606. /**
  60607. * Release all resources
  60608. */
  60609. dispose(): void;
  60610. /**
  60611. * Gets the name of the current physics plugin
  60612. * @returns the name of the plugin
  60613. */
  60614. getPhysicsPluginName(): string;
  60615. /**
  60616. * Adding a new impostor for the impostor tracking.
  60617. * This will be done by the impostor itself.
  60618. * @param impostor the impostor to add
  60619. */
  60620. addImpostor(impostor: PhysicsImpostor): void;
  60621. /**
  60622. * Remove an impostor from the engine.
  60623. * This impostor and its mesh will not longer be updated by the physics engine.
  60624. * @param impostor the impostor to remove
  60625. */
  60626. removeImpostor(impostor: PhysicsImpostor): void;
  60627. /**
  60628. * Add a joint to the physics engine
  60629. * @param mainImpostor defines the main impostor to which the joint is added.
  60630. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60631. * @param joint defines the joint that will connect both impostors.
  60632. */
  60633. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60634. /**
  60635. * Removes a joint from the simulation
  60636. * @param mainImpostor defines the impostor used with the joint
  60637. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60638. * @param joint defines the joint to remove
  60639. */
  60640. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60641. /**
  60642. * Called by the scene. No need to call it.
  60643. * @param delta defines the timespam between frames
  60644. */
  60645. _step(delta: number): void;
  60646. /**
  60647. * Gets the current plugin used to run the simulation
  60648. * @returns current plugin
  60649. */
  60650. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60651. /**
  60652. * Gets the list of physic impostors
  60653. * @returns an array of PhysicsImpostor
  60654. */
  60655. getImpostors(): Array<PhysicsImpostor>;
  60656. /**
  60657. * Gets the impostor for a physics enabled object
  60658. * @param object defines the object impersonated by the impostor
  60659. * @returns the PhysicsImpostor or null if not found
  60660. */
  60661. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60662. /**
  60663. * Gets the impostor for a physics body object
  60664. * @param body defines physics body used by the impostor
  60665. * @returns the PhysicsImpostor or null if not found
  60666. */
  60667. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60668. /**
  60669. * Does a raycast in the physics world
  60670. * @param from when should the ray start?
  60671. * @param to when should the ray end?
  60672. * @returns PhysicsRaycastResult
  60673. */
  60674. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60675. }
  60676. }
  60677. declare module BABYLON {
  60678. /** @hidden */
  60679. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60680. private _useDeltaForWorldStep;
  60681. world: any;
  60682. name: string;
  60683. private _physicsMaterials;
  60684. private _fixedTimeStep;
  60685. private _cannonRaycastResult;
  60686. private _raycastResult;
  60687. private _physicsBodysToRemoveAfterStep;
  60688. private _firstFrame;
  60689. BJSCANNON: any;
  60690. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60691. setGravity(gravity: Vector3): void;
  60692. setTimeStep(timeStep: number): void;
  60693. getTimeStep(): number;
  60694. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60695. private _removeMarkedPhysicsBodiesFromWorld;
  60696. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60697. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60698. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60699. private _processChildMeshes;
  60700. removePhysicsBody(impostor: PhysicsImpostor): void;
  60701. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60702. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60703. private _addMaterial;
  60704. private _checkWithEpsilon;
  60705. private _createShape;
  60706. private _createHeightmap;
  60707. private _minus90X;
  60708. private _plus90X;
  60709. private _tmpPosition;
  60710. private _tmpDeltaPosition;
  60711. private _tmpUnityRotation;
  60712. private _updatePhysicsBodyTransformation;
  60713. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60714. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60715. isSupported(): boolean;
  60716. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60717. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60718. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60719. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60720. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60721. getBodyMass(impostor: PhysicsImpostor): number;
  60722. getBodyFriction(impostor: PhysicsImpostor): number;
  60723. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60724. getBodyRestitution(impostor: PhysicsImpostor): number;
  60725. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60726. sleepBody(impostor: PhysicsImpostor): void;
  60727. wakeUpBody(impostor: PhysicsImpostor): void;
  60728. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60729. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60730. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60731. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60732. getRadius(impostor: PhysicsImpostor): number;
  60733. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60734. dispose(): void;
  60735. private _extendNamespace;
  60736. /**
  60737. * Does a raycast in the physics world
  60738. * @param from when should the ray start?
  60739. * @param to when should the ray end?
  60740. * @returns PhysicsRaycastResult
  60741. */
  60742. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60743. }
  60744. }
  60745. declare module BABYLON {
  60746. /** @hidden */
  60747. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60748. private _useDeltaForWorldStep;
  60749. world: any;
  60750. name: string;
  60751. BJSOIMO: any;
  60752. private _raycastResult;
  60753. private _fixedTimeStep;
  60754. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60755. setGravity(gravity: Vector3): void;
  60756. setTimeStep(timeStep: number): void;
  60757. getTimeStep(): number;
  60758. private _tmpImpostorsArray;
  60759. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60760. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60761. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60762. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60763. private _tmpPositionVector;
  60764. removePhysicsBody(impostor: PhysicsImpostor): void;
  60765. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60766. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60767. isSupported(): boolean;
  60768. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60769. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60770. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60771. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60772. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60773. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60774. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60775. getBodyMass(impostor: PhysicsImpostor): number;
  60776. getBodyFriction(impostor: PhysicsImpostor): number;
  60777. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60778. getBodyRestitution(impostor: PhysicsImpostor): number;
  60779. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60780. sleepBody(impostor: PhysicsImpostor): void;
  60781. wakeUpBody(impostor: PhysicsImpostor): void;
  60782. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60783. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60784. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60785. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60786. getRadius(impostor: PhysicsImpostor): number;
  60787. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60788. dispose(): void;
  60789. /**
  60790. * Does a raycast in the physics world
  60791. * @param from when should the ray start?
  60792. * @param to when should the ray end?
  60793. * @returns PhysicsRaycastResult
  60794. */
  60795. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60796. }
  60797. }
  60798. declare module BABYLON {
  60799. /**
  60800. * AmmoJS Physics plugin
  60801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60802. * @see https://github.com/kripken/ammo.js/
  60803. */
  60804. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60805. private _useDeltaForWorldStep;
  60806. /**
  60807. * Reference to the Ammo library
  60808. */
  60809. bjsAMMO: any;
  60810. /**
  60811. * Created ammoJS world which physics bodies are added to
  60812. */
  60813. world: any;
  60814. /**
  60815. * Name of the plugin
  60816. */
  60817. name: string;
  60818. private _timeStep;
  60819. private _fixedTimeStep;
  60820. private _maxSteps;
  60821. private _tmpQuaternion;
  60822. private _tmpAmmoTransform;
  60823. private _tmpAmmoQuaternion;
  60824. private _tmpAmmoConcreteContactResultCallback;
  60825. private _collisionConfiguration;
  60826. private _dispatcher;
  60827. private _overlappingPairCache;
  60828. private _solver;
  60829. private _softBodySolver;
  60830. private _tmpAmmoVectorA;
  60831. private _tmpAmmoVectorB;
  60832. private _tmpAmmoVectorC;
  60833. private _tmpAmmoVectorD;
  60834. private _tmpContactCallbackResult;
  60835. private _tmpAmmoVectorRCA;
  60836. private _tmpAmmoVectorRCB;
  60837. private _raycastResult;
  60838. private static readonly DISABLE_COLLISION_FLAG;
  60839. private static readonly KINEMATIC_FLAG;
  60840. private static readonly DISABLE_DEACTIVATION_FLAG;
  60841. /**
  60842. * Initializes the ammoJS plugin
  60843. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60844. * @param ammoInjection can be used to inject your own ammo reference
  60845. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60846. */
  60847. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60848. /**
  60849. * Sets the gravity of the physics world (m/(s^2))
  60850. * @param gravity Gravity to set
  60851. */
  60852. setGravity(gravity: Vector3): void;
  60853. /**
  60854. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60855. * @param timeStep timestep to use in seconds
  60856. */
  60857. setTimeStep(timeStep: number): void;
  60858. /**
  60859. * 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)
  60860. * @param fixedTimeStep fixedTimeStep to use in seconds
  60861. */
  60862. setFixedTimeStep(fixedTimeStep: number): void;
  60863. /**
  60864. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60865. * @param maxSteps the maximum number of steps by the physics engine per frame
  60866. */
  60867. setMaxSteps(maxSteps: number): void;
  60868. /**
  60869. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60870. * @returns the current timestep in seconds
  60871. */
  60872. getTimeStep(): number;
  60873. /**
  60874. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60875. */
  60876. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60877. private _isImpostorInContact;
  60878. private _isImpostorPairInContact;
  60879. private _stepSimulation;
  60880. /**
  60881. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60882. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60883. * After the step the babylon meshes are set to the position of the physics imposters
  60884. * @param delta amount of time to step forward
  60885. * @param impostors array of imposters to update before/after the step
  60886. */
  60887. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60888. /**
  60889. * Update babylon mesh to match physics world object
  60890. * @param impostor imposter to match
  60891. */
  60892. private _afterSoftStep;
  60893. /**
  60894. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60895. * @param impostor imposter to match
  60896. */
  60897. private _ropeStep;
  60898. /**
  60899. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60900. * @param impostor imposter to match
  60901. */
  60902. private _softbodyOrClothStep;
  60903. private _tmpMatrix;
  60904. /**
  60905. * Applies an impulse on the imposter
  60906. * @param impostor imposter to apply impulse to
  60907. * @param force amount of force to be applied to the imposter
  60908. * @param contactPoint the location to apply the impulse on the imposter
  60909. */
  60910. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60911. /**
  60912. * Applies a force on the imposter
  60913. * @param impostor imposter to apply force
  60914. * @param force amount of force to be applied to the imposter
  60915. * @param contactPoint the location to apply the force on the imposter
  60916. */
  60917. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60918. /**
  60919. * Creates a physics body using the plugin
  60920. * @param impostor the imposter to create the physics body on
  60921. */
  60922. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60923. /**
  60924. * Removes the physics body from the imposter and disposes of the body's memory
  60925. * @param impostor imposter to remove the physics body from
  60926. */
  60927. removePhysicsBody(impostor: PhysicsImpostor): void;
  60928. /**
  60929. * Generates a joint
  60930. * @param impostorJoint the imposter joint to create the joint with
  60931. */
  60932. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60933. /**
  60934. * Removes a joint
  60935. * @param impostorJoint the imposter joint to remove the joint from
  60936. */
  60937. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60938. private _addMeshVerts;
  60939. /**
  60940. * Initialise the soft body vertices to match its object's (mesh) vertices
  60941. * Softbody vertices (nodes) are in world space and to match this
  60942. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60943. * @param impostor to create the softbody for
  60944. */
  60945. private _softVertexData;
  60946. /**
  60947. * Create an impostor's soft body
  60948. * @param impostor to create the softbody for
  60949. */
  60950. private _createSoftbody;
  60951. /**
  60952. * Create cloth for an impostor
  60953. * @param impostor to create the softbody for
  60954. */
  60955. private _createCloth;
  60956. /**
  60957. * Create rope for an impostor
  60958. * @param impostor to create the softbody for
  60959. */
  60960. private _createRope;
  60961. /**
  60962. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60963. * @param impostor to create the custom physics shape for
  60964. */
  60965. private _createCustom;
  60966. private _addHullVerts;
  60967. private _createShape;
  60968. /**
  60969. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60970. * @param impostor imposter containing the physics body and babylon object
  60971. */
  60972. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60973. /**
  60974. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60975. * @param impostor imposter containing the physics body and babylon object
  60976. * @param newPosition new position
  60977. * @param newRotation new rotation
  60978. */
  60979. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60980. /**
  60981. * If this plugin is supported
  60982. * @returns true if its supported
  60983. */
  60984. isSupported(): boolean;
  60985. /**
  60986. * Sets the linear velocity of the physics body
  60987. * @param impostor imposter to set the velocity on
  60988. * @param velocity velocity to set
  60989. */
  60990. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60991. /**
  60992. * Sets the angular velocity of the physics body
  60993. * @param impostor imposter to set the velocity on
  60994. * @param velocity velocity to set
  60995. */
  60996. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60997. /**
  60998. * gets the linear velocity
  60999. * @param impostor imposter to get linear velocity from
  61000. * @returns linear velocity
  61001. */
  61002. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61003. /**
  61004. * gets the angular velocity
  61005. * @param impostor imposter to get angular velocity from
  61006. * @returns angular velocity
  61007. */
  61008. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61009. /**
  61010. * Sets the mass of physics body
  61011. * @param impostor imposter to set the mass on
  61012. * @param mass mass to set
  61013. */
  61014. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61015. /**
  61016. * Gets the mass of the physics body
  61017. * @param impostor imposter to get the mass from
  61018. * @returns mass
  61019. */
  61020. getBodyMass(impostor: PhysicsImpostor): number;
  61021. /**
  61022. * Gets friction of the impostor
  61023. * @param impostor impostor to get friction from
  61024. * @returns friction value
  61025. */
  61026. getBodyFriction(impostor: PhysicsImpostor): number;
  61027. /**
  61028. * Sets friction of the impostor
  61029. * @param impostor impostor to set friction on
  61030. * @param friction friction value
  61031. */
  61032. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61033. /**
  61034. * Gets restitution of the impostor
  61035. * @param impostor impostor to get restitution from
  61036. * @returns restitution value
  61037. */
  61038. getBodyRestitution(impostor: PhysicsImpostor): number;
  61039. /**
  61040. * Sets resitution of the impostor
  61041. * @param impostor impostor to set resitution on
  61042. * @param restitution resitution value
  61043. */
  61044. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61045. /**
  61046. * Gets pressure inside the impostor
  61047. * @param impostor impostor to get pressure from
  61048. * @returns pressure value
  61049. */
  61050. getBodyPressure(impostor: PhysicsImpostor): number;
  61051. /**
  61052. * Sets pressure inside a soft body impostor
  61053. * Cloth and rope must remain 0 pressure
  61054. * @param impostor impostor to set pressure on
  61055. * @param pressure pressure value
  61056. */
  61057. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61058. /**
  61059. * Gets stiffness of the impostor
  61060. * @param impostor impostor to get stiffness from
  61061. * @returns pressure value
  61062. */
  61063. getBodyStiffness(impostor: PhysicsImpostor): number;
  61064. /**
  61065. * Sets stiffness of the impostor
  61066. * @param impostor impostor to set stiffness on
  61067. * @param stiffness stiffness value from 0 to 1
  61068. */
  61069. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61070. /**
  61071. * Gets velocityIterations of the impostor
  61072. * @param impostor impostor to get velocity iterations from
  61073. * @returns velocityIterations value
  61074. */
  61075. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61076. /**
  61077. * Sets velocityIterations of the impostor
  61078. * @param impostor impostor to set velocity iterations on
  61079. * @param velocityIterations velocityIterations value
  61080. */
  61081. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61082. /**
  61083. * Gets positionIterations of the impostor
  61084. * @param impostor impostor to get position iterations from
  61085. * @returns positionIterations value
  61086. */
  61087. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61088. /**
  61089. * Sets positionIterations of the impostor
  61090. * @param impostor impostor to set position on
  61091. * @param positionIterations positionIterations value
  61092. */
  61093. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61094. /**
  61095. * Append an anchor to a cloth object
  61096. * @param impostor is the cloth impostor to add anchor to
  61097. * @param otherImpostor is the rigid impostor to anchor to
  61098. * @param width ratio across width from 0 to 1
  61099. * @param height ratio up height from 0 to 1
  61100. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61101. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61102. */
  61103. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61104. /**
  61105. * Append an hook to a rope object
  61106. * @param impostor is the rope impostor to add hook to
  61107. * @param otherImpostor is the rigid impostor to hook to
  61108. * @param length ratio along the rope from 0 to 1
  61109. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61110. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61111. */
  61112. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61113. /**
  61114. * Sleeps the physics body and stops it from being active
  61115. * @param impostor impostor to sleep
  61116. */
  61117. sleepBody(impostor: PhysicsImpostor): void;
  61118. /**
  61119. * Activates the physics body
  61120. * @param impostor impostor to activate
  61121. */
  61122. wakeUpBody(impostor: PhysicsImpostor): void;
  61123. /**
  61124. * Updates the distance parameters of the joint
  61125. * @param joint joint to update
  61126. * @param maxDistance maximum distance of the joint
  61127. * @param minDistance minimum distance of the joint
  61128. */
  61129. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61130. /**
  61131. * Sets a motor on the joint
  61132. * @param joint joint to set motor on
  61133. * @param speed speed of the motor
  61134. * @param maxForce maximum force of the motor
  61135. * @param motorIndex index of the motor
  61136. */
  61137. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61138. /**
  61139. * Sets the motors limit
  61140. * @param joint joint to set limit on
  61141. * @param upperLimit upper limit
  61142. * @param lowerLimit lower limit
  61143. */
  61144. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61145. /**
  61146. * Syncs the position and rotation of a mesh with the impostor
  61147. * @param mesh mesh to sync
  61148. * @param impostor impostor to update the mesh with
  61149. */
  61150. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61151. /**
  61152. * Gets the radius of the impostor
  61153. * @param impostor impostor to get radius from
  61154. * @returns the radius
  61155. */
  61156. getRadius(impostor: PhysicsImpostor): number;
  61157. /**
  61158. * Gets the box size of the impostor
  61159. * @param impostor impostor to get box size from
  61160. * @param result the resulting box size
  61161. */
  61162. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61163. /**
  61164. * Disposes of the impostor
  61165. */
  61166. dispose(): void;
  61167. /**
  61168. * Does a raycast in the physics world
  61169. * @param from when should the ray start?
  61170. * @param to when should the ray end?
  61171. * @returns PhysicsRaycastResult
  61172. */
  61173. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61174. }
  61175. }
  61176. declare module BABYLON {
  61177. interface AbstractScene {
  61178. /**
  61179. * The list of reflection probes added to the scene
  61180. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61181. */
  61182. reflectionProbes: Array<ReflectionProbe>;
  61183. /**
  61184. * Removes the given reflection probe from this scene.
  61185. * @param toRemove The reflection probe to remove
  61186. * @returns The index of the removed reflection probe
  61187. */
  61188. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61189. /**
  61190. * Adds the given reflection probe to this scene.
  61191. * @param newReflectionProbe The reflection probe to add
  61192. */
  61193. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61194. }
  61195. /**
  61196. * Class used to generate realtime reflection / refraction cube textures
  61197. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61198. */
  61199. export class ReflectionProbe {
  61200. /** defines the name of the probe */
  61201. name: string;
  61202. private _scene;
  61203. private _renderTargetTexture;
  61204. private _projectionMatrix;
  61205. private _viewMatrix;
  61206. private _target;
  61207. private _add;
  61208. private _attachedMesh;
  61209. private _invertYAxis;
  61210. /** Gets or sets probe position (center of the cube map) */
  61211. position: Vector3;
  61212. /**
  61213. * Creates a new reflection probe
  61214. * @param name defines the name of the probe
  61215. * @param size defines the texture resolution (for each face)
  61216. * @param scene defines the hosting scene
  61217. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61218. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61219. */
  61220. constructor(
  61221. /** defines the name of the probe */
  61222. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61223. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61224. get samples(): number;
  61225. set samples(value: number);
  61226. /** Gets or sets the refresh rate to use (on every frame by default) */
  61227. get refreshRate(): number;
  61228. set refreshRate(value: number);
  61229. /**
  61230. * Gets the hosting scene
  61231. * @returns a Scene
  61232. */
  61233. getScene(): Scene;
  61234. /** Gets the internal CubeTexture used to render to */
  61235. get cubeTexture(): RenderTargetTexture;
  61236. /** Gets the list of meshes to render */
  61237. get renderList(): Nullable<AbstractMesh[]>;
  61238. /**
  61239. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61240. * @param mesh defines the mesh to attach to
  61241. */
  61242. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61243. /**
  61244. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61245. * @param renderingGroupId The rendering group id corresponding to its index
  61246. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61247. */
  61248. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61249. /**
  61250. * Clean all associated resources
  61251. */
  61252. dispose(): void;
  61253. /**
  61254. * Converts the reflection probe information to a readable string for debug purpose.
  61255. * @param fullDetails Supports for multiple levels of logging within scene loading
  61256. * @returns the human readable reflection probe info
  61257. */
  61258. toString(fullDetails?: boolean): string;
  61259. /**
  61260. * Get the class name of the relfection probe.
  61261. * @returns "ReflectionProbe"
  61262. */
  61263. getClassName(): string;
  61264. /**
  61265. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61266. * @returns The JSON representation of the texture
  61267. */
  61268. serialize(): any;
  61269. /**
  61270. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61271. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61272. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61273. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61274. * @returns The parsed reflection probe if successful
  61275. */
  61276. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61277. }
  61278. }
  61279. declare module BABYLON {
  61280. /** @hidden */
  61281. export var _BabylonLoaderRegistered: boolean;
  61282. /**
  61283. * Helps setting up some configuration for the babylon file loader.
  61284. */
  61285. export class BabylonFileLoaderConfiguration {
  61286. /**
  61287. * The loader does not allow injecting custom physix engine into the plugins.
  61288. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61289. * So you could set this variable to your engine import to make it work.
  61290. */
  61291. static LoaderInjectedPhysicsEngine: any;
  61292. }
  61293. }
  61294. declare module BABYLON {
  61295. /**
  61296. * The Physically based simple base material of BJS.
  61297. *
  61298. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61299. * It is used as the base class for both the specGloss and metalRough conventions.
  61300. */
  61301. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61302. /**
  61303. * Number of Simultaneous lights allowed on the material.
  61304. */
  61305. maxSimultaneousLights: number;
  61306. /**
  61307. * If sets to true, disables all the lights affecting the material.
  61308. */
  61309. disableLighting: boolean;
  61310. /**
  61311. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61312. */
  61313. environmentTexture: BaseTexture;
  61314. /**
  61315. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61316. */
  61317. invertNormalMapX: boolean;
  61318. /**
  61319. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61320. */
  61321. invertNormalMapY: boolean;
  61322. /**
  61323. * Normal map used in the model.
  61324. */
  61325. normalTexture: BaseTexture;
  61326. /**
  61327. * Emissivie color used to self-illuminate the model.
  61328. */
  61329. emissiveColor: Color3;
  61330. /**
  61331. * Emissivie texture used to self-illuminate the model.
  61332. */
  61333. emissiveTexture: BaseTexture;
  61334. /**
  61335. * Occlusion Channel Strenght.
  61336. */
  61337. occlusionStrength: number;
  61338. /**
  61339. * Occlusion Texture of the material (adding extra occlusion effects).
  61340. */
  61341. occlusionTexture: BaseTexture;
  61342. /**
  61343. * Defines the alpha limits in alpha test mode.
  61344. */
  61345. alphaCutOff: number;
  61346. /**
  61347. * Gets the current double sided mode.
  61348. */
  61349. get doubleSided(): boolean;
  61350. /**
  61351. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61352. */
  61353. set doubleSided(value: boolean);
  61354. /**
  61355. * Stores the pre-calculated light information of a mesh in a texture.
  61356. */
  61357. lightmapTexture: BaseTexture;
  61358. /**
  61359. * If true, the light map contains occlusion information instead of lighting info.
  61360. */
  61361. useLightmapAsShadowmap: boolean;
  61362. /**
  61363. * Instantiates a new PBRMaterial instance.
  61364. *
  61365. * @param name The material name
  61366. * @param scene The scene the material will be use in.
  61367. */
  61368. constructor(name: string, scene: Scene);
  61369. getClassName(): string;
  61370. }
  61371. }
  61372. declare module BABYLON {
  61373. /**
  61374. * The PBR material of BJS following the metal roughness convention.
  61375. *
  61376. * This fits to the PBR convention in the GLTF definition:
  61377. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61378. */
  61379. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61380. /**
  61381. * The base color has two different interpretations depending on the value of metalness.
  61382. * When the material is a metal, the base color is the specific measured reflectance value
  61383. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61384. * of the material.
  61385. */
  61386. baseColor: Color3;
  61387. /**
  61388. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61389. * well as opacity information in the alpha channel.
  61390. */
  61391. baseTexture: BaseTexture;
  61392. /**
  61393. * Specifies the metallic scalar value of the material.
  61394. * Can also be used to scale the metalness values of the metallic texture.
  61395. */
  61396. metallic: number;
  61397. /**
  61398. * Specifies the roughness scalar value of the material.
  61399. * Can also be used to scale the roughness values of the metallic texture.
  61400. */
  61401. roughness: number;
  61402. /**
  61403. * Texture containing both the metallic value in the B channel and the
  61404. * roughness value in the G channel to keep better precision.
  61405. */
  61406. metallicRoughnessTexture: BaseTexture;
  61407. /**
  61408. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61409. *
  61410. * @param name The material name
  61411. * @param scene The scene the material will be use in.
  61412. */
  61413. constructor(name: string, scene: Scene);
  61414. /**
  61415. * Return the currrent class name of the material.
  61416. */
  61417. getClassName(): string;
  61418. /**
  61419. * Makes a duplicate of the current material.
  61420. * @param name - name to use for the new material.
  61421. */
  61422. clone(name: string): PBRMetallicRoughnessMaterial;
  61423. /**
  61424. * Serialize the material to a parsable JSON object.
  61425. */
  61426. serialize(): any;
  61427. /**
  61428. * Parses a JSON object correponding to the serialize function.
  61429. */
  61430. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61431. }
  61432. }
  61433. declare module BABYLON {
  61434. /**
  61435. * The PBR material of BJS following the specular glossiness convention.
  61436. *
  61437. * This fits to the PBR convention in the GLTF definition:
  61438. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61439. */
  61440. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61441. /**
  61442. * Specifies the diffuse color of the material.
  61443. */
  61444. diffuseColor: Color3;
  61445. /**
  61446. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61447. * channel.
  61448. */
  61449. diffuseTexture: BaseTexture;
  61450. /**
  61451. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61452. */
  61453. specularColor: Color3;
  61454. /**
  61455. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61456. */
  61457. glossiness: number;
  61458. /**
  61459. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61460. */
  61461. specularGlossinessTexture: BaseTexture;
  61462. /**
  61463. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61464. *
  61465. * @param name The material name
  61466. * @param scene The scene the material will be use in.
  61467. */
  61468. constructor(name: string, scene: Scene);
  61469. /**
  61470. * Return the currrent class name of the material.
  61471. */
  61472. getClassName(): string;
  61473. /**
  61474. * Makes a duplicate of the current material.
  61475. * @param name - name to use for the new material.
  61476. */
  61477. clone(name: string): PBRSpecularGlossinessMaterial;
  61478. /**
  61479. * Serialize the material to a parsable JSON object.
  61480. */
  61481. serialize(): any;
  61482. /**
  61483. * Parses a JSON object correponding to the serialize function.
  61484. */
  61485. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61486. }
  61487. }
  61488. declare module BABYLON {
  61489. /**
  61490. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61491. * It can help converting any input color in a desired output one. This can then be used to create effects
  61492. * from sepia, black and white to sixties or futuristic rendering...
  61493. *
  61494. * The only supported format is currently 3dl.
  61495. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61496. */
  61497. export class ColorGradingTexture extends BaseTexture {
  61498. /**
  61499. * The texture URL.
  61500. */
  61501. url: string;
  61502. /**
  61503. * Empty line regex stored for GC.
  61504. */
  61505. private static _noneEmptyLineRegex;
  61506. private _textureMatrix;
  61507. private _onLoad;
  61508. /**
  61509. * Instantiates a ColorGradingTexture from the following parameters.
  61510. *
  61511. * @param url The location of the color gradind data (currently only supporting 3dl)
  61512. * @param sceneOrEngine The scene or engine the texture will be used in
  61513. * @param onLoad defines a callback triggered when the texture has been loaded
  61514. */
  61515. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61516. /**
  61517. * Fires the onload event from the constructor if requested.
  61518. */
  61519. private _triggerOnLoad;
  61520. /**
  61521. * Returns the texture matrix used in most of the material.
  61522. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61523. */
  61524. getTextureMatrix(): Matrix;
  61525. /**
  61526. * Occurs when the file being loaded is a .3dl LUT file.
  61527. */
  61528. private load3dlTexture;
  61529. /**
  61530. * Starts the loading process of the texture.
  61531. */
  61532. private loadTexture;
  61533. /**
  61534. * Clones the color gradind texture.
  61535. */
  61536. clone(): ColorGradingTexture;
  61537. /**
  61538. * Called during delayed load for textures.
  61539. */
  61540. delayLoad(): void;
  61541. /**
  61542. * Parses a color grading texture serialized by Babylon.
  61543. * @param parsedTexture The texture information being parsedTexture
  61544. * @param scene The scene to load the texture in
  61545. * @param rootUrl The root url of the data assets to load
  61546. * @return A color gradind texture
  61547. */
  61548. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61549. /**
  61550. * Serializes the LUT texture to json format.
  61551. */
  61552. serialize(): any;
  61553. }
  61554. }
  61555. declare module BABYLON {
  61556. /**
  61557. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61558. */
  61559. export class EquiRectangularCubeTexture extends BaseTexture {
  61560. /** The six faces of the cube. */
  61561. private static _FacesMapping;
  61562. private _noMipmap;
  61563. private _onLoad;
  61564. private _onError;
  61565. /** The size of the cubemap. */
  61566. private _size;
  61567. /** The buffer of the image. */
  61568. private _buffer;
  61569. /** The width of the input image. */
  61570. private _width;
  61571. /** The height of the input image. */
  61572. private _height;
  61573. /** The URL to the image. */
  61574. url: string;
  61575. /**
  61576. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61577. * @param url The location of the image
  61578. * @param scene The scene the texture will be used in
  61579. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61580. * @param noMipmap Forces to not generate the mipmap if true
  61581. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61582. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61583. * @param onLoad — defines a callback called when texture is loaded
  61584. * @param onError — defines a callback called if there is an error
  61585. */
  61586. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61587. /**
  61588. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61589. */
  61590. private loadImage;
  61591. /**
  61592. * Convert the image buffer into a cubemap and create a CubeTexture.
  61593. */
  61594. private loadTexture;
  61595. /**
  61596. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61597. * @param buffer The ArrayBuffer that should be converted.
  61598. * @returns The buffer as Float32Array.
  61599. */
  61600. private getFloat32ArrayFromArrayBuffer;
  61601. /**
  61602. * Get the current class name of the texture useful for serialization or dynamic coding.
  61603. * @returns "EquiRectangularCubeTexture"
  61604. */
  61605. getClassName(): string;
  61606. /**
  61607. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61608. * @returns A clone of the current EquiRectangularCubeTexture.
  61609. */
  61610. clone(): EquiRectangularCubeTexture;
  61611. }
  61612. }
  61613. declare module BABYLON {
  61614. /**
  61615. * Defines the options related to the creation of an HtmlElementTexture
  61616. */
  61617. export interface IHtmlElementTextureOptions {
  61618. /**
  61619. * Defines wether mip maps should be created or not.
  61620. */
  61621. generateMipMaps?: boolean;
  61622. /**
  61623. * Defines the sampling mode of the texture.
  61624. */
  61625. samplingMode?: number;
  61626. /**
  61627. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61628. */
  61629. engine: Nullable<ThinEngine>;
  61630. /**
  61631. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61632. */
  61633. scene: Nullable<Scene>;
  61634. }
  61635. /**
  61636. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61637. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61638. * is automatically managed.
  61639. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61640. * in your application.
  61641. *
  61642. * As the update is not automatic, you need to call them manually.
  61643. */
  61644. export class HtmlElementTexture extends BaseTexture {
  61645. /**
  61646. * The texture URL.
  61647. */
  61648. element: HTMLVideoElement | HTMLCanvasElement;
  61649. private static readonly DefaultOptions;
  61650. private _textureMatrix;
  61651. private _isVideo;
  61652. private _generateMipMaps;
  61653. private _samplingMode;
  61654. /**
  61655. * Instantiates a HtmlElementTexture from the following parameters.
  61656. *
  61657. * @param name Defines the name of the texture
  61658. * @param element Defines the video or canvas the texture is filled with
  61659. * @param options Defines the other none mandatory texture creation options
  61660. */
  61661. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61662. private _createInternalTexture;
  61663. /**
  61664. * Returns the texture matrix used in most of the material.
  61665. */
  61666. getTextureMatrix(): Matrix;
  61667. /**
  61668. * Updates the content of the texture.
  61669. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61670. */
  61671. update(invertY?: Nullable<boolean>): void;
  61672. }
  61673. }
  61674. declare module BABYLON {
  61675. /**
  61676. * Based on jsTGALoader - Javascript loader for TGA file
  61677. * By Vincent Thibault
  61678. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61679. */
  61680. export class TGATools {
  61681. private static _TYPE_INDEXED;
  61682. private static _TYPE_RGB;
  61683. private static _TYPE_GREY;
  61684. private static _TYPE_RLE_INDEXED;
  61685. private static _TYPE_RLE_RGB;
  61686. private static _TYPE_RLE_GREY;
  61687. private static _ORIGIN_MASK;
  61688. private static _ORIGIN_SHIFT;
  61689. private static _ORIGIN_BL;
  61690. private static _ORIGIN_BR;
  61691. private static _ORIGIN_UL;
  61692. private static _ORIGIN_UR;
  61693. /**
  61694. * Gets the header of a TGA file
  61695. * @param data defines the TGA data
  61696. * @returns the header
  61697. */
  61698. static GetTGAHeader(data: Uint8Array): any;
  61699. /**
  61700. * Uploads TGA content to a Babylon Texture
  61701. * @hidden
  61702. */
  61703. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61704. /** @hidden */
  61705. 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;
  61706. /** @hidden */
  61707. 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;
  61708. /** @hidden */
  61709. 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;
  61710. /** @hidden */
  61711. 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;
  61712. /** @hidden */
  61713. 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;
  61714. /** @hidden */
  61715. 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;
  61716. }
  61717. }
  61718. declare module BABYLON {
  61719. /**
  61720. * Implementation of the TGA Texture Loader.
  61721. * @hidden
  61722. */
  61723. export class _TGATextureLoader implements IInternalTextureLoader {
  61724. /**
  61725. * Defines wether the loader supports cascade loading the different faces.
  61726. */
  61727. readonly supportCascades: boolean;
  61728. /**
  61729. * This returns if the loader support the current file information.
  61730. * @param extension defines the file extension of the file being loaded
  61731. * @returns true if the loader can load the specified file
  61732. */
  61733. canLoad(extension: string): boolean;
  61734. /**
  61735. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61736. * @param data contains the texture data
  61737. * @param texture defines the BabylonJS internal texture
  61738. * @param createPolynomials will be true if polynomials have been requested
  61739. * @param onLoad defines the callback to trigger once the texture is ready
  61740. * @param onError defines the callback to trigger in case of error
  61741. */
  61742. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61743. /**
  61744. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61745. * @param data contains the texture data
  61746. * @param texture defines the BabylonJS internal texture
  61747. * @param callback defines the method to call once ready to upload
  61748. */
  61749. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61750. }
  61751. }
  61752. declare module BABYLON {
  61753. /**
  61754. * Info about the .basis files
  61755. */
  61756. class BasisFileInfo {
  61757. /**
  61758. * If the file has alpha
  61759. */
  61760. hasAlpha: boolean;
  61761. /**
  61762. * Info about each image of the basis file
  61763. */
  61764. images: Array<{
  61765. levels: Array<{
  61766. width: number;
  61767. height: number;
  61768. transcodedPixels: ArrayBufferView;
  61769. }>;
  61770. }>;
  61771. }
  61772. /**
  61773. * Result of transcoding a basis file
  61774. */
  61775. class TranscodeResult {
  61776. /**
  61777. * Info about the .basis file
  61778. */
  61779. fileInfo: BasisFileInfo;
  61780. /**
  61781. * Format to use when loading the file
  61782. */
  61783. format: number;
  61784. }
  61785. /**
  61786. * Configuration options for the Basis transcoder
  61787. */
  61788. export class BasisTranscodeConfiguration {
  61789. /**
  61790. * Supported compression formats used to determine the supported output format of the transcoder
  61791. */
  61792. supportedCompressionFormats?: {
  61793. /**
  61794. * etc1 compression format
  61795. */
  61796. etc1?: boolean;
  61797. /**
  61798. * s3tc compression format
  61799. */
  61800. s3tc?: boolean;
  61801. /**
  61802. * pvrtc compression format
  61803. */
  61804. pvrtc?: boolean;
  61805. /**
  61806. * etc2 compression format
  61807. */
  61808. etc2?: boolean;
  61809. };
  61810. /**
  61811. * If mipmap levels should be loaded for transcoded images (Default: true)
  61812. */
  61813. loadMipmapLevels?: boolean;
  61814. /**
  61815. * Index of a single image to load (Default: all images)
  61816. */
  61817. loadSingleImage?: number;
  61818. }
  61819. /**
  61820. * Used to load .Basis files
  61821. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61822. */
  61823. export class BasisTools {
  61824. private static _IgnoreSupportedFormats;
  61825. /**
  61826. * URL to use when loading the basis transcoder
  61827. */
  61828. static JSModuleURL: string;
  61829. /**
  61830. * URL to use when loading the wasm module for the transcoder
  61831. */
  61832. static WasmModuleURL: string;
  61833. /**
  61834. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61835. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61836. * @returns internal format corresponding to the Basis format
  61837. */
  61838. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61839. private static _WorkerPromise;
  61840. private static _Worker;
  61841. private static _actionId;
  61842. private static _CreateWorkerAsync;
  61843. /**
  61844. * Transcodes a loaded image file to compressed pixel data
  61845. * @param data image data to transcode
  61846. * @param config configuration options for the transcoding
  61847. * @returns a promise resulting in the transcoded image
  61848. */
  61849. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61850. /**
  61851. * Loads a texture from the transcode result
  61852. * @param texture texture load to
  61853. * @param transcodeResult the result of transcoding the basis file to load from
  61854. */
  61855. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61856. }
  61857. }
  61858. declare module BABYLON {
  61859. /**
  61860. * Loader for .basis file format
  61861. */
  61862. export class _BasisTextureLoader implements IInternalTextureLoader {
  61863. /**
  61864. * Defines whether the loader supports cascade loading the different faces.
  61865. */
  61866. readonly supportCascades: boolean;
  61867. /**
  61868. * This returns if the loader support the current file information.
  61869. * @param extension defines the file extension of the file being loaded
  61870. * @returns true if the loader can load the specified file
  61871. */
  61872. canLoad(extension: string): boolean;
  61873. /**
  61874. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61875. * @param data contains the texture data
  61876. * @param texture defines the BabylonJS internal texture
  61877. * @param createPolynomials will be true if polynomials have been requested
  61878. * @param onLoad defines the callback to trigger once the texture is ready
  61879. * @param onError defines the callback to trigger in case of error
  61880. */
  61881. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61882. /**
  61883. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61884. * @param data contains the texture data
  61885. * @param texture defines the BabylonJS internal texture
  61886. * @param callback defines the method to call once ready to upload
  61887. */
  61888. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61889. }
  61890. }
  61891. declare module BABYLON {
  61892. /**
  61893. * Defines the basic options interface of a TexturePacker Frame
  61894. */
  61895. export interface ITexturePackerFrame {
  61896. /**
  61897. * The frame ID
  61898. */
  61899. id: number;
  61900. /**
  61901. * The frames Scale
  61902. */
  61903. scale: Vector2;
  61904. /**
  61905. * The Frames offset
  61906. */
  61907. offset: Vector2;
  61908. }
  61909. /**
  61910. * This is a support class for frame Data on texture packer sets.
  61911. */
  61912. export class TexturePackerFrame implements ITexturePackerFrame {
  61913. /**
  61914. * The frame ID
  61915. */
  61916. id: number;
  61917. /**
  61918. * The frames Scale
  61919. */
  61920. scale: Vector2;
  61921. /**
  61922. * The Frames offset
  61923. */
  61924. offset: Vector2;
  61925. /**
  61926. * Initializes a texture package frame.
  61927. * @param id The numerical frame identifier
  61928. * @param scale Scalar Vector2 for UV frame
  61929. * @param offset Vector2 for the frame position in UV units.
  61930. * @returns TexturePackerFrame
  61931. */
  61932. constructor(id: number, scale: Vector2, offset: Vector2);
  61933. }
  61934. }
  61935. declare module BABYLON {
  61936. /**
  61937. * Defines the basic options interface of a TexturePacker
  61938. */
  61939. export interface ITexturePackerOptions {
  61940. /**
  61941. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61942. */
  61943. map?: string[];
  61944. /**
  61945. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61946. */
  61947. uvsIn?: string;
  61948. /**
  61949. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61950. */
  61951. uvsOut?: string;
  61952. /**
  61953. * number representing the layout style. Defaults to LAYOUT_STRIP
  61954. */
  61955. layout?: number;
  61956. /**
  61957. * number of columns if using custom column count layout(2). This defaults to 4.
  61958. */
  61959. colnum?: number;
  61960. /**
  61961. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61962. */
  61963. updateInputMeshes?: boolean;
  61964. /**
  61965. * boolean flag to dispose all the source textures. Defaults to true.
  61966. */
  61967. disposeSources?: boolean;
  61968. /**
  61969. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61970. */
  61971. fillBlanks?: boolean;
  61972. /**
  61973. * string value representing the context fill style color. Defaults to 'black'.
  61974. */
  61975. customFillColor?: string;
  61976. /**
  61977. * Width and Height Value of each Frame in the TexturePacker Sets
  61978. */
  61979. frameSize?: number;
  61980. /**
  61981. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61982. */
  61983. paddingRatio?: number;
  61984. /**
  61985. * Number that declares the fill method for the padding gutter.
  61986. */
  61987. paddingMode?: number;
  61988. /**
  61989. * If in SUBUV_COLOR padding mode what color to use.
  61990. */
  61991. paddingColor?: Color3 | Color4;
  61992. }
  61993. /**
  61994. * Defines the basic interface of a TexturePacker JSON File
  61995. */
  61996. export interface ITexturePackerJSON {
  61997. /**
  61998. * The frame ID
  61999. */
  62000. name: string;
  62001. /**
  62002. * The base64 channel data
  62003. */
  62004. sets: any;
  62005. /**
  62006. * The options of the Packer
  62007. */
  62008. options: ITexturePackerOptions;
  62009. /**
  62010. * The frame data of the Packer
  62011. */
  62012. frames: Array<number>;
  62013. }
  62014. /**
  62015. * This is a support class that generates a series of packed texture sets.
  62016. * @see https://doc.babylonjs.com/babylon101/materials
  62017. */
  62018. export class TexturePacker {
  62019. /** Packer Layout Constant 0 */
  62020. static readonly LAYOUT_STRIP: number;
  62021. /** Packer Layout Constant 1 */
  62022. static readonly LAYOUT_POWER2: number;
  62023. /** Packer Layout Constant 2 */
  62024. static readonly LAYOUT_COLNUM: number;
  62025. /** Packer Layout Constant 0 */
  62026. static readonly SUBUV_WRAP: number;
  62027. /** Packer Layout Constant 1 */
  62028. static readonly SUBUV_EXTEND: number;
  62029. /** Packer Layout Constant 2 */
  62030. static readonly SUBUV_COLOR: number;
  62031. /** The Name of the Texture Package */
  62032. name: string;
  62033. /** The scene scope of the TexturePacker */
  62034. scene: Scene;
  62035. /** The Meshes to target */
  62036. meshes: AbstractMesh[];
  62037. /** Arguments passed with the Constructor */
  62038. options: ITexturePackerOptions;
  62039. /** The promise that is started upon initialization */
  62040. promise: Nullable<Promise<TexturePacker | string>>;
  62041. /** The Container object for the channel sets that are generated */
  62042. sets: object;
  62043. /** The Container array for the frames that are generated */
  62044. frames: TexturePackerFrame[];
  62045. /** The expected number of textures the system is parsing. */
  62046. private _expecting;
  62047. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62048. private _paddingValue;
  62049. /**
  62050. * Initializes a texture package series from an array of meshes or a single mesh.
  62051. * @param name The name of the package
  62052. * @param meshes The target meshes to compose the package from
  62053. * @param options The arguments that texture packer should follow while building.
  62054. * @param scene The scene which the textures are scoped to.
  62055. * @returns TexturePacker
  62056. */
  62057. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62058. /**
  62059. * Starts the package process
  62060. * @param resolve The promises resolution function
  62061. * @returns TexturePacker
  62062. */
  62063. private _createFrames;
  62064. /**
  62065. * Calculates the Size of the Channel Sets
  62066. * @returns Vector2
  62067. */
  62068. private _calculateSize;
  62069. /**
  62070. * Calculates the UV data for the frames.
  62071. * @param baseSize the base frameSize
  62072. * @param padding the base frame padding
  62073. * @param dtSize size of the Dynamic Texture for that channel
  62074. * @param dtUnits is 1/dtSize
  62075. * @param update flag to update the input meshes
  62076. */
  62077. private _calculateMeshUVFrames;
  62078. /**
  62079. * Calculates the frames Offset.
  62080. * @param index of the frame
  62081. * @returns Vector2
  62082. */
  62083. private _getFrameOffset;
  62084. /**
  62085. * Updates a Mesh to the frame data
  62086. * @param mesh that is the target
  62087. * @param frameID or the frame index
  62088. */
  62089. private _updateMeshUV;
  62090. /**
  62091. * Updates a Meshes materials to use the texture packer channels
  62092. * @param m is the mesh to target
  62093. * @param force all channels on the packer to be set.
  62094. */
  62095. private _updateTextureReferences;
  62096. /**
  62097. * Public method to set a Mesh to a frame
  62098. * @param m that is the target
  62099. * @param frameID or the frame index
  62100. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62101. */
  62102. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62103. /**
  62104. * Starts the async promise to compile the texture packer.
  62105. * @returns Promise<void>
  62106. */
  62107. processAsync(): Promise<void>;
  62108. /**
  62109. * Disposes all textures associated with this packer
  62110. */
  62111. dispose(): void;
  62112. /**
  62113. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62114. * @param imageType is the image type to use.
  62115. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62116. */
  62117. download(imageType?: string, quality?: number): void;
  62118. /**
  62119. * Public method to load a texturePacker JSON file.
  62120. * @param data of the JSON file in string format.
  62121. */
  62122. updateFromJSON(data: string): void;
  62123. }
  62124. }
  62125. declare module BABYLON {
  62126. /**
  62127. * 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.
  62128. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62129. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62130. */
  62131. export class CustomProceduralTexture extends ProceduralTexture {
  62132. private _animate;
  62133. private _time;
  62134. private _config;
  62135. private _texturePath;
  62136. /**
  62137. * Instantiates a new Custom Procedural Texture.
  62138. * 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.
  62139. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62140. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62141. * @param name Define the name of the texture
  62142. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62143. * @param size Define the size of the texture to create
  62144. * @param scene Define the scene the texture belongs to
  62145. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62146. * @param generateMipMaps Define if the texture should creates mip maps or not
  62147. */
  62148. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62149. private _loadJson;
  62150. /**
  62151. * Is the texture ready to be used ? (rendered at least once)
  62152. * @returns true if ready, otherwise, false.
  62153. */
  62154. isReady(): boolean;
  62155. /**
  62156. * Render the texture to its associated render target.
  62157. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62158. */
  62159. render(useCameraPostProcess?: boolean): void;
  62160. /**
  62161. * Update the list of dependant textures samplers in the shader.
  62162. */
  62163. updateTextures(): void;
  62164. /**
  62165. * Update the uniform values of the procedural texture in the shader.
  62166. */
  62167. updateShaderUniforms(): void;
  62168. /**
  62169. * Define if the texture animates or not.
  62170. */
  62171. get animate(): boolean;
  62172. set animate(value: boolean);
  62173. }
  62174. }
  62175. declare module BABYLON {
  62176. /** @hidden */
  62177. export var noisePixelShader: {
  62178. name: string;
  62179. shader: string;
  62180. };
  62181. }
  62182. declare module BABYLON {
  62183. /**
  62184. * Class used to generate noise procedural textures
  62185. */
  62186. export class NoiseProceduralTexture extends ProceduralTexture {
  62187. /** Gets or sets the start time (default is 0) */
  62188. time: number;
  62189. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62190. brightness: number;
  62191. /** Defines the number of octaves to process */
  62192. octaves: number;
  62193. /** Defines the level of persistence (0.8 by default) */
  62194. persistence: number;
  62195. /** Gets or sets animation speed factor (default is 1) */
  62196. animationSpeedFactor: number;
  62197. /**
  62198. * Creates a new NoiseProceduralTexture
  62199. * @param name defines the name fo the texture
  62200. * @param size defines the size of the texture (default is 256)
  62201. * @param scene defines the hosting scene
  62202. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62203. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62204. */
  62205. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62206. private _updateShaderUniforms;
  62207. protected _getDefines(): string;
  62208. /** Generate the current state of the procedural texture */
  62209. render(useCameraPostProcess?: boolean): void;
  62210. /**
  62211. * Serializes this noise procedural texture
  62212. * @returns a serialized noise procedural texture object
  62213. */
  62214. serialize(): any;
  62215. /**
  62216. * Clone the texture.
  62217. * @returns the cloned texture
  62218. */
  62219. clone(): NoiseProceduralTexture;
  62220. /**
  62221. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62222. * @param parsedTexture defines parsed texture data
  62223. * @param scene defines the current scene
  62224. * @param rootUrl defines the root URL containing noise procedural texture information
  62225. * @returns a parsed NoiseProceduralTexture
  62226. */
  62227. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62228. }
  62229. }
  62230. declare module BABYLON {
  62231. /**
  62232. * Raw cube texture where the raw buffers are passed in
  62233. */
  62234. export class RawCubeTexture extends CubeTexture {
  62235. /**
  62236. * Creates a cube texture where the raw buffers are passed in.
  62237. * @param scene defines the scene the texture is attached to
  62238. * @param data defines the array of data to use to create each face
  62239. * @param size defines the size of the textures
  62240. * @param format defines the format of the data
  62241. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62242. * @param generateMipMaps defines if the engine should generate the mip levels
  62243. * @param invertY defines if data must be stored with Y axis inverted
  62244. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62245. * @param compression defines the compression used (null by default)
  62246. */
  62247. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62248. /**
  62249. * Updates the raw cube texture.
  62250. * @param data defines the data to store
  62251. * @param format defines the data format
  62252. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62253. * @param invertY defines if data must be stored with Y axis inverted
  62254. * @param compression defines the compression used (null by default)
  62255. * @param level defines which level of the texture to update
  62256. */
  62257. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62258. /**
  62259. * Updates a raw cube texture with RGBD encoded data.
  62260. * @param data defines the array of data [mipmap][face] to use to create each face
  62261. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62262. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62263. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62264. * @returns a promsie that resolves when the operation is complete
  62265. */
  62266. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62267. /**
  62268. * Clones the raw cube texture.
  62269. * @return a new cube texture
  62270. */
  62271. clone(): CubeTexture;
  62272. /** @hidden */
  62273. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62274. }
  62275. }
  62276. declare module BABYLON {
  62277. /**
  62278. * Class used to store 2D array textures containing user data
  62279. */
  62280. export class RawTexture2DArray extends Texture {
  62281. /** Gets or sets the texture format to use */
  62282. format: number;
  62283. /**
  62284. * Create a new RawTexture2DArray
  62285. * @param data defines the data of the texture
  62286. * @param width defines the width of the texture
  62287. * @param height defines the height of the texture
  62288. * @param depth defines the number of layers of the texture
  62289. * @param format defines the texture format to use
  62290. * @param scene defines the hosting scene
  62291. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62292. * @param invertY defines if texture must be stored with Y axis inverted
  62293. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62294. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62295. */
  62296. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62297. /** Gets or sets the texture format to use */
  62298. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62299. /**
  62300. * Update the texture with new data
  62301. * @param data defines the data to store in the texture
  62302. */
  62303. update(data: ArrayBufferView): void;
  62304. }
  62305. }
  62306. declare module BABYLON {
  62307. /**
  62308. * Class used to store 3D textures containing user data
  62309. */
  62310. export class RawTexture3D extends Texture {
  62311. /** Gets or sets the texture format to use */
  62312. format: number;
  62313. /**
  62314. * Create a new RawTexture3D
  62315. * @param data defines the data of the texture
  62316. * @param width defines the width of the texture
  62317. * @param height defines the height of the texture
  62318. * @param depth defines the depth of the texture
  62319. * @param format defines the texture format to use
  62320. * @param scene defines the hosting scene
  62321. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62322. * @param invertY defines if texture must be stored with Y axis inverted
  62323. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62324. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62325. */
  62326. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62327. /** Gets or sets the texture format to use */
  62328. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62329. /**
  62330. * Update the texture with new data
  62331. * @param data defines the data to store in the texture
  62332. */
  62333. update(data: ArrayBufferView): void;
  62334. }
  62335. }
  62336. declare module BABYLON {
  62337. /**
  62338. * Creates a refraction texture used by refraction channel of the standard material.
  62339. * It is like a mirror but to see through a material.
  62340. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62341. */
  62342. export class RefractionTexture extends RenderTargetTexture {
  62343. /**
  62344. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62345. * 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.
  62346. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62347. */
  62348. refractionPlane: Plane;
  62349. /**
  62350. * Define how deep under the surface we should see.
  62351. */
  62352. depth: number;
  62353. /**
  62354. * Creates a refraction texture used by refraction channel of the standard material.
  62355. * It is like a mirror but to see through a material.
  62356. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62357. * @param name Define the texture name
  62358. * @param size Define the size of the underlying texture
  62359. * @param scene Define the scene the refraction belongs to
  62360. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62361. */
  62362. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62363. /**
  62364. * Clone the refraction texture.
  62365. * @returns the cloned texture
  62366. */
  62367. clone(): RefractionTexture;
  62368. /**
  62369. * Serialize the texture to a JSON representation you could use in Parse later on
  62370. * @returns the serialized JSON representation
  62371. */
  62372. serialize(): any;
  62373. }
  62374. }
  62375. declare module BABYLON {
  62376. /**
  62377. * Block used to add support for vertex skinning (bones)
  62378. */
  62379. export class BonesBlock extends NodeMaterialBlock {
  62380. /**
  62381. * Creates a new BonesBlock
  62382. * @param name defines the block name
  62383. */
  62384. constructor(name: string);
  62385. /**
  62386. * Initialize the block and prepare the context for build
  62387. * @param state defines the state that will be used for the build
  62388. */
  62389. initialize(state: NodeMaterialBuildState): void;
  62390. /**
  62391. * Gets the current class name
  62392. * @returns the class name
  62393. */
  62394. getClassName(): string;
  62395. /**
  62396. * Gets the matrix indices input component
  62397. */
  62398. get matricesIndices(): NodeMaterialConnectionPoint;
  62399. /**
  62400. * Gets the matrix weights input component
  62401. */
  62402. get matricesWeights(): NodeMaterialConnectionPoint;
  62403. /**
  62404. * Gets the extra matrix indices input component
  62405. */
  62406. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62407. /**
  62408. * Gets the extra matrix weights input component
  62409. */
  62410. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62411. /**
  62412. * Gets the world input component
  62413. */
  62414. get world(): NodeMaterialConnectionPoint;
  62415. /**
  62416. * Gets the output component
  62417. */
  62418. get output(): NodeMaterialConnectionPoint;
  62419. autoConfigure(material: NodeMaterial): void;
  62420. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62421. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62422. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62423. protected _buildBlock(state: NodeMaterialBuildState): this;
  62424. }
  62425. }
  62426. declare module BABYLON {
  62427. /**
  62428. * Block used to add support for instances
  62429. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62430. */
  62431. export class InstancesBlock extends NodeMaterialBlock {
  62432. /**
  62433. * Creates a new InstancesBlock
  62434. * @param name defines the block name
  62435. */
  62436. constructor(name: string);
  62437. /**
  62438. * Gets the current class name
  62439. * @returns the class name
  62440. */
  62441. getClassName(): string;
  62442. /**
  62443. * Gets the first world row input component
  62444. */
  62445. get world0(): NodeMaterialConnectionPoint;
  62446. /**
  62447. * Gets the second world row input component
  62448. */
  62449. get world1(): NodeMaterialConnectionPoint;
  62450. /**
  62451. * Gets the third world row input component
  62452. */
  62453. get world2(): NodeMaterialConnectionPoint;
  62454. /**
  62455. * Gets the forth world row input component
  62456. */
  62457. get world3(): NodeMaterialConnectionPoint;
  62458. /**
  62459. * Gets the world input component
  62460. */
  62461. get world(): NodeMaterialConnectionPoint;
  62462. /**
  62463. * Gets the output component
  62464. */
  62465. get output(): NodeMaterialConnectionPoint;
  62466. /**
  62467. * Gets the isntanceID component
  62468. */
  62469. get instanceID(): NodeMaterialConnectionPoint;
  62470. autoConfigure(material: NodeMaterial): void;
  62471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62472. protected _buildBlock(state: NodeMaterialBuildState): this;
  62473. }
  62474. }
  62475. declare module BABYLON {
  62476. /**
  62477. * Block used to add morph targets support to vertex shader
  62478. */
  62479. export class MorphTargetsBlock extends NodeMaterialBlock {
  62480. private _repeatableContentAnchor;
  62481. /**
  62482. * Create a new MorphTargetsBlock
  62483. * @param name defines the block name
  62484. */
  62485. constructor(name: string);
  62486. /**
  62487. * Gets the current class name
  62488. * @returns the class name
  62489. */
  62490. getClassName(): string;
  62491. /**
  62492. * Gets the position input component
  62493. */
  62494. get position(): NodeMaterialConnectionPoint;
  62495. /**
  62496. * Gets the normal input component
  62497. */
  62498. get normal(): NodeMaterialConnectionPoint;
  62499. /**
  62500. * Gets the tangent input component
  62501. */
  62502. get tangent(): NodeMaterialConnectionPoint;
  62503. /**
  62504. * Gets the tangent input component
  62505. */
  62506. get uv(): NodeMaterialConnectionPoint;
  62507. /**
  62508. * Gets the position output component
  62509. */
  62510. get positionOutput(): NodeMaterialConnectionPoint;
  62511. /**
  62512. * Gets the normal output component
  62513. */
  62514. get normalOutput(): NodeMaterialConnectionPoint;
  62515. /**
  62516. * Gets the tangent output component
  62517. */
  62518. get tangentOutput(): NodeMaterialConnectionPoint;
  62519. /**
  62520. * Gets the tangent output component
  62521. */
  62522. get uvOutput(): NodeMaterialConnectionPoint;
  62523. initialize(state: NodeMaterialBuildState): void;
  62524. autoConfigure(material: NodeMaterial): void;
  62525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62527. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62528. protected _buildBlock(state: NodeMaterialBuildState): this;
  62529. }
  62530. }
  62531. declare module BABYLON {
  62532. /**
  62533. * Block used to get data information from a light
  62534. */
  62535. export class LightInformationBlock extends NodeMaterialBlock {
  62536. private _lightDataUniformName;
  62537. private _lightColorUniformName;
  62538. private _lightTypeDefineName;
  62539. /**
  62540. * Gets or sets the light associated with this block
  62541. */
  62542. light: Nullable<Light>;
  62543. /**
  62544. * Creates a new LightInformationBlock
  62545. * @param name defines the block name
  62546. */
  62547. constructor(name: string);
  62548. /**
  62549. * Gets the current class name
  62550. * @returns the class name
  62551. */
  62552. getClassName(): string;
  62553. /**
  62554. * Gets the world position input component
  62555. */
  62556. get worldPosition(): NodeMaterialConnectionPoint;
  62557. /**
  62558. * Gets the direction output component
  62559. */
  62560. get direction(): NodeMaterialConnectionPoint;
  62561. /**
  62562. * Gets the direction output component
  62563. */
  62564. get color(): NodeMaterialConnectionPoint;
  62565. /**
  62566. * Gets the direction output component
  62567. */
  62568. get intensity(): NodeMaterialConnectionPoint;
  62569. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62571. protected _buildBlock(state: NodeMaterialBuildState): this;
  62572. serialize(): any;
  62573. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62574. }
  62575. }
  62576. declare module BABYLON {
  62577. /**
  62578. * Block used to add image processing support to fragment shader
  62579. */
  62580. export class ImageProcessingBlock extends NodeMaterialBlock {
  62581. /**
  62582. * Create a new ImageProcessingBlock
  62583. * @param name defines the block name
  62584. */
  62585. constructor(name: string);
  62586. /**
  62587. * Gets the current class name
  62588. * @returns the class name
  62589. */
  62590. getClassName(): string;
  62591. /**
  62592. * Gets the color input component
  62593. */
  62594. get color(): NodeMaterialConnectionPoint;
  62595. /**
  62596. * Gets the output component
  62597. */
  62598. get output(): NodeMaterialConnectionPoint;
  62599. /**
  62600. * Initialize the block and prepare the context for build
  62601. * @param state defines the state that will be used for the build
  62602. */
  62603. initialize(state: NodeMaterialBuildState): void;
  62604. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62605. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62606. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62607. protected _buildBlock(state: NodeMaterialBuildState): this;
  62608. }
  62609. }
  62610. declare module BABYLON {
  62611. /**
  62612. * Block used to pertub normals based on a normal map
  62613. */
  62614. export class PerturbNormalBlock extends NodeMaterialBlock {
  62615. private _tangentSpaceParameterName;
  62616. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62617. invertX: boolean;
  62618. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62619. invertY: boolean;
  62620. /**
  62621. * Create a new PerturbNormalBlock
  62622. * @param name defines the block name
  62623. */
  62624. constructor(name: string);
  62625. /**
  62626. * Gets the current class name
  62627. * @returns the class name
  62628. */
  62629. getClassName(): string;
  62630. /**
  62631. * Gets the world position input component
  62632. */
  62633. get worldPosition(): NodeMaterialConnectionPoint;
  62634. /**
  62635. * Gets the world normal input component
  62636. */
  62637. get worldNormal(): NodeMaterialConnectionPoint;
  62638. /**
  62639. * Gets the world tangent input component
  62640. */
  62641. get worldTangent(): NodeMaterialConnectionPoint;
  62642. /**
  62643. * Gets the uv input component
  62644. */
  62645. get uv(): NodeMaterialConnectionPoint;
  62646. /**
  62647. * Gets the normal map color input component
  62648. */
  62649. get normalMapColor(): NodeMaterialConnectionPoint;
  62650. /**
  62651. * Gets the strength input component
  62652. */
  62653. get strength(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the output component
  62656. */
  62657. get output(): NodeMaterialConnectionPoint;
  62658. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62659. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62660. autoConfigure(material: NodeMaterial): void;
  62661. protected _buildBlock(state: NodeMaterialBuildState): this;
  62662. protected _dumpPropertiesCode(): string;
  62663. serialize(): any;
  62664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62665. }
  62666. }
  62667. declare module BABYLON {
  62668. /**
  62669. * Block used to discard a pixel if a value is smaller than a cutoff
  62670. */
  62671. export class DiscardBlock extends NodeMaterialBlock {
  62672. /**
  62673. * Create a new DiscardBlock
  62674. * @param name defines the block name
  62675. */
  62676. constructor(name: string);
  62677. /**
  62678. * Gets the current class name
  62679. * @returns the class name
  62680. */
  62681. getClassName(): string;
  62682. /**
  62683. * Gets the color input component
  62684. */
  62685. get value(): NodeMaterialConnectionPoint;
  62686. /**
  62687. * Gets the cutoff input component
  62688. */
  62689. get cutoff(): NodeMaterialConnectionPoint;
  62690. protected _buildBlock(state: NodeMaterialBuildState): this;
  62691. }
  62692. }
  62693. declare module BABYLON {
  62694. /**
  62695. * Block used to test if the fragment shader is front facing
  62696. */
  62697. export class FrontFacingBlock extends NodeMaterialBlock {
  62698. /**
  62699. * Creates a new FrontFacingBlock
  62700. * @param name defines the block name
  62701. */
  62702. constructor(name: string);
  62703. /**
  62704. * Gets the current class name
  62705. * @returns the class name
  62706. */
  62707. getClassName(): string;
  62708. /**
  62709. * Gets the output component
  62710. */
  62711. get output(): NodeMaterialConnectionPoint;
  62712. protected _buildBlock(state: NodeMaterialBuildState): this;
  62713. }
  62714. }
  62715. declare module BABYLON {
  62716. /**
  62717. * Block used to get the derivative value on x and y of a given input
  62718. */
  62719. export class DerivativeBlock extends NodeMaterialBlock {
  62720. /**
  62721. * Create a new DerivativeBlock
  62722. * @param name defines the block name
  62723. */
  62724. constructor(name: string);
  62725. /**
  62726. * Gets the current class name
  62727. * @returns the class name
  62728. */
  62729. getClassName(): string;
  62730. /**
  62731. * Gets the input component
  62732. */
  62733. get input(): NodeMaterialConnectionPoint;
  62734. /**
  62735. * Gets the derivative output on x
  62736. */
  62737. get dx(): NodeMaterialConnectionPoint;
  62738. /**
  62739. * Gets the derivative output on y
  62740. */
  62741. get dy(): NodeMaterialConnectionPoint;
  62742. protected _buildBlock(state: NodeMaterialBuildState): this;
  62743. }
  62744. }
  62745. declare module BABYLON {
  62746. /**
  62747. * Block used to make gl_FragCoord available
  62748. */
  62749. export class FragCoordBlock extends NodeMaterialBlock {
  62750. /**
  62751. * Creates a new FragCoordBlock
  62752. * @param name defines the block name
  62753. */
  62754. constructor(name: string);
  62755. /**
  62756. * Gets the current class name
  62757. * @returns the class name
  62758. */
  62759. getClassName(): string;
  62760. /**
  62761. * Gets the xy component
  62762. */
  62763. get xy(): NodeMaterialConnectionPoint;
  62764. /**
  62765. * Gets the xyz component
  62766. */
  62767. get xyz(): NodeMaterialConnectionPoint;
  62768. /**
  62769. * Gets the xyzw component
  62770. */
  62771. get xyzw(): NodeMaterialConnectionPoint;
  62772. /**
  62773. * Gets the x component
  62774. */
  62775. get x(): NodeMaterialConnectionPoint;
  62776. /**
  62777. * Gets the y component
  62778. */
  62779. get y(): NodeMaterialConnectionPoint;
  62780. /**
  62781. * Gets the z component
  62782. */
  62783. get z(): NodeMaterialConnectionPoint;
  62784. /**
  62785. * Gets the w component
  62786. */
  62787. get output(): NodeMaterialConnectionPoint;
  62788. protected writeOutputs(state: NodeMaterialBuildState): string;
  62789. protected _buildBlock(state: NodeMaterialBuildState): this;
  62790. }
  62791. }
  62792. declare module BABYLON {
  62793. /**
  62794. * Block used to get the screen sizes
  62795. */
  62796. export class ScreenSizeBlock extends NodeMaterialBlock {
  62797. private _varName;
  62798. private _scene;
  62799. /**
  62800. * Creates a new ScreenSizeBlock
  62801. * @param name defines the block name
  62802. */
  62803. constructor(name: string);
  62804. /**
  62805. * Gets the current class name
  62806. * @returns the class name
  62807. */
  62808. getClassName(): string;
  62809. /**
  62810. * Gets the xy component
  62811. */
  62812. get xy(): NodeMaterialConnectionPoint;
  62813. /**
  62814. * Gets the x component
  62815. */
  62816. get x(): NodeMaterialConnectionPoint;
  62817. /**
  62818. * Gets the y component
  62819. */
  62820. get y(): NodeMaterialConnectionPoint;
  62821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62822. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62823. protected _buildBlock(state: NodeMaterialBuildState): this;
  62824. }
  62825. }
  62826. declare module BABYLON {
  62827. /**
  62828. * Block used to add support for scene fog
  62829. */
  62830. export class FogBlock extends NodeMaterialBlock {
  62831. private _fogDistanceName;
  62832. private _fogParameters;
  62833. /**
  62834. * Create a new FogBlock
  62835. * @param name defines the block name
  62836. */
  62837. constructor(name: string);
  62838. /**
  62839. * Gets the current class name
  62840. * @returns the class name
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * Gets the world position input component
  62845. */
  62846. get worldPosition(): NodeMaterialConnectionPoint;
  62847. /**
  62848. * Gets the view input component
  62849. */
  62850. get view(): NodeMaterialConnectionPoint;
  62851. /**
  62852. * Gets the color input component
  62853. */
  62854. get input(): NodeMaterialConnectionPoint;
  62855. /**
  62856. * Gets the fog color input component
  62857. */
  62858. get fogColor(): NodeMaterialConnectionPoint;
  62859. /**
  62860. * Gets the output component
  62861. */
  62862. get output(): NodeMaterialConnectionPoint;
  62863. autoConfigure(material: NodeMaterial): void;
  62864. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62865. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62866. protected _buildBlock(state: NodeMaterialBuildState): this;
  62867. }
  62868. }
  62869. declare module BABYLON {
  62870. /**
  62871. * Block used to add light in the fragment shader
  62872. */
  62873. export class LightBlock extends NodeMaterialBlock {
  62874. private _lightId;
  62875. /**
  62876. * Gets or sets the light associated with this block
  62877. */
  62878. light: Nullable<Light>;
  62879. /**
  62880. * Create a new LightBlock
  62881. * @param name defines the block name
  62882. */
  62883. constructor(name: string);
  62884. /**
  62885. * Gets the current class name
  62886. * @returns the class name
  62887. */
  62888. getClassName(): string;
  62889. /**
  62890. * Gets the world position input component
  62891. */
  62892. get worldPosition(): NodeMaterialConnectionPoint;
  62893. /**
  62894. * Gets the world normal input component
  62895. */
  62896. get worldNormal(): NodeMaterialConnectionPoint;
  62897. /**
  62898. * Gets the camera (or eye) position component
  62899. */
  62900. get cameraPosition(): NodeMaterialConnectionPoint;
  62901. /**
  62902. * Gets the glossiness component
  62903. */
  62904. get glossiness(): NodeMaterialConnectionPoint;
  62905. /**
  62906. * Gets the glossinness power component
  62907. */
  62908. get glossPower(): NodeMaterialConnectionPoint;
  62909. /**
  62910. * Gets the diffuse color component
  62911. */
  62912. get diffuseColor(): NodeMaterialConnectionPoint;
  62913. /**
  62914. * Gets the specular color component
  62915. */
  62916. get specularColor(): NodeMaterialConnectionPoint;
  62917. /**
  62918. * Gets the diffuse output component
  62919. */
  62920. get diffuseOutput(): NodeMaterialConnectionPoint;
  62921. /**
  62922. * Gets the specular output component
  62923. */
  62924. get specularOutput(): NodeMaterialConnectionPoint;
  62925. /**
  62926. * Gets the shadow output component
  62927. */
  62928. get shadow(): NodeMaterialConnectionPoint;
  62929. autoConfigure(material: NodeMaterial): void;
  62930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62931. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62932. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62933. private _injectVertexCode;
  62934. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62935. serialize(): any;
  62936. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62937. }
  62938. }
  62939. declare module BABYLON {
  62940. /**
  62941. * Block used to read a reflection texture from a sampler
  62942. */
  62943. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62944. /**
  62945. * Create a new ReflectionTextureBlock
  62946. * @param name defines the block name
  62947. */
  62948. constructor(name: string);
  62949. /**
  62950. * Gets the current class name
  62951. * @returns the class name
  62952. */
  62953. getClassName(): string;
  62954. /**
  62955. * Gets the world position input component
  62956. */
  62957. get position(): NodeMaterialConnectionPoint;
  62958. /**
  62959. * Gets the world position input component
  62960. */
  62961. get worldPosition(): NodeMaterialConnectionPoint;
  62962. /**
  62963. * Gets the world normal input component
  62964. */
  62965. get worldNormal(): NodeMaterialConnectionPoint;
  62966. /**
  62967. * Gets the world input component
  62968. */
  62969. get world(): NodeMaterialConnectionPoint;
  62970. /**
  62971. * Gets the camera (or eye) position component
  62972. */
  62973. get cameraPosition(): NodeMaterialConnectionPoint;
  62974. /**
  62975. * Gets the view input component
  62976. */
  62977. get view(): NodeMaterialConnectionPoint;
  62978. /**
  62979. * Gets the rgb output component
  62980. */
  62981. get rgb(): NodeMaterialConnectionPoint;
  62982. /**
  62983. * Gets the rgba output component
  62984. */
  62985. get rgba(): NodeMaterialConnectionPoint;
  62986. /**
  62987. * Gets the r output component
  62988. */
  62989. get r(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the g output component
  62992. */
  62993. get g(): NodeMaterialConnectionPoint;
  62994. /**
  62995. * Gets the b output component
  62996. */
  62997. get b(): NodeMaterialConnectionPoint;
  62998. /**
  62999. * Gets the a output component
  63000. */
  63001. get a(): NodeMaterialConnectionPoint;
  63002. autoConfigure(material: NodeMaterial): void;
  63003. protected _buildBlock(state: NodeMaterialBuildState): this;
  63004. }
  63005. }
  63006. declare module BABYLON {
  63007. /**
  63008. * Block used to add 2 vectors
  63009. */
  63010. export class AddBlock extends NodeMaterialBlock {
  63011. /**
  63012. * Creates a new AddBlock
  63013. * @param name defines the block name
  63014. */
  63015. constructor(name: string);
  63016. /**
  63017. * Gets the current class name
  63018. * @returns the class name
  63019. */
  63020. getClassName(): string;
  63021. /**
  63022. * Gets the left operand input component
  63023. */
  63024. get left(): NodeMaterialConnectionPoint;
  63025. /**
  63026. * Gets the right operand input component
  63027. */
  63028. get right(): NodeMaterialConnectionPoint;
  63029. /**
  63030. * Gets the output component
  63031. */
  63032. get output(): NodeMaterialConnectionPoint;
  63033. protected _buildBlock(state: NodeMaterialBuildState): this;
  63034. }
  63035. }
  63036. declare module BABYLON {
  63037. /**
  63038. * Block used to scale a vector by a float
  63039. */
  63040. export class ScaleBlock extends NodeMaterialBlock {
  63041. /**
  63042. * Creates a new ScaleBlock
  63043. * @param name defines the block name
  63044. */
  63045. constructor(name: string);
  63046. /**
  63047. * Gets the current class name
  63048. * @returns the class name
  63049. */
  63050. getClassName(): string;
  63051. /**
  63052. * Gets the input component
  63053. */
  63054. get input(): NodeMaterialConnectionPoint;
  63055. /**
  63056. * Gets the factor input component
  63057. */
  63058. get factor(): NodeMaterialConnectionPoint;
  63059. /**
  63060. * Gets the output component
  63061. */
  63062. get output(): NodeMaterialConnectionPoint;
  63063. protected _buildBlock(state: NodeMaterialBuildState): this;
  63064. }
  63065. }
  63066. declare module BABYLON {
  63067. /**
  63068. * Block used to clamp a float
  63069. */
  63070. export class ClampBlock extends NodeMaterialBlock {
  63071. /** Gets or sets the minimum range */
  63072. minimum: number;
  63073. /** Gets or sets the maximum range */
  63074. maximum: number;
  63075. /**
  63076. * Creates a new ClampBlock
  63077. * @param name defines the block name
  63078. */
  63079. constructor(name: string);
  63080. /**
  63081. * Gets the current class name
  63082. * @returns the class name
  63083. */
  63084. getClassName(): string;
  63085. /**
  63086. * Gets the value input component
  63087. */
  63088. get value(): NodeMaterialConnectionPoint;
  63089. /**
  63090. * Gets the output component
  63091. */
  63092. get output(): NodeMaterialConnectionPoint;
  63093. protected _buildBlock(state: NodeMaterialBuildState): this;
  63094. protected _dumpPropertiesCode(): string;
  63095. serialize(): any;
  63096. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63097. }
  63098. }
  63099. declare module BABYLON {
  63100. /**
  63101. * Block used to apply a cross product between 2 vectors
  63102. */
  63103. export class CrossBlock extends NodeMaterialBlock {
  63104. /**
  63105. * Creates a new CrossBlock
  63106. * @param name defines the block name
  63107. */
  63108. constructor(name: string);
  63109. /**
  63110. * Gets the current class name
  63111. * @returns the class name
  63112. */
  63113. getClassName(): string;
  63114. /**
  63115. * Gets the left operand input component
  63116. */
  63117. get left(): NodeMaterialConnectionPoint;
  63118. /**
  63119. * Gets the right operand input component
  63120. */
  63121. get right(): NodeMaterialConnectionPoint;
  63122. /**
  63123. * Gets the output component
  63124. */
  63125. get output(): NodeMaterialConnectionPoint;
  63126. protected _buildBlock(state: NodeMaterialBuildState): this;
  63127. }
  63128. }
  63129. declare module BABYLON {
  63130. /**
  63131. * Block used to apply a dot product between 2 vectors
  63132. */
  63133. export class DotBlock extends NodeMaterialBlock {
  63134. /**
  63135. * Creates a new DotBlock
  63136. * @param name defines the block name
  63137. */
  63138. constructor(name: string);
  63139. /**
  63140. * Gets the current class name
  63141. * @returns the class name
  63142. */
  63143. getClassName(): string;
  63144. /**
  63145. * Gets the left operand input component
  63146. */
  63147. get left(): NodeMaterialConnectionPoint;
  63148. /**
  63149. * Gets the right operand input component
  63150. */
  63151. get right(): NodeMaterialConnectionPoint;
  63152. /**
  63153. * Gets the output component
  63154. */
  63155. get output(): NodeMaterialConnectionPoint;
  63156. protected _buildBlock(state: NodeMaterialBuildState): this;
  63157. }
  63158. }
  63159. declare module BABYLON {
  63160. /**
  63161. * Block used to normalize a vector
  63162. */
  63163. export class NormalizeBlock extends NodeMaterialBlock {
  63164. /**
  63165. * Creates a new NormalizeBlock
  63166. * @param name defines the block name
  63167. */
  63168. constructor(name: string);
  63169. /**
  63170. * Gets the current class name
  63171. * @returns the class name
  63172. */
  63173. getClassName(): string;
  63174. /**
  63175. * Gets the input component
  63176. */
  63177. get input(): NodeMaterialConnectionPoint;
  63178. /**
  63179. * Gets the output component
  63180. */
  63181. get output(): NodeMaterialConnectionPoint;
  63182. protected _buildBlock(state: NodeMaterialBuildState): this;
  63183. }
  63184. }
  63185. declare module BABYLON {
  63186. /**
  63187. * Operations supported by the Trigonometry block
  63188. */
  63189. export enum TrigonometryBlockOperations {
  63190. /** Cos */
  63191. Cos = 0,
  63192. /** Sin */
  63193. Sin = 1,
  63194. /** Abs */
  63195. Abs = 2,
  63196. /** Exp */
  63197. Exp = 3,
  63198. /** Exp2 */
  63199. Exp2 = 4,
  63200. /** Round */
  63201. Round = 5,
  63202. /** Floor */
  63203. Floor = 6,
  63204. /** Ceiling */
  63205. Ceiling = 7,
  63206. /** Square root */
  63207. Sqrt = 8,
  63208. /** Log */
  63209. Log = 9,
  63210. /** Tangent */
  63211. Tan = 10,
  63212. /** Arc tangent */
  63213. ArcTan = 11,
  63214. /** Arc cosinus */
  63215. ArcCos = 12,
  63216. /** Arc sinus */
  63217. ArcSin = 13,
  63218. /** Fraction */
  63219. Fract = 14,
  63220. /** Sign */
  63221. Sign = 15,
  63222. /** To radians (from degrees) */
  63223. Radians = 16,
  63224. /** To degrees (from radians) */
  63225. Degrees = 17
  63226. }
  63227. /**
  63228. * Block used to apply trigonometry operation to floats
  63229. */
  63230. export class TrigonometryBlock extends NodeMaterialBlock {
  63231. /**
  63232. * Gets or sets the operation applied by the block
  63233. */
  63234. operation: TrigonometryBlockOperations;
  63235. /**
  63236. * Creates a new TrigonometryBlock
  63237. * @param name defines the block name
  63238. */
  63239. constructor(name: string);
  63240. /**
  63241. * Gets the current class name
  63242. * @returns the class name
  63243. */
  63244. getClassName(): string;
  63245. /**
  63246. * Gets the input component
  63247. */
  63248. get input(): NodeMaterialConnectionPoint;
  63249. /**
  63250. * Gets the output component
  63251. */
  63252. get output(): NodeMaterialConnectionPoint;
  63253. protected _buildBlock(state: NodeMaterialBuildState): this;
  63254. serialize(): any;
  63255. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63256. protected _dumpPropertiesCode(): string;
  63257. }
  63258. }
  63259. declare module BABYLON {
  63260. /**
  63261. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63262. */
  63263. export class ColorMergerBlock extends NodeMaterialBlock {
  63264. /**
  63265. * Create a new ColorMergerBlock
  63266. * @param name defines the block name
  63267. */
  63268. constructor(name: string);
  63269. /**
  63270. * Gets the current class name
  63271. * @returns the class name
  63272. */
  63273. getClassName(): string;
  63274. /**
  63275. * Gets the rgb component (input)
  63276. */
  63277. get rgbIn(): NodeMaterialConnectionPoint;
  63278. /**
  63279. * Gets the r component (input)
  63280. */
  63281. get r(): NodeMaterialConnectionPoint;
  63282. /**
  63283. * Gets the g component (input)
  63284. */
  63285. get g(): NodeMaterialConnectionPoint;
  63286. /**
  63287. * Gets the b component (input)
  63288. */
  63289. get b(): NodeMaterialConnectionPoint;
  63290. /**
  63291. * Gets the a component (input)
  63292. */
  63293. get a(): NodeMaterialConnectionPoint;
  63294. /**
  63295. * Gets the rgba component (output)
  63296. */
  63297. get rgba(): NodeMaterialConnectionPoint;
  63298. /**
  63299. * Gets the rgb component (output)
  63300. */
  63301. get rgbOut(): NodeMaterialConnectionPoint;
  63302. /**
  63303. * Gets the rgb component (output)
  63304. * @deprecated Please use rgbOut instead.
  63305. */
  63306. get rgb(): NodeMaterialConnectionPoint;
  63307. protected _buildBlock(state: NodeMaterialBuildState): this;
  63308. }
  63309. }
  63310. declare module BABYLON {
  63311. /**
  63312. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63313. */
  63314. export class VectorSplitterBlock extends NodeMaterialBlock {
  63315. /**
  63316. * Create a new VectorSplitterBlock
  63317. * @param name defines the block name
  63318. */
  63319. constructor(name: string);
  63320. /**
  63321. * Gets the current class name
  63322. * @returns the class name
  63323. */
  63324. getClassName(): string;
  63325. /**
  63326. * Gets the xyzw component (input)
  63327. */
  63328. get xyzw(): NodeMaterialConnectionPoint;
  63329. /**
  63330. * Gets the xyz component (input)
  63331. */
  63332. get xyzIn(): NodeMaterialConnectionPoint;
  63333. /**
  63334. * Gets the xy component (input)
  63335. */
  63336. get xyIn(): NodeMaterialConnectionPoint;
  63337. /**
  63338. * Gets the xyz component (output)
  63339. */
  63340. get xyzOut(): NodeMaterialConnectionPoint;
  63341. /**
  63342. * Gets the xy component (output)
  63343. */
  63344. get xyOut(): NodeMaterialConnectionPoint;
  63345. /**
  63346. * Gets the x component (output)
  63347. */
  63348. get x(): NodeMaterialConnectionPoint;
  63349. /**
  63350. * Gets the y component (output)
  63351. */
  63352. get y(): NodeMaterialConnectionPoint;
  63353. /**
  63354. * Gets the z component (output)
  63355. */
  63356. get z(): NodeMaterialConnectionPoint;
  63357. /**
  63358. * Gets the w component (output)
  63359. */
  63360. get w(): NodeMaterialConnectionPoint;
  63361. protected _inputRename(name: string): string;
  63362. protected _outputRename(name: string): string;
  63363. protected _buildBlock(state: NodeMaterialBuildState): this;
  63364. }
  63365. }
  63366. declare module BABYLON {
  63367. /**
  63368. * Block used to lerp between 2 values
  63369. */
  63370. export class LerpBlock extends NodeMaterialBlock {
  63371. /**
  63372. * Creates a new LerpBlock
  63373. * @param name defines the block name
  63374. */
  63375. constructor(name: string);
  63376. /**
  63377. * Gets the current class name
  63378. * @returns the class name
  63379. */
  63380. getClassName(): string;
  63381. /**
  63382. * Gets the left operand input component
  63383. */
  63384. get left(): NodeMaterialConnectionPoint;
  63385. /**
  63386. * Gets the right operand input component
  63387. */
  63388. get right(): NodeMaterialConnectionPoint;
  63389. /**
  63390. * Gets the gradient operand input component
  63391. */
  63392. get gradient(): NodeMaterialConnectionPoint;
  63393. /**
  63394. * Gets the output component
  63395. */
  63396. get output(): NodeMaterialConnectionPoint;
  63397. protected _buildBlock(state: NodeMaterialBuildState): this;
  63398. }
  63399. }
  63400. declare module BABYLON {
  63401. /**
  63402. * Block used to divide 2 vectors
  63403. */
  63404. export class DivideBlock extends NodeMaterialBlock {
  63405. /**
  63406. * Creates a new DivideBlock
  63407. * @param name defines the block name
  63408. */
  63409. constructor(name: string);
  63410. /**
  63411. * Gets the current class name
  63412. * @returns the class name
  63413. */
  63414. getClassName(): string;
  63415. /**
  63416. * Gets the left operand input component
  63417. */
  63418. get left(): NodeMaterialConnectionPoint;
  63419. /**
  63420. * Gets the right operand input component
  63421. */
  63422. get right(): NodeMaterialConnectionPoint;
  63423. /**
  63424. * Gets the output component
  63425. */
  63426. get output(): NodeMaterialConnectionPoint;
  63427. protected _buildBlock(state: NodeMaterialBuildState): this;
  63428. }
  63429. }
  63430. declare module BABYLON {
  63431. /**
  63432. * Block used to subtract 2 vectors
  63433. */
  63434. export class SubtractBlock extends NodeMaterialBlock {
  63435. /**
  63436. * Creates a new SubtractBlock
  63437. * @param name defines the block name
  63438. */
  63439. constructor(name: string);
  63440. /**
  63441. * Gets the current class name
  63442. * @returns the class name
  63443. */
  63444. getClassName(): string;
  63445. /**
  63446. * Gets the left operand input component
  63447. */
  63448. get left(): NodeMaterialConnectionPoint;
  63449. /**
  63450. * Gets the right operand input component
  63451. */
  63452. get right(): NodeMaterialConnectionPoint;
  63453. /**
  63454. * Gets the output component
  63455. */
  63456. get output(): NodeMaterialConnectionPoint;
  63457. protected _buildBlock(state: NodeMaterialBuildState): this;
  63458. }
  63459. }
  63460. declare module BABYLON {
  63461. /**
  63462. * Block used to step a value
  63463. */
  63464. export class StepBlock extends NodeMaterialBlock {
  63465. /**
  63466. * Creates a new StepBlock
  63467. * @param name defines the block name
  63468. */
  63469. constructor(name: string);
  63470. /**
  63471. * Gets the current class name
  63472. * @returns the class name
  63473. */
  63474. getClassName(): string;
  63475. /**
  63476. * Gets the value operand input component
  63477. */
  63478. get value(): NodeMaterialConnectionPoint;
  63479. /**
  63480. * Gets the edge operand input component
  63481. */
  63482. get edge(): NodeMaterialConnectionPoint;
  63483. /**
  63484. * Gets the output component
  63485. */
  63486. get output(): NodeMaterialConnectionPoint;
  63487. protected _buildBlock(state: NodeMaterialBuildState): this;
  63488. }
  63489. }
  63490. declare module BABYLON {
  63491. /**
  63492. * Block used to get the opposite (1 - x) of a value
  63493. */
  63494. export class OneMinusBlock extends NodeMaterialBlock {
  63495. /**
  63496. * Creates a new OneMinusBlock
  63497. * @param name defines the block name
  63498. */
  63499. constructor(name: string);
  63500. /**
  63501. * Gets the current class name
  63502. * @returns the class name
  63503. */
  63504. getClassName(): string;
  63505. /**
  63506. * Gets the input component
  63507. */
  63508. get input(): NodeMaterialConnectionPoint;
  63509. /**
  63510. * Gets the output component
  63511. */
  63512. get output(): NodeMaterialConnectionPoint;
  63513. protected _buildBlock(state: NodeMaterialBuildState): this;
  63514. }
  63515. }
  63516. declare module BABYLON {
  63517. /**
  63518. * Block used to get the view direction
  63519. */
  63520. export class ViewDirectionBlock extends NodeMaterialBlock {
  63521. /**
  63522. * Creates a new ViewDirectionBlock
  63523. * @param name defines the block name
  63524. */
  63525. constructor(name: string);
  63526. /**
  63527. * Gets the current class name
  63528. * @returns the class name
  63529. */
  63530. getClassName(): string;
  63531. /**
  63532. * Gets the world position component
  63533. */
  63534. get worldPosition(): NodeMaterialConnectionPoint;
  63535. /**
  63536. * Gets the camera position component
  63537. */
  63538. get cameraPosition(): NodeMaterialConnectionPoint;
  63539. /**
  63540. * Gets the output component
  63541. */
  63542. get output(): NodeMaterialConnectionPoint;
  63543. autoConfigure(material: NodeMaterial): void;
  63544. protected _buildBlock(state: NodeMaterialBuildState): this;
  63545. }
  63546. }
  63547. declare module BABYLON {
  63548. /**
  63549. * Block used to compute fresnel value
  63550. */
  63551. export class FresnelBlock extends NodeMaterialBlock {
  63552. /**
  63553. * Create a new FresnelBlock
  63554. * @param name defines the block name
  63555. */
  63556. constructor(name: string);
  63557. /**
  63558. * Gets the current class name
  63559. * @returns the class name
  63560. */
  63561. getClassName(): string;
  63562. /**
  63563. * Gets the world normal input component
  63564. */
  63565. get worldNormal(): NodeMaterialConnectionPoint;
  63566. /**
  63567. * Gets the view direction input component
  63568. */
  63569. get viewDirection(): NodeMaterialConnectionPoint;
  63570. /**
  63571. * Gets the bias input component
  63572. */
  63573. get bias(): NodeMaterialConnectionPoint;
  63574. /**
  63575. * Gets the camera (or eye) position component
  63576. */
  63577. get power(): NodeMaterialConnectionPoint;
  63578. /**
  63579. * Gets the fresnel output component
  63580. */
  63581. get fresnel(): NodeMaterialConnectionPoint;
  63582. autoConfigure(material: NodeMaterial): void;
  63583. protected _buildBlock(state: NodeMaterialBuildState): this;
  63584. }
  63585. }
  63586. declare module BABYLON {
  63587. /**
  63588. * Block used to get the max of 2 values
  63589. */
  63590. export class MaxBlock extends NodeMaterialBlock {
  63591. /**
  63592. * Creates a new MaxBlock
  63593. * @param name defines the block name
  63594. */
  63595. constructor(name: string);
  63596. /**
  63597. * Gets the current class name
  63598. * @returns the class name
  63599. */
  63600. getClassName(): string;
  63601. /**
  63602. * Gets the left operand input component
  63603. */
  63604. get left(): NodeMaterialConnectionPoint;
  63605. /**
  63606. * Gets the right operand input component
  63607. */
  63608. get right(): NodeMaterialConnectionPoint;
  63609. /**
  63610. * Gets the output component
  63611. */
  63612. get output(): NodeMaterialConnectionPoint;
  63613. protected _buildBlock(state: NodeMaterialBuildState): this;
  63614. }
  63615. }
  63616. declare module BABYLON {
  63617. /**
  63618. * Block used to get the min of 2 values
  63619. */
  63620. export class MinBlock extends NodeMaterialBlock {
  63621. /**
  63622. * Creates a new MinBlock
  63623. * @param name defines the block name
  63624. */
  63625. constructor(name: string);
  63626. /**
  63627. * Gets the current class name
  63628. * @returns the class name
  63629. */
  63630. getClassName(): string;
  63631. /**
  63632. * Gets the left operand input component
  63633. */
  63634. get left(): NodeMaterialConnectionPoint;
  63635. /**
  63636. * Gets the right operand input component
  63637. */
  63638. get right(): NodeMaterialConnectionPoint;
  63639. /**
  63640. * Gets the output component
  63641. */
  63642. get output(): NodeMaterialConnectionPoint;
  63643. protected _buildBlock(state: NodeMaterialBuildState): this;
  63644. }
  63645. }
  63646. declare module BABYLON {
  63647. /**
  63648. * Block used to get the distance between 2 values
  63649. */
  63650. export class DistanceBlock extends NodeMaterialBlock {
  63651. /**
  63652. * Creates a new DistanceBlock
  63653. * @param name defines the block name
  63654. */
  63655. constructor(name: string);
  63656. /**
  63657. * Gets the current class name
  63658. * @returns the class name
  63659. */
  63660. getClassName(): string;
  63661. /**
  63662. * Gets the left operand input component
  63663. */
  63664. get left(): NodeMaterialConnectionPoint;
  63665. /**
  63666. * Gets the right operand input component
  63667. */
  63668. get right(): NodeMaterialConnectionPoint;
  63669. /**
  63670. * Gets the output component
  63671. */
  63672. get output(): NodeMaterialConnectionPoint;
  63673. protected _buildBlock(state: NodeMaterialBuildState): this;
  63674. }
  63675. }
  63676. declare module BABYLON {
  63677. /**
  63678. * Block used to get the length of a vector
  63679. */
  63680. export class LengthBlock extends NodeMaterialBlock {
  63681. /**
  63682. * Creates a new LengthBlock
  63683. * @param name defines the block name
  63684. */
  63685. constructor(name: string);
  63686. /**
  63687. * Gets the current class name
  63688. * @returns the class name
  63689. */
  63690. getClassName(): string;
  63691. /**
  63692. * Gets the value input component
  63693. */
  63694. get value(): NodeMaterialConnectionPoint;
  63695. /**
  63696. * Gets the output component
  63697. */
  63698. get output(): NodeMaterialConnectionPoint;
  63699. protected _buildBlock(state: NodeMaterialBuildState): this;
  63700. }
  63701. }
  63702. declare module BABYLON {
  63703. /**
  63704. * Block used to get negative version of a value (i.e. x * -1)
  63705. */
  63706. export class NegateBlock extends NodeMaterialBlock {
  63707. /**
  63708. * Creates a new NegateBlock
  63709. * @param name defines the block name
  63710. */
  63711. constructor(name: string);
  63712. /**
  63713. * Gets the current class name
  63714. * @returns the class name
  63715. */
  63716. getClassName(): string;
  63717. /**
  63718. * Gets the value input component
  63719. */
  63720. get value(): NodeMaterialConnectionPoint;
  63721. /**
  63722. * Gets the output component
  63723. */
  63724. get output(): NodeMaterialConnectionPoint;
  63725. protected _buildBlock(state: NodeMaterialBuildState): this;
  63726. }
  63727. }
  63728. declare module BABYLON {
  63729. /**
  63730. * Block used to get the value of the first parameter raised to the power of the second
  63731. */
  63732. export class PowBlock extends NodeMaterialBlock {
  63733. /**
  63734. * Creates a new PowBlock
  63735. * @param name defines the block name
  63736. */
  63737. constructor(name: string);
  63738. /**
  63739. * Gets the current class name
  63740. * @returns the class name
  63741. */
  63742. getClassName(): string;
  63743. /**
  63744. * Gets the value operand input component
  63745. */
  63746. get value(): NodeMaterialConnectionPoint;
  63747. /**
  63748. * Gets the power operand input component
  63749. */
  63750. get power(): NodeMaterialConnectionPoint;
  63751. /**
  63752. * Gets the output component
  63753. */
  63754. get output(): NodeMaterialConnectionPoint;
  63755. protected _buildBlock(state: NodeMaterialBuildState): this;
  63756. }
  63757. }
  63758. declare module BABYLON {
  63759. /**
  63760. * Block used to get a random number
  63761. */
  63762. export class RandomNumberBlock extends NodeMaterialBlock {
  63763. /**
  63764. * Creates a new RandomNumberBlock
  63765. * @param name defines the block name
  63766. */
  63767. constructor(name: string);
  63768. /**
  63769. * Gets the current class name
  63770. * @returns the class name
  63771. */
  63772. getClassName(): string;
  63773. /**
  63774. * Gets the seed input component
  63775. */
  63776. get seed(): NodeMaterialConnectionPoint;
  63777. /**
  63778. * Gets the output component
  63779. */
  63780. get output(): NodeMaterialConnectionPoint;
  63781. protected _buildBlock(state: NodeMaterialBuildState): this;
  63782. }
  63783. }
  63784. declare module BABYLON {
  63785. /**
  63786. * Block used to compute arc tangent of 2 values
  63787. */
  63788. export class ArcTan2Block extends NodeMaterialBlock {
  63789. /**
  63790. * Creates a new ArcTan2Block
  63791. * @param name defines the block name
  63792. */
  63793. constructor(name: string);
  63794. /**
  63795. * Gets the current class name
  63796. * @returns the class name
  63797. */
  63798. getClassName(): string;
  63799. /**
  63800. * Gets the x operand input component
  63801. */
  63802. get x(): NodeMaterialConnectionPoint;
  63803. /**
  63804. * Gets the y operand input component
  63805. */
  63806. get y(): NodeMaterialConnectionPoint;
  63807. /**
  63808. * Gets the output component
  63809. */
  63810. get output(): NodeMaterialConnectionPoint;
  63811. protected _buildBlock(state: NodeMaterialBuildState): this;
  63812. }
  63813. }
  63814. declare module BABYLON {
  63815. /**
  63816. * Block used to smooth step a value
  63817. */
  63818. export class SmoothStepBlock extends NodeMaterialBlock {
  63819. /**
  63820. * Creates a new SmoothStepBlock
  63821. * @param name defines the block name
  63822. */
  63823. constructor(name: string);
  63824. /**
  63825. * Gets the current class name
  63826. * @returns the class name
  63827. */
  63828. getClassName(): string;
  63829. /**
  63830. * Gets the value operand input component
  63831. */
  63832. get value(): NodeMaterialConnectionPoint;
  63833. /**
  63834. * Gets the first edge operand input component
  63835. */
  63836. get edge0(): NodeMaterialConnectionPoint;
  63837. /**
  63838. * Gets the second edge operand input component
  63839. */
  63840. get edge1(): NodeMaterialConnectionPoint;
  63841. /**
  63842. * Gets the output component
  63843. */
  63844. get output(): NodeMaterialConnectionPoint;
  63845. protected _buildBlock(state: NodeMaterialBuildState): this;
  63846. }
  63847. }
  63848. declare module BABYLON {
  63849. /**
  63850. * Block used to get the reciprocal (1 / x) of a value
  63851. */
  63852. export class ReciprocalBlock extends NodeMaterialBlock {
  63853. /**
  63854. * Creates a new ReciprocalBlock
  63855. * @param name defines the block name
  63856. */
  63857. constructor(name: string);
  63858. /**
  63859. * Gets the current class name
  63860. * @returns the class name
  63861. */
  63862. getClassName(): string;
  63863. /**
  63864. * Gets the input component
  63865. */
  63866. get input(): NodeMaterialConnectionPoint;
  63867. /**
  63868. * Gets the output component
  63869. */
  63870. get output(): NodeMaterialConnectionPoint;
  63871. protected _buildBlock(state: NodeMaterialBuildState): this;
  63872. }
  63873. }
  63874. declare module BABYLON {
  63875. /**
  63876. * Block used to replace a color by another one
  63877. */
  63878. export class ReplaceColorBlock extends NodeMaterialBlock {
  63879. /**
  63880. * Creates a new ReplaceColorBlock
  63881. * @param name defines the block name
  63882. */
  63883. constructor(name: string);
  63884. /**
  63885. * Gets the current class name
  63886. * @returns the class name
  63887. */
  63888. getClassName(): string;
  63889. /**
  63890. * Gets the value input component
  63891. */
  63892. get value(): NodeMaterialConnectionPoint;
  63893. /**
  63894. * Gets the reference input component
  63895. */
  63896. get reference(): NodeMaterialConnectionPoint;
  63897. /**
  63898. * Gets the distance input component
  63899. */
  63900. get distance(): NodeMaterialConnectionPoint;
  63901. /**
  63902. * Gets the replacement input component
  63903. */
  63904. get replacement(): NodeMaterialConnectionPoint;
  63905. /**
  63906. * Gets the output component
  63907. */
  63908. get output(): NodeMaterialConnectionPoint;
  63909. protected _buildBlock(state: NodeMaterialBuildState): this;
  63910. }
  63911. }
  63912. declare module BABYLON {
  63913. /**
  63914. * Block used to posterize a value
  63915. * @see https://en.wikipedia.org/wiki/Posterization
  63916. */
  63917. export class PosterizeBlock extends NodeMaterialBlock {
  63918. /**
  63919. * Creates a new PosterizeBlock
  63920. * @param name defines the block name
  63921. */
  63922. constructor(name: string);
  63923. /**
  63924. * Gets the current class name
  63925. * @returns the class name
  63926. */
  63927. getClassName(): string;
  63928. /**
  63929. * Gets the value input component
  63930. */
  63931. get value(): NodeMaterialConnectionPoint;
  63932. /**
  63933. * Gets the steps input component
  63934. */
  63935. get steps(): NodeMaterialConnectionPoint;
  63936. /**
  63937. * Gets the output component
  63938. */
  63939. get output(): NodeMaterialConnectionPoint;
  63940. protected _buildBlock(state: NodeMaterialBuildState): this;
  63941. }
  63942. }
  63943. declare module BABYLON {
  63944. /**
  63945. * Operations supported by the Wave block
  63946. */
  63947. export enum WaveBlockKind {
  63948. /** SawTooth */
  63949. SawTooth = 0,
  63950. /** Square */
  63951. Square = 1,
  63952. /** Triangle */
  63953. Triangle = 2
  63954. }
  63955. /**
  63956. * Block used to apply wave operation to floats
  63957. */
  63958. export class WaveBlock extends NodeMaterialBlock {
  63959. /**
  63960. * Gets or sets the kibnd of wave to be applied by the block
  63961. */
  63962. kind: WaveBlockKind;
  63963. /**
  63964. * Creates a new WaveBlock
  63965. * @param name defines the block name
  63966. */
  63967. constructor(name: string);
  63968. /**
  63969. * Gets the current class name
  63970. * @returns the class name
  63971. */
  63972. getClassName(): string;
  63973. /**
  63974. * Gets the input component
  63975. */
  63976. get input(): NodeMaterialConnectionPoint;
  63977. /**
  63978. * Gets the output component
  63979. */
  63980. get output(): NodeMaterialConnectionPoint;
  63981. protected _buildBlock(state: NodeMaterialBuildState): this;
  63982. serialize(): any;
  63983. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63984. }
  63985. }
  63986. declare module BABYLON {
  63987. /**
  63988. * Class used to store a color step for the GradientBlock
  63989. */
  63990. export class GradientBlockColorStep {
  63991. private _step;
  63992. /**
  63993. * Gets value indicating which step this color is associated with (between 0 and 1)
  63994. */
  63995. get step(): number;
  63996. /**
  63997. * Sets a value indicating which step this color is associated with (between 0 and 1)
  63998. */
  63999. set step(val: number);
  64000. private _color;
  64001. /**
  64002. * Gets the color associated with this step
  64003. */
  64004. get color(): Color3;
  64005. /**
  64006. * Sets the color associated with this step
  64007. */
  64008. set color(val: Color3);
  64009. /**
  64010. * Creates a new GradientBlockColorStep
  64011. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64012. * @param color defines the color associated with this step
  64013. */
  64014. constructor(step: number, color: Color3);
  64015. }
  64016. /**
  64017. * Block used to return a color from a gradient based on an input value between 0 and 1
  64018. */
  64019. export class GradientBlock extends NodeMaterialBlock {
  64020. /**
  64021. * Gets or sets the list of color steps
  64022. */
  64023. colorSteps: GradientBlockColorStep[];
  64024. /** Gets an observable raised when the value is changed */
  64025. onValueChangedObservable: Observable<GradientBlock>;
  64026. /** calls observable when the value is changed*/
  64027. colorStepsUpdated(): void;
  64028. /**
  64029. * Creates a new GradientBlock
  64030. * @param name defines the block name
  64031. */
  64032. constructor(name: string);
  64033. /**
  64034. * Gets the current class name
  64035. * @returns the class name
  64036. */
  64037. getClassName(): string;
  64038. /**
  64039. * Gets the gradient input component
  64040. */
  64041. get gradient(): NodeMaterialConnectionPoint;
  64042. /**
  64043. * Gets the output component
  64044. */
  64045. get output(): NodeMaterialConnectionPoint;
  64046. private _writeColorConstant;
  64047. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64048. serialize(): any;
  64049. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64050. protected _dumpPropertiesCode(): string;
  64051. }
  64052. }
  64053. declare module BABYLON {
  64054. /**
  64055. * Block used to normalize lerp between 2 values
  64056. */
  64057. export class NLerpBlock extends NodeMaterialBlock {
  64058. /**
  64059. * Creates a new NLerpBlock
  64060. * @param name defines the block name
  64061. */
  64062. constructor(name: string);
  64063. /**
  64064. * Gets the current class name
  64065. * @returns the class name
  64066. */
  64067. getClassName(): string;
  64068. /**
  64069. * Gets the left operand input component
  64070. */
  64071. get left(): NodeMaterialConnectionPoint;
  64072. /**
  64073. * Gets the right operand input component
  64074. */
  64075. get right(): NodeMaterialConnectionPoint;
  64076. /**
  64077. * Gets the gradient operand input component
  64078. */
  64079. get gradient(): NodeMaterialConnectionPoint;
  64080. /**
  64081. * Gets the output component
  64082. */
  64083. get output(): NodeMaterialConnectionPoint;
  64084. protected _buildBlock(state: NodeMaterialBuildState): this;
  64085. }
  64086. }
  64087. declare module BABYLON {
  64088. /**
  64089. * block used to Generate a Worley Noise 3D Noise Pattern
  64090. */
  64091. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64092. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64093. manhattanDistance: boolean;
  64094. /**
  64095. * Creates a new WorleyNoise3DBlock
  64096. * @param name defines the block name
  64097. */
  64098. constructor(name: string);
  64099. /**
  64100. * Gets the current class name
  64101. * @returns the class name
  64102. */
  64103. getClassName(): string;
  64104. /**
  64105. * Gets the seed input component
  64106. */
  64107. get seed(): NodeMaterialConnectionPoint;
  64108. /**
  64109. * Gets the jitter input component
  64110. */
  64111. get jitter(): NodeMaterialConnectionPoint;
  64112. /**
  64113. * Gets the output component
  64114. */
  64115. get output(): NodeMaterialConnectionPoint;
  64116. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64117. /**
  64118. * Exposes the properties to the UI?
  64119. */
  64120. protected _dumpPropertiesCode(): string;
  64121. /**
  64122. * Exposes the properties to the Seralize?
  64123. */
  64124. serialize(): any;
  64125. /**
  64126. * Exposes the properties to the deseralize?
  64127. */
  64128. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64129. }
  64130. }
  64131. declare module BABYLON {
  64132. /**
  64133. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64134. */
  64135. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64136. /**
  64137. * Creates a new SimplexPerlin3DBlock
  64138. * @param name defines the block name
  64139. */
  64140. constructor(name: string);
  64141. /**
  64142. * Gets the current class name
  64143. * @returns the class name
  64144. */
  64145. getClassName(): string;
  64146. /**
  64147. * Gets the seed operand input component
  64148. */
  64149. get seed(): NodeMaterialConnectionPoint;
  64150. /**
  64151. * Gets the output component
  64152. */
  64153. get output(): NodeMaterialConnectionPoint;
  64154. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64155. }
  64156. }
  64157. declare module BABYLON {
  64158. /**
  64159. * Block used to blend normals
  64160. */
  64161. export class NormalBlendBlock extends NodeMaterialBlock {
  64162. /**
  64163. * Creates a new NormalBlendBlock
  64164. * @param name defines the block name
  64165. */
  64166. constructor(name: string);
  64167. /**
  64168. * Gets the current class name
  64169. * @returns the class name
  64170. */
  64171. getClassName(): string;
  64172. /**
  64173. * Gets the first input component
  64174. */
  64175. get normalMap0(): NodeMaterialConnectionPoint;
  64176. /**
  64177. * Gets the second input component
  64178. */
  64179. get normalMap1(): NodeMaterialConnectionPoint;
  64180. /**
  64181. * Gets the output component
  64182. */
  64183. get output(): NodeMaterialConnectionPoint;
  64184. protected _buildBlock(state: NodeMaterialBuildState): this;
  64185. }
  64186. }
  64187. declare module BABYLON {
  64188. /**
  64189. * Block used to rotate a 2d vector by a given angle
  64190. */
  64191. export class Rotate2dBlock extends NodeMaterialBlock {
  64192. /**
  64193. * Creates a new Rotate2dBlock
  64194. * @param name defines the block name
  64195. */
  64196. constructor(name: string);
  64197. /**
  64198. * Gets the current class name
  64199. * @returns the class name
  64200. */
  64201. getClassName(): string;
  64202. /**
  64203. * Gets the input vector
  64204. */
  64205. get input(): NodeMaterialConnectionPoint;
  64206. /**
  64207. * Gets the input angle
  64208. */
  64209. get angle(): NodeMaterialConnectionPoint;
  64210. /**
  64211. * Gets the output component
  64212. */
  64213. get output(): NodeMaterialConnectionPoint;
  64214. autoConfigure(material: NodeMaterial): void;
  64215. protected _buildBlock(state: NodeMaterialBuildState): this;
  64216. }
  64217. }
  64218. declare module BABYLON {
  64219. /**
  64220. * Block used to get the reflected vector from a direction and a normal
  64221. */
  64222. export class ReflectBlock extends NodeMaterialBlock {
  64223. /**
  64224. * Creates a new ReflectBlock
  64225. * @param name defines the block name
  64226. */
  64227. constructor(name: string);
  64228. /**
  64229. * Gets the current class name
  64230. * @returns the class name
  64231. */
  64232. getClassName(): string;
  64233. /**
  64234. * Gets the incident component
  64235. */
  64236. get incident(): NodeMaterialConnectionPoint;
  64237. /**
  64238. * Gets the normal component
  64239. */
  64240. get normal(): NodeMaterialConnectionPoint;
  64241. /**
  64242. * Gets the output component
  64243. */
  64244. get output(): NodeMaterialConnectionPoint;
  64245. protected _buildBlock(state: NodeMaterialBuildState): this;
  64246. }
  64247. }
  64248. declare module BABYLON {
  64249. /**
  64250. * Block used to get the refracted vector from a direction and a normal
  64251. */
  64252. export class RefractBlock extends NodeMaterialBlock {
  64253. /**
  64254. * Creates a new RefractBlock
  64255. * @param name defines the block name
  64256. */
  64257. constructor(name: string);
  64258. /**
  64259. * Gets the current class name
  64260. * @returns the class name
  64261. */
  64262. getClassName(): string;
  64263. /**
  64264. * Gets the incident component
  64265. */
  64266. get incident(): NodeMaterialConnectionPoint;
  64267. /**
  64268. * Gets the normal component
  64269. */
  64270. get normal(): NodeMaterialConnectionPoint;
  64271. /**
  64272. * Gets the index of refraction component
  64273. */
  64274. get ior(): NodeMaterialConnectionPoint;
  64275. /**
  64276. * Gets the output component
  64277. */
  64278. get output(): NodeMaterialConnectionPoint;
  64279. protected _buildBlock(state: NodeMaterialBuildState): this;
  64280. }
  64281. }
  64282. declare module BABYLON {
  64283. /**
  64284. * Block used to desaturate a color
  64285. */
  64286. export class DesaturateBlock extends NodeMaterialBlock {
  64287. /**
  64288. * Creates a new DesaturateBlock
  64289. * @param name defines the block name
  64290. */
  64291. constructor(name: string);
  64292. /**
  64293. * Gets the current class name
  64294. * @returns the class name
  64295. */
  64296. getClassName(): string;
  64297. /**
  64298. * Gets the color operand input component
  64299. */
  64300. get color(): NodeMaterialConnectionPoint;
  64301. /**
  64302. * Gets the level operand input component
  64303. */
  64304. get level(): NodeMaterialConnectionPoint;
  64305. /**
  64306. * Gets the output component
  64307. */
  64308. get output(): NodeMaterialConnectionPoint;
  64309. protected _buildBlock(state: NodeMaterialBuildState): this;
  64310. }
  64311. }
  64312. declare module BABYLON {
  64313. /**
  64314. * Block used to implement the ambient occlusion module of the PBR material
  64315. */
  64316. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64317. /**
  64318. * Create a new AmbientOcclusionBlock
  64319. * @param name defines the block name
  64320. */
  64321. constructor(name: string);
  64322. /**
  64323. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64324. */
  64325. useAmbientInGrayScale: boolean;
  64326. /**
  64327. * Initialize the block and prepare the context for build
  64328. * @param state defines the state that will be used for the build
  64329. */
  64330. initialize(state: NodeMaterialBuildState): void;
  64331. /**
  64332. * Gets the current class name
  64333. * @returns the class name
  64334. */
  64335. getClassName(): string;
  64336. /**
  64337. * Gets the texture input component
  64338. */
  64339. get texture(): NodeMaterialConnectionPoint;
  64340. /**
  64341. * Gets the texture intensity component
  64342. */
  64343. get intensity(): NodeMaterialConnectionPoint;
  64344. /**
  64345. * Gets the direct light intensity input component
  64346. */
  64347. get directLightIntensity(): NodeMaterialConnectionPoint;
  64348. /**
  64349. * Gets the ambient occlusion object output component
  64350. */
  64351. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64352. /**
  64353. * Gets the main code of the block (fragment side)
  64354. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64355. * @returns the shader code
  64356. */
  64357. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64358. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64359. protected _buildBlock(state: NodeMaterialBuildState): this;
  64360. protected _dumpPropertiesCode(): string;
  64361. serialize(): any;
  64362. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64363. }
  64364. }
  64365. declare module BABYLON {
  64366. /**
  64367. * Block used to implement the reflection module of the PBR material
  64368. */
  64369. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64370. /** @hidden */
  64371. _defineLODReflectionAlpha: string;
  64372. /** @hidden */
  64373. _defineLinearSpecularReflection: string;
  64374. private _vEnvironmentIrradianceName;
  64375. /** @hidden */
  64376. _vReflectionMicrosurfaceInfosName: string;
  64377. /** @hidden */
  64378. _vReflectionInfosName: string;
  64379. /** @hidden */
  64380. _vReflectionFilteringInfoName: string;
  64381. private _scene;
  64382. /**
  64383. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64384. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64385. * It's less burden on the user side in the editor part.
  64386. */
  64387. /** @hidden */
  64388. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64389. /** @hidden */
  64390. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64391. /** @hidden */
  64392. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64393. /**
  64394. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64395. * diffuse part of the IBL.
  64396. */
  64397. useSphericalHarmonics: boolean;
  64398. /**
  64399. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64400. */
  64401. forceIrradianceInFragment: boolean;
  64402. /**
  64403. * Create a new ReflectionBlock
  64404. * @param name defines the block name
  64405. */
  64406. constructor(name: string);
  64407. /**
  64408. * Gets the current class name
  64409. * @returns the class name
  64410. */
  64411. getClassName(): string;
  64412. /**
  64413. * Gets the position input component
  64414. */
  64415. get position(): NodeMaterialConnectionPoint;
  64416. /**
  64417. * Gets the world position input component
  64418. */
  64419. get worldPosition(): NodeMaterialConnectionPoint;
  64420. /**
  64421. * Gets the world normal input component
  64422. */
  64423. get worldNormal(): NodeMaterialConnectionPoint;
  64424. /**
  64425. * Gets the world input component
  64426. */
  64427. get world(): NodeMaterialConnectionPoint;
  64428. /**
  64429. * Gets the camera (or eye) position component
  64430. */
  64431. get cameraPosition(): NodeMaterialConnectionPoint;
  64432. /**
  64433. * Gets the view input component
  64434. */
  64435. get view(): NodeMaterialConnectionPoint;
  64436. /**
  64437. * Gets the color input component
  64438. */
  64439. get color(): NodeMaterialConnectionPoint;
  64440. /**
  64441. * Gets the reflection object output component
  64442. */
  64443. get reflection(): NodeMaterialConnectionPoint;
  64444. /**
  64445. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64446. */
  64447. get hasTexture(): boolean;
  64448. /**
  64449. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64450. */
  64451. get reflectionColor(): string;
  64452. protected _getTexture(): Nullable<BaseTexture>;
  64453. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64454. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64455. /**
  64456. * Gets the code to inject in the vertex shader
  64457. * @param state current state of the node material building
  64458. * @returns the shader code
  64459. */
  64460. handleVertexSide(state: NodeMaterialBuildState): string;
  64461. /**
  64462. * Gets the main code of the block (fragment side)
  64463. * @param state current state of the node material building
  64464. * @param normalVarName name of the existing variable corresponding to the normal
  64465. * @returns the shader code
  64466. */
  64467. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64468. protected _buildBlock(state: NodeMaterialBuildState): this;
  64469. protected _dumpPropertiesCode(): string;
  64470. serialize(): any;
  64471. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64472. }
  64473. }
  64474. declare module BABYLON {
  64475. /**
  64476. * Block used to implement the sheen module of the PBR material
  64477. */
  64478. export class SheenBlock extends NodeMaterialBlock {
  64479. /**
  64480. * Create a new SheenBlock
  64481. * @param name defines the block name
  64482. */
  64483. constructor(name: string);
  64484. /**
  64485. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64486. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64487. * making it easier to setup and tweak the effect
  64488. */
  64489. albedoScaling: boolean;
  64490. /**
  64491. * Defines if the sheen is linked to the sheen color.
  64492. */
  64493. linkSheenWithAlbedo: boolean;
  64494. /**
  64495. * Initialize the block and prepare the context for build
  64496. * @param state defines the state that will be used for the build
  64497. */
  64498. initialize(state: NodeMaterialBuildState): void;
  64499. /**
  64500. * Gets the current class name
  64501. * @returns the class name
  64502. */
  64503. getClassName(): string;
  64504. /**
  64505. * Gets the intensity input component
  64506. */
  64507. get intensity(): NodeMaterialConnectionPoint;
  64508. /**
  64509. * Gets the color input component
  64510. */
  64511. get color(): NodeMaterialConnectionPoint;
  64512. /**
  64513. * Gets the roughness input component
  64514. */
  64515. get roughness(): NodeMaterialConnectionPoint;
  64516. /**
  64517. * Gets the sheen object output component
  64518. */
  64519. get sheen(): NodeMaterialConnectionPoint;
  64520. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64521. /**
  64522. * Gets the main code of the block (fragment side)
  64523. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64524. * @returns the shader code
  64525. */
  64526. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64527. protected _buildBlock(state: NodeMaterialBuildState): this;
  64528. protected _dumpPropertiesCode(): string;
  64529. serialize(): any;
  64530. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64531. }
  64532. }
  64533. declare module BABYLON {
  64534. /**
  64535. * Block used to implement the reflectivity module of the PBR material
  64536. */
  64537. export class ReflectivityBlock extends NodeMaterialBlock {
  64538. private _metallicReflectanceColor;
  64539. private _metallicF0Factor;
  64540. /** @hidden */
  64541. _vMetallicReflectanceFactorsName: string;
  64542. /**
  64543. * The property below is set by the main PBR block prior to calling methods of this class.
  64544. */
  64545. /** @hidden */
  64546. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64547. /**
  64548. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64549. */
  64550. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64551. /**
  64552. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64553. */
  64554. useMetallnessFromMetallicTextureBlue: boolean;
  64555. /**
  64556. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64557. */
  64558. useRoughnessFromMetallicTextureAlpha: boolean;
  64559. /**
  64560. * Specifies if the metallic texture contains the roughness information in its green channel.
  64561. */
  64562. useRoughnessFromMetallicTextureGreen: boolean;
  64563. /**
  64564. * Create a new ReflectivityBlock
  64565. * @param name defines the block name
  64566. */
  64567. constructor(name: string);
  64568. /**
  64569. * Initialize the block and prepare the context for build
  64570. * @param state defines the state that will be used for the build
  64571. */
  64572. initialize(state: NodeMaterialBuildState): void;
  64573. /**
  64574. * Gets the current class name
  64575. * @returns the class name
  64576. */
  64577. getClassName(): string;
  64578. /**
  64579. * Gets the metallic input component
  64580. */
  64581. get metallic(): NodeMaterialConnectionPoint;
  64582. /**
  64583. * Gets the roughness input component
  64584. */
  64585. get roughness(): NodeMaterialConnectionPoint;
  64586. /**
  64587. * Gets the texture input component
  64588. */
  64589. get texture(): NodeMaterialConnectionPoint;
  64590. /**
  64591. * Gets the reflectivity object output component
  64592. */
  64593. get reflectivity(): NodeMaterialConnectionPoint;
  64594. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64595. /**
  64596. * Gets the main code of the block (fragment side)
  64597. * @param state current state of the node material building
  64598. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64599. * @returns the shader code
  64600. */
  64601. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64602. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64603. protected _buildBlock(state: NodeMaterialBuildState): this;
  64604. protected _dumpPropertiesCode(): string;
  64605. serialize(): any;
  64606. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64607. }
  64608. }
  64609. declare module BABYLON {
  64610. /**
  64611. * Block used to implement the anisotropy module of the PBR material
  64612. */
  64613. export class AnisotropyBlock extends NodeMaterialBlock {
  64614. /**
  64615. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64616. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64617. * It's less burden on the user side in the editor part.
  64618. */
  64619. /** @hidden */
  64620. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64621. /** @hidden */
  64622. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64623. /**
  64624. * Create a new AnisotropyBlock
  64625. * @param name defines the block name
  64626. */
  64627. constructor(name: string);
  64628. /**
  64629. * Initialize the block and prepare the context for build
  64630. * @param state defines the state that will be used for the build
  64631. */
  64632. initialize(state: NodeMaterialBuildState): void;
  64633. /**
  64634. * Gets the current class name
  64635. * @returns the class name
  64636. */
  64637. getClassName(): string;
  64638. /**
  64639. * Gets the intensity input component
  64640. */
  64641. get intensity(): NodeMaterialConnectionPoint;
  64642. /**
  64643. * Gets the direction input component
  64644. */
  64645. get direction(): NodeMaterialConnectionPoint;
  64646. /**
  64647. * Gets the texture input component
  64648. */
  64649. get texture(): NodeMaterialConnectionPoint;
  64650. /**
  64651. * Gets the uv input component
  64652. */
  64653. get uv(): NodeMaterialConnectionPoint;
  64654. /**
  64655. * Gets the worldTangent input component
  64656. */
  64657. get worldTangent(): NodeMaterialConnectionPoint;
  64658. /**
  64659. * Gets the anisotropy object output component
  64660. */
  64661. get anisotropy(): NodeMaterialConnectionPoint;
  64662. private _generateTBNSpace;
  64663. /**
  64664. * Gets the main code of the block (fragment side)
  64665. * @param state current state of the node material building
  64666. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64667. * @returns the shader code
  64668. */
  64669. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64670. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64671. protected _buildBlock(state: NodeMaterialBuildState): this;
  64672. }
  64673. }
  64674. declare module BABYLON {
  64675. /**
  64676. * Block used to implement the clear coat module of the PBR material
  64677. */
  64678. export class ClearCoatBlock extends NodeMaterialBlock {
  64679. private _scene;
  64680. /**
  64681. * Create a new ClearCoatBlock
  64682. * @param name defines the block name
  64683. */
  64684. constructor(name: string);
  64685. /**
  64686. * Initialize the block and prepare the context for build
  64687. * @param state defines the state that will be used for the build
  64688. */
  64689. initialize(state: NodeMaterialBuildState): void;
  64690. /**
  64691. * Gets the current class name
  64692. * @returns the class name
  64693. */
  64694. getClassName(): string;
  64695. /**
  64696. * Gets the intensity input component
  64697. */
  64698. get intensity(): NodeMaterialConnectionPoint;
  64699. /**
  64700. * Gets the roughness input component
  64701. */
  64702. get roughness(): NodeMaterialConnectionPoint;
  64703. /**
  64704. * Gets the ior input component
  64705. */
  64706. get ior(): NodeMaterialConnectionPoint;
  64707. /**
  64708. * Gets the texture input component
  64709. */
  64710. get texture(): NodeMaterialConnectionPoint;
  64711. /**
  64712. * Gets the bump texture input component
  64713. */
  64714. get bumpTexture(): NodeMaterialConnectionPoint;
  64715. /**
  64716. * Gets the uv input component
  64717. */
  64718. get uv(): NodeMaterialConnectionPoint;
  64719. /**
  64720. * Gets the tint color input component
  64721. */
  64722. get tintColor(): NodeMaterialConnectionPoint;
  64723. /**
  64724. * Gets the tint "at distance" input component
  64725. */
  64726. get tintAtDistance(): NodeMaterialConnectionPoint;
  64727. /**
  64728. * Gets the tint thickness input component
  64729. */
  64730. get tintThickness(): NodeMaterialConnectionPoint;
  64731. /**
  64732. * Gets the world tangent input component
  64733. */
  64734. get worldTangent(): NodeMaterialConnectionPoint;
  64735. /**
  64736. * Gets the clear coat object output component
  64737. */
  64738. get clearcoat(): NodeMaterialConnectionPoint;
  64739. autoConfigure(material: NodeMaterial): void;
  64740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64741. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64742. private _generateTBNSpace;
  64743. /**
  64744. * Gets the main code of the block (fragment side)
  64745. * @param state current state of the node material building
  64746. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64747. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64748. * @param worldPosVarName name of the variable holding the world position
  64749. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64750. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64751. * @param worldNormalVarName name of the variable holding the world normal
  64752. * @returns the shader code
  64753. */
  64754. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64755. protected _buildBlock(state: NodeMaterialBuildState): this;
  64756. }
  64757. }
  64758. declare module BABYLON {
  64759. /**
  64760. * Block used to implement the sub surface module of the PBR material
  64761. */
  64762. export class SubSurfaceBlock extends NodeMaterialBlock {
  64763. /**
  64764. * Create a new SubSurfaceBlock
  64765. * @param name defines the block name
  64766. */
  64767. constructor(name: string);
  64768. /**
  64769. * Stores the intensity of the different subsurface effects in the thickness texture.
  64770. * * the green channel is the translucency intensity.
  64771. * * the blue channel is the scattering intensity.
  64772. * * the alpha channel is the refraction intensity.
  64773. */
  64774. useMaskFromThicknessTexture: boolean;
  64775. /**
  64776. * Initialize the block and prepare the context for build
  64777. * @param state defines the state that will be used for the build
  64778. */
  64779. initialize(state: NodeMaterialBuildState): void;
  64780. /**
  64781. * Gets the current class name
  64782. * @returns the class name
  64783. */
  64784. getClassName(): string;
  64785. /**
  64786. * Gets the min thickness input component
  64787. */
  64788. get minThickness(): NodeMaterialConnectionPoint;
  64789. /**
  64790. * Gets the max thickness input component
  64791. */
  64792. get maxThickness(): NodeMaterialConnectionPoint;
  64793. /**
  64794. * Gets the thickness texture component
  64795. */
  64796. get thicknessTexture(): NodeMaterialConnectionPoint;
  64797. /**
  64798. * Gets the tint color input component
  64799. */
  64800. get tintColor(): NodeMaterialConnectionPoint;
  64801. /**
  64802. * Gets the translucency intensity input component
  64803. */
  64804. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64805. /**
  64806. * Gets the translucency diffusion distance input component
  64807. */
  64808. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64809. /**
  64810. * Gets the refraction object parameters
  64811. */
  64812. get refraction(): NodeMaterialConnectionPoint;
  64813. /**
  64814. * Gets the sub surface object output component
  64815. */
  64816. get subsurface(): NodeMaterialConnectionPoint;
  64817. autoConfigure(material: NodeMaterial): void;
  64818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64819. /**
  64820. * Gets the main code of the block (fragment side)
  64821. * @param state current state of the node material building
  64822. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64823. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64824. * @param worldPosVarName name of the variable holding the world position
  64825. * @returns the shader code
  64826. */
  64827. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64828. protected _buildBlock(state: NodeMaterialBuildState): this;
  64829. }
  64830. }
  64831. declare module BABYLON {
  64832. /**
  64833. * Block used to implement the PBR metallic/roughness model
  64834. */
  64835. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64836. /**
  64837. * Gets or sets the light associated with this block
  64838. */
  64839. light: Nullable<Light>;
  64840. private _lightId;
  64841. private _scene;
  64842. private _environmentBRDFTexture;
  64843. private _environmentBrdfSamplerName;
  64844. private _vNormalWName;
  64845. private _invertNormalName;
  64846. /**
  64847. * Create a new ReflectionBlock
  64848. * @param name defines the block name
  64849. */
  64850. constructor(name: string);
  64851. /**
  64852. * Intensity of the direct lights e.g. the four lights available in your scene.
  64853. * This impacts both the direct diffuse and specular highlights.
  64854. */
  64855. directIntensity: number;
  64856. /**
  64857. * Intensity of the environment e.g. how much the environment will light the object
  64858. * either through harmonics for rough material or through the refelction for shiny ones.
  64859. */
  64860. environmentIntensity: number;
  64861. /**
  64862. * This is a special control allowing the reduction of the specular highlights coming from the
  64863. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64864. */
  64865. specularIntensity: number;
  64866. /**
  64867. * Defines the falloff type used in this material.
  64868. * It by default is Physical.
  64869. */
  64870. lightFalloff: number;
  64871. /**
  64872. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64873. */
  64874. useAlphaFromAlbedoTexture: boolean;
  64875. /**
  64876. * Specifies that alpha test should be used
  64877. */
  64878. useAlphaTest: boolean;
  64879. /**
  64880. * Defines the alpha limits in alpha test mode.
  64881. */
  64882. alphaTestCutoff: number;
  64883. /**
  64884. * Specifies that alpha blending should be used
  64885. */
  64886. useAlphaBlending: boolean;
  64887. /**
  64888. * Defines if the alpha value should be determined via the rgb values.
  64889. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64890. */
  64891. opacityRGB: boolean;
  64892. /**
  64893. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64894. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64895. */
  64896. useRadianceOverAlpha: boolean;
  64897. /**
  64898. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64899. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64900. */
  64901. useSpecularOverAlpha: boolean;
  64902. /**
  64903. * Enables specular anti aliasing in the PBR shader.
  64904. * It will both interacts on the Geometry for analytical and IBL lighting.
  64905. * It also prefilter the roughness map based on the bump values.
  64906. */
  64907. enableSpecularAntiAliasing: boolean;
  64908. /**
  64909. * Enables realtime filtering on the texture.
  64910. */
  64911. realTimeFiltering: boolean;
  64912. /**
  64913. * Quality switch for realtime filtering
  64914. */
  64915. realTimeFilteringQuality: number;
  64916. /**
  64917. * Defines if the material uses energy conservation.
  64918. */
  64919. useEnergyConservation: boolean;
  64920. /**
  64921. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64922. * too much the area relying on ambient texture to define their ambient occlusion.
  64923. */
  64924. useRadianceOcclusion: boolean;
  64925. /**
  64926. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64927. * makes the reflect vector face the model (under horizon).
  64928. */
  64929. useHorizonOcclusion: boolean;
  64930. /**
  64931. * If set to true, no lighting calculations will be applied.
  64932. */
  64933. unlit: boolean;
  64934. /**
  64935. * Force normal to face away from face.
  64936. */
  64937. forceNormalForward: boolean;
  64938. /**
  64939. * Defines the material debug mode.
  64940. * It helps seeing only some components of the material while troubleshooting.
  64941. */
  64942. debugMode: number;
  64943. /**
  64944. * Specify from where on screen the debug mode should start.
  64945. * The value goes from -1 (full screen) to 1 (not visible)
  64946. * It helps with side by side comparison against the final render
  64947. * This defaults to 0
  64948. */
  64949. debugLimit: number;
  64950. /**
  64951. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64952. * You can use the factor to better multiply the final value.
  64953. */
  64954. debugFactor: number;
  64955. /**
  64956. * Initialize the block and prepare the context for build
  64957. * @param state defines the state that will be used for the build
  64958. */
  64959. initialize(state: NodeMaterialBuildState): void;
  64960. /**
  64961. * Gets the current class name
  64962. * @returns the class name
  64963. */
  64964. getClassName(): string;
  64965. /**
  64966. * Gets the world position input component
  64967. */
  64968. get worldPosition(): NodeMaterialConnectionPoint;
  64969. /**
  64970. * Gets the world normal input component
  64971. */
  64972. get worldNormal(): NodeMaterialConnectionPoint;
  64973. /**
  64974. * Gets the perturbed normal input component
  64975. */
  64976. get perturbedNormal(): NodeMaterialConnectionPoint;
  64977. /**
  64978. * Gets the camera position input component
  64979. */
  64980. get cameraPosition(): NodeMaterialConnectionPoint;
  64981. /**
  64982. * Gets the base color input component
  64983. */
  64984. get baseColor(): NodeMaterialConnectionPoint;
  64985. /**
  64986. * Gets the opacity texture input component
  64987. */
  64988. get opacityTexture(): NodeMaterialConnectionPoint;
  64989. /**
  64990. * Gets the ambient color input component
  64991. */
  64992. get ambientColor(): NodeMaterialConnectionPoint;
  64993. /**
  64994. * Gets the reflectivity object parameters
  64995. */
  64996. get reflectivity(): NodeMaterialConnectionPoint;
  64997. /**
  64998. * Gets the ambient occlusion object parameters
  64999. */
  65000. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65001. /**
  65002. * Gets the reflection object parameters
  65003. */
  65004. get reflection(): NodeMaterialConnectionPoint;
  65005. /**
  65006. * Gets the sheen object parameters
  65007. */
  65008. get sheen(): NodeMaterialConnectionPoint;
  65009. /**
  65010. * Gets the clear coat object parameters
  65011. */
  65012. get clearcoat(): NodeMaterialConnectionPoint;
  65013. /**
  65014. * Gets the sub surface object parameters
  65015. */
  65016. get subsurface(): NodeMaterialConnectionPoint;
  65017. /**
  65018. * Gets the anisotropy object parameters
  65019. */
  65020. get anisotropy(): NodeMaterialConnectionPoint;
  65021. /**
  65022. * Gets the ambient output component
  65023. */
  65024. get ambient(): NodeMaterialConnectionPoint;
  65025. /**
  65026. * Gets the diffuse output component
  65027. */
  65028. get diffuse(): NodeMaterialConnectionPoint;
  65029. /**
  65030. * Gets the specular output component
  65031. */
  65032. get specular(): NodeMaterialConnectionPoint;
  65033. /**
  65034. * Gets the sheen output component
  65035. */
  65036. get sheenDir(): NodeMaterialConnectionPoint;
  65037. /**
  65038. * Gets the clear coat output component
  65039. */
  65040. get clearcoatDir(): NodeMaterialConnectionPoint;
  65041. /**
  65042. * Gets the indirect diffuse output component
  65043. */
  65044. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65045. /**
  65046. * Gets the indirect specular output component
  65047. */
  65048. get specularIndirect(): NodeMaterialConnectionPoint;
  65049. /**
  65050. * Gets the indirect sheen output component
  65051. */
  65052. get sheenIndirect(): NodeMaterialConnectionPoint;
  65053. /**
  65054. * Gets the indirect clear coat output component
  65055. */
  65056. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65057. /**
  65058. * Gets the refraction output component
  65059. */
  65060. get refraction(): NodeMaterialConnectionPoint;
  65061. /**
  65062. * Gets the global lighting output component
  65063. */
  65064. get lighting(): NodeMaterialConnectionPoint;
  65065. /**
  65066. * Gets the shadow output component
  65067. */
  65068. get shadow(): NodeMaterialConnectionPoint;
  65069. /**
  65070. * Gets the alpha output component
  65071. */
  65072. get alpha(): NodeMaterialConnectionPoint;
  65073. autoConfigure(material: NodeMaterial): void;
  65074. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65075. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65076. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65077. private _injectVertexCode;
  65078. /**
  65079. * Gets the code corresponding to the albedo/opacity module
  65080. * @returns the shader code
  65081. */
  65082. getAlbedoOpacityCode(): string;
  65083. protected _buildBlock(state: NodeMaterialBuildState): this;
  65084. protected _dumpPropertiesCode(): string;
  65085. serialize(): any;
  65086. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65087. }
  65088. }
  65089. declare module BABYLON {
  65090. /**
  65091. * Block used to compute value of one parameter modulo another
  65092. */
  65093. export class ModBlock extends NodeMaterialBlock {
  65094. /**
  65095. * Creates a new ModBlock
  65096. * @param name defines the block name
  65097. */
  65098. constructor(name: string);
  65099. /**
  65100. * Gets the current class name
  65101. * @returns the class name
  65102. */
  65103. getClassName(): string;
  65104. /**
  65105. * Gets the left operand input component
  65106. */
  65107. get left(): NodeMaterialConnectionPoint;
  65108. /**
  65109. * Gets the right operand input component
  65110. */
  65111. get right(): NodeMaterialConnectionPoint;
  65112. /**
  65113. * Gets the output component
  65114. */
  65115. get output(): NodeMaterialConnectionPoint;
  65116. protected _buildBlock(state: NodeMaterialBuildState): this;
  65117. }
  65118. }
  65119. declare module BABYLON {
  65120. /**
  65121. * Configuration for Draco compression
  65122. */
  65123. export interface IDracoCompressionConfiguration {
  65124. /**
  65125. * Configuration for the decoder.
  65126. */
  65127. decoder: {
  65128. /**
  65129. * The url to the WebAssembly module.
  65130. */
  65131. wasmUrl?: string;
  65132. /**
  65133. * The url to the WebAssembly binary.
  65134. */
  65135. wasmBinaryUrl?: string;
  65136. /**
  65137. * The url to the fallback JavaScript module.
  65138. */
  65139. fallbackUrl?: string;
  65140. };
  65141. }
  65142. /**
  65143. * Draco compression (https://google.github.io/draco/)
  65144. *
  65145. * This class wraps the Draco module.
  65146. *
  65147. * **Encoder**
  65148. *
  65149. * The encoder is not currently implemented.
  65150. *
  65151. * **Decoder**
  65152. *
  65153. * 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.
  65154. *
  65155. * To update the configuration, use the following code:
  65156. * ```javascript
  65157. * DracoCompression.Configuration = {
  65158. * decoder: {
  65159. * wasmUrl: "<url to the WebAssembly library>",
  65160. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65161. * fallbackUrl: "<url to the fallback JavaScript library>",
  65162. * }
  65163. * };
  65164. * ```
  65165. *
  65166. * 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.
  65167. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65168. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65169. *
  65170. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65171. * ```javascript
  65172. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65173. * ```
  65174. *
  65175. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65176. */
  65177. export class DracoCompression implements IDisposable {
  65178. private _workerPoolPromise?;
  65179. private _decoderModulePromise?;
  65180. /**
  65181. * The configuration. Defaults to the following urls:
  65182. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65183. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65184. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65185. */
  65186. static Configuration: IDracoCompressionConfiguration;
  65187. /**
  65188. * Returns true if the decoder configuration is available.
  65189. */
  65190. static get DecoderAvailable(): boolean;
  65191. /**
  65192. * Default number of workers to create when creating the draco compression object.
  65193. */
  65194. static DefaultNumWorkers: number;
  65195. private static GetDefaultNumWorkers;
  65196. private static _Default;
  65197. /**
  65198. * Default instance for the draco compression object.
  65199. */
  65200. static get Default(): DracoCompression;
  65201. /**
  65202. * Constructor
  65203. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65204. */
  65205. constructor(numWorkers?: number);
  65206. /**
  65207. * Stop all async operations and release resources.
  65208. */
  65209. dispose(): void;
  65210. /**
  65211. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65212. * @returns a promise that resolves when ready
  65213. */
  65214. whenReadyAsync(): Promise<void>;
  65215. /**
  65216. * Decode Draco compressed mesh data to vertex data.
  65217. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65218. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65219. * @returns A promise that resolves with the decoded vertex data
  65220. */
  65221. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65222. [kind: string]: number;
  65223. }): Promise<VertexData>;
  65224. }
  65225. }
  65226. declare module BABYLON {
  65227. /**
  65228. * Class for building Constructive Solid Geometry
  65229. */
  65230. export class CSG {
  65231. private polygons;
  65232. /**
  65233. * The world matrix
  65234. */
  65235. matrix: Matrix;
  65236. /**
  65237. * Stores the position
  65238. */
  65239. position: Vector3;
  65240. /**
  65241. * Stores the rotation
  65242. */
  65243. rotation: Vector3;
  65244. /**
  65245. * Stores the rotation quaternion
  65246. */
  65247. rotationQuaternion: Nullable<Quaternion>;
  65248. /**
  65249. * Stores the scaling vector
  65250. */
  65251. scaling: Vector3;
  65252. /**
  65253. * Convert the Mesh to CSG
  65254. * @param mesh The Mesh to convert to CSG
  65255. * @returns A new CSG from the Mesh
  65256. */
  65257. static FromMesh(mesh: Mesh): CSG;
  65258. /**
  65259. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65260. * @param polygons Polygons used to construct a CSG solid
  65261. */
  65262. private static FromPolygons;
  65263. /**
  65264. * Clones, or makes a deep copy, of the CSG
  65265. * @returns A new CSG
  65266. */
  65267. clone(): CSG;
  65268. /**
  65269. * Unions this CSG with another CSG
  65270. * @param csg The CSG to union against this CSG
  65271. * @returns The unioned CSG
  65272. */
  65273. union(csg: CSG): CSG;
  65274. /**
  65275. * Unions this CSG with another CSG in place
  65276. * @param csg The CSG to union against this CSG
  65277. */
  65278. unionInPlace(csg: CSG): void;
  65279. /**
  65280. * Subtracts this CSG with another CSG
  65281. * @param csg The CSG to subtract against this CSG
  65282. * @returns A new CSG
  65283. */
  65284. subtract(csg: CSG): CSG;
  65285. /**
  65286. * Subtracts this CSG with another CSG in place
  65287. * @param csg The CSG to subtact against this CSG
  65288. */
  65289. subtractInPlace(csg: CSG): void;
  65290. /**
  65291. * Intersect this CSG with another CSG
  65292. * @param csg The CSG to intersect against this CSG
  65293. * @returns A new CSG
  65294. */
  65295. intersect(csg: CSG): CSG;
  65296. /**
  65297. * Intersects this CSG with another CSG in place
  65298. * @param csg The CSG to intersect against this CSG
  65299. */
  65300. intersectInPlace(csg: CSG): void;
  65301. /**
  65302. * Return a new CSG solid with solid and empty space switched. This solid is
  65303. * not modified.
  65304. * @returns A new CSG solid with solid and empty space switched
  65305. */
  65306. inverse(): CSG;
  65307. /**
  65308. * Inverses the CSG in place
  65309. */
  65310. inverseInPlace(): void;
  65311. /**
  65312. * This is used to keep meshes transformations so they can be restored
  65313. * when we build back a Babylon Mesh
  65314. * NB : All CSG operations are performed in world coordinates
  65315. * @param csg The CSG to copy the transform attributes from
  65316. * @returns This CSG
  65317. */
  65318. copyTransformAttributes(csg: CSG): CSG;
  65319. /**
  65320. * Build Raw mesh from CSG
  65321. * Coordinates here are in world space
  65322. * @param name The name of the mesh geometry
  65323. * @param scene The Scene
  65324. * @param keepSubMeshes Specifies if the submeshes should be kept
  65325. * @returns A new Mesh
  65326. */
  65327. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65328. /**
  65329. * Build Mesh from CSG taking material and transforms into account
  65330. * @param name The name of the Mesh
  65331. * @param material The material of the Mesh
  65332. * @param scene The Scene
  65333. * @param keepSubMeshes Specifies if submeshes should be kept
  65334. * @returns The new Mesh
  65335. */
  65336. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65337. }
  65338. }
  65339. declare module BABYLON {
  65340. /**
  65341. * Class used to create a trail following a mesh
  65342. */
  65343. export class TrailMesh extends Mesh {
  65344. private _generator;
  65345. private _autoStart;
  65346. private _running;
  65347. private _diameter;
  65348. private _length;
  65349. private _sectionPolygonPointsCount;
  65350. private _sectionVectors;
  65351. private _sectionNormalVectors;
  65352. private _beforeRenderObserver;
  65353. /**
  65354. * @constructor
  65355. * @param name The value used by scene.getMeshByName() to do a lookup.
  65356. * @param generator The mesh or transform node to generate a trail.
  65357. * @param scene The scene to add this mesh to.
  65358. * @param diameter Diameter of trailing mesh. Default is 1.
  65359. * @param length Length of trailing mesh. Default is 60.
  65360. * @param autoStart Automatically start trailing mesh. Default true.
  65361. */
  65362. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65363. /**
  65364. * "TrailMesh"
  65365. * @returns "TrailMesh"
  65366. */
  65367. getClassName(): string;
  65368. private _createMesh;
  65369. /**
  65370. * Start trailing mesh.
  65371. */
  65372. start(): void;
  65373. /**
  65374. * Stop trailing mesh.
  65375. */
  65376. stop(): void;
  65377. /**
  65378. * Update trailing mesh geometry.
  65379. */
  65380. update(): void;
  65381. /**
  65382. * Returns a new TrailMesh object.
  65383. * @param name is a string, the name given to the new mesh
  65384. * @param newGenerator use new generator object for cloned trail mesh
  65385. * @returns a new mesh
  65386. */
  65387. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65388. /**
  65389. * Serializes this trail mesh
  65390. * @param serializationObject object to write serialization to
  65391. */
  65392. serialize(serializationObject: any): void;
  65393. /**
  65394. * Parses a serialized trail mesh
  65395. * @param parsedMesh the serialized mesh
  65396. * @param scene the scene to create the trail mesh in
  65397. * @returns the created trail mesh
  65398. */
  65399. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65400. }
  65401. }
  65402. declare module BABYLON {
  65403. /**
  65404. * Class containing static functions to help procedurally build meshes
  65405. */
  65406. export class TiledBoxBuilder {
  65407. /**
  65408. * Creates a box mesh
  65409. * 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)
  65410. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65412. * * 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
  65413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65414. * @param name defines the name of the mesh
  65415. * @param options defines the options used to create the mesh
  65416. * @param scene defines the hosting scene
  65417. * @returns the box mesh
  65418. */
  65419. static CreateTiledBox(name: string, options: {
  65420. pattern?: number;
  65421. width?: number;
  65422. height?: number;
  65423. depth?: number;
  65424. tileSize?: number;
  65425. tileWidth?: number;
  65426. tileHeight?: number;
  65427. alignHorizontal?: number;
  65428. alignVertical?: number;
  65429. faceUV?: Vector4[];
  65430. faceColors?: Color4[];
  65431. sideOrientation?: number;
  65432. updatable?: boolean;
  65433. }, scene?: Nullable<Scene>): Mesh;
  65434. }
  65435. }
  65436. declare module BABYLON {
  65437. /**
  65438. * Class containing static functions to help procedurally build meshes
  65439. */
  65440. export class TorusKnotBuilder {
  65441. /**
  65442. * Creates a torus knot mesh
  65443. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65444. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65445. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65446. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65448. * * 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
  65449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65450. * @param name defines the name of the mesh
  65451. * @param options defines the options used to create the mesh
  65452. * @param scene defines the hosting scene
  65453. * @returns the torus knot mesh
  65454. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65455. */
  65456. static CreateTorusKnot(name: string, options: {
  65457. radius?: number;
  65458. tube?: number;
  65459. radialSegments?: number;
  65460. tubularSegments?: number;
  65461. p?: number;
  65462. q?: number;
  65463. updatable?: boolean;
  65464. sideOrientation?: number;
  65465. frontUVs?: Vector4;
  65466. backUVs?: Vector4;
  65467. }, scene: any): Mesh;
  65468. }
  65469. }
  65470. declare module BABYLON {
  65471. /**
  65472. * Polygon
  65473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65474. */
  65475. export class Polygon {
  65476. /**
  65477. * Creates a rectangle
  65478. * @param xmin bottom X coord
  65479. * @param ymin bottom Y coord
  65480. * @param xmax top X coord
  65481. * @param ymax top Y coord
  65482. * @returns points that make the resulting rectation
  65483. */
  65484. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65485. /**
  65486. * Creates a circle
  65487. * @param radius radius of circle
  65488. * @param cx scale in x
  65489. * @param cy scale in y
  65490. * @param numberOfSides number of sides that make up the circle
  65491. * @returns points that make the resulting circle
  65492. */
  65493. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65494. /**
  65495. * Creates a polygon from input string
  65496. * @param input Input polygon data
  65497. * @returns the parsed points
  65498. */
  65499. static Parse(input: string): Vector2[];
  65500. /**
  65501. * Starts building a polygon from x and y coordinates
  65502. * @param x x coordinate
  65503. * @param y y coordinate
  65504. * @returns the started path2
  65505. */
  65506. static StartingAt(x: number, y: number): Path2;
  65507. }
  65508. /**
  65509. * Builds a polygon
  65510. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65511. */
  65512. export class PolygonMeshBuilder {
  65513. private _points;
  65514. private _outlinepoints;
  65515. private _holes;
  65516. private _name;
  65517. private _scene;
  65518. private _epoints;
  65519. private _eholes;
  65520. private _addToepoint;
  65521. /**
  65522. * Babylon reference to the earcut plugin.
  65523. */
  65524. bjsEarcut: any;
  65525. /**
  65526. * Creates a PolygonMeshBuilder
  65527. * @param name name of the builder
  65528. * @param contours Path of the polygon
  65529. * @param scene scene to add to when creating the mesh
  65530. * @param earcutInjection can be used to inject your own earcut reference
  65531. */
  65532. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65533. /**
  65534. * Adds a whole within the polygon
  65535. * @param hole Array of points defining the hole
  65536. * @returns this
  65537. */
  65538. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65539. /**
  65540. * Creates the polygon
  65541. * @param updatable If the mesh should be updatable
  65542. * @param depth The depth of the mesh created
  65543. * @returns the created mesh
  65544. */
  65545. build(updatable?: boolean, depth?: number): Mesh;
  65546. /**
  65547. * Creates the polygon
  65548. * @param depth The depth of the mesh created
  65549. * @returns the created VertexData
  65550. */
  65551. buildVertexData(depth?: number): VertexData;
  65552. /**
  65553. * Adds a side to the polygon
  65554. * @param positions points that make the polygon
  65555. * @param normals normals of the polygon
  65556. * @param uvs uvs of the polygon
  65557. * @param indices indices of the polygon
  65558. * @param bounds bounds of the polygon
  65559. * @param points points of the polygon
  65560. * @param depth depth of the polygon
  65561. * @param flip flip of the polygon
  65562. */
  65563. private addSide;
  65564. }
  65565. }
  65566. declare module BABYLON {
  65567. /**
  65568. * Class containing static functions to help procedurally build meshes
  65569. */
  65570. export class PolygonBuilder {
  65571. /**
  65572. * Creates a polygon mesh
  65573. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65574. * * 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
  65575. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65577. * * 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)
  65578. * * Remember you can only change the shape positions, not their number when updating a polygon
  65579. * @param name defines the name of the mesh
  65580. * @param options defines the options used to create the mesh
  65581. * @param scene defines the hosting scene
  65582. * @param earcutInjection can be used to inject your own earcut reference
  65583. * @returns the polygon mesh
  65584. */
  65585. static CreatePolygon(name: string, options: {
  65586. shape: Vector3[];
  65587. holes?: Vector3[][];
  65588. depth?: number;
  65589. faceUV?: Vector4[];
  65590. faceColors?: Color4[];
  65591. updatable?: boolean;
  65592. sideOrientation?: number;
  65593. frontUVs?: Vector4;
  65594. backUVs?: Vector4;
  65595. wrap?: boolean;
  65596. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65597. /**
  65598. * Creates an extruded polygon mesh, with depth in the Y direction.
  65599. * * 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)
  65600. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65601. * @param name defines the name of the mesh
  65602. * @param options defines the options used to create the mesh
  65603. * @param scene defines the hosting scene
  65604. * @param earcutInjection can be used to inject your own earcut reference
  65605. * @returns the polygon mesh
  65606. */
  65607. static ExtrudePolygon(name: string, options: {
  65608. shape: Vector3[];
  65609. holes?: Vector3[][];
  65610. depth?: number;
  65611. faceUV?: Vector4[];
  65612. faceColors?: Color4[];
  65613. updatable?: boolean;
  65614. sideOrientation?: number;
  65615. frontUVs?: Vector4;
  65616. backUVs?: Vector4;
  65617. wrap?: boolean;
  65618. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65619. }
  65620. }
  65621. declare module BABYLON {
  65622. /**
  65623. * Class containing static functions to help procedurally build meshes
  65624. */
  65625. export class LatheBuilder {
  65626. /**
  65627. * Creates lathe mesh.
  65628. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65629. * * 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
  65630. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65631. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65632. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65633. * * 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
  65634. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65635. * * 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
  65636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65637. * * 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
  65638. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65640. * @param name defines the name of the mesh
  65641. * @param options defines the options used to create the mesh
  65642. * @param scene defines the hosting scene
  65643. * @returns the lathe mesh
  65644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65645. */
  65646. static CreateLathe(name: string, options: {
  65647. shape: Vector3[];
  65648. radius?: number;
  65649. tessellation?: number;
  65650. clip?: number;
  65651. arc?: number;
  65652. closed?: boolean;
  65653. updatable?: boolean;
  65654. sideOrientation?: number;
  65655. frontUVs?: Vector4;
  65656. backUVs?: Vector4;
  65657. cap?: number;
  65658. invertUV?: boolean;
  65659. }, scene?: Nullable<Scene>): Mesh;
  65660. }
  65661. }
  65662. declare module BABYLON {
  65663. /**
  65664. * Class containing static functions to help procedurally build meshes
  65665. */
  65666. export class TiledPlaneBuilder {
  65667. /**
  65668. * Creates a tiled plane mesh
  65669. * * The parameter `pattern` will, depending on value, do nothing or
  65670. * * * flip (reflect about central vertical) alternate tiles across and up
  65671. * * * flip every tile on alternate rows
  65672. * * * rotate (180 degs) alternate tiles across and up
  65673. * * * rotate every tile on alternate rows
  65674. * * * flip and rotate alternate tiles across and up
  65675. * * * flip and rotate every tile on alternate rows
  65676. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65677. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65679. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65680. * * 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)
  65681. * * 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)
  65682. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65683. * @param name defines the name of the mesh
  65684. * @param options defines the options used to create the mesh
  65685. * @param scene defines the hosting scene
  65686. * @returns the box mesh
  65687. */
  65688. static CreateTiledPlane(name: string, options: {
  65689. pattern?: number;
  65690. tileSize?: number;
  65691. tileWidth?: number;
  65692. tileHeight?: number;
  65693. size?: number;
  65694. width?: number;
  65695. height?: number;
  65696. alignHorizontal?: number;
  65697. alignVertical?: number;
  65698. sideOrientation?: number;
  65699. frontUVs?: Vector4;
  65700. backUVs?: Vector4;
  65701. updatable?: boolean;
  65702. }, scene?: Nullable<Scene>): Mesh;
  65703. }
  65704. }
  65705. declare module BABYLON {
  65706. /**
  65707. * Class containing static functions to help procedurally build meshes
  65708. */
  65709. export class TubeBuilder {
  65710. /**
  65711. * Creates a tube mesh.
  65712. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65713. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65714. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65715. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65716. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65717. * * 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)
  65718. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65719. * * 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
  65720. * * 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
  65721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65722. * * 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
  65723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65725. * @param name defines the name of the mesh
  65726. * @param options defines the options used to create the mesh
  65727. * @param scene defines the hosting scene
  65728. * @returns the tube mesh
  65729. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65730. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65731. */
  65732. static CreateTube(name: string, options: {
  65733. path: Vector3[];
  65734. radius?: number;
  65735. tessellation?: number;
  65736. radiusFunction?: {
  65737. (i: number, distance: number): number;
  65738. };
  65739. cap?: number;
  65740. arc?: number;
  65741. updatable?: boolean;
  65742. sideOrientation?: number;
  65743. frontUVs?: Vector4;
  65744. backUVs?: Vector4;
  65745. instance?: Mesh;
  65746. invertUV?: boolean;
  65747. }, scene?: Nullable<Scene>): Mesh;
  65748. }
  65749. }
  65750. declare module BABYLON {
  65751. /**
  65752. * Class containing static functions to help procedurally build meshes
  65753. */
  65754. export class IcoSphereBuilder {
  65755. /**
  65756. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65757. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65758. * * 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`)
  65759. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65760. * * 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
  65761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65762. * * 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
  65763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65764. * @param name defines the name of the mesh
  65765. * @param options defines the options used to create the mesh
  65766. * @param scene defines the hosting scene
  65767. * @returns the icosahedron mesh
  65768. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65769. */
  65770. static CreateIcoSphere(name: string, options: {
  65771. radius?: number;
  65772. radiusX?: number;
  65773. radiusY?: number;
  65774. radiusZ?: number;
  65775. flat?: boolean;
  65776. subdivisions?: number;
  65777. sideOrientation?: number;
  65778. frontUVs?: Vector4;
  65779. backUVs?: Vector4;
  65780. updatable?: boolean;
  65781. }, scene?: Nullable<Scene>): Mesh;
  65782. }
  65783. }
  65784. declare module BABYLON {
  65785. /**
  65786. * Class containing static functions to help procedurally build meshes
  65787. */
  65788. export class DecalBuilder {
  65789. /**
  65790. * Creates a decal mesh.
  65791. * 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
  65792. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65793. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65794. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65795. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65796. * @param name defines the name of the mesh
  65797. * @param sourceMesh defines the mesh where the decal must be applied
  65798. * @param options defines the options used to create the mesh
  65799. * @param scene defines the hosting scene
  65800. * @returns the decal mesh
  65801. * @see https://doc.babylonjs.com/how_to/decals
  65802. */
  65803. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65804. position?: Vector3;
  65805. normal?: Vector3;
  65806. size?: Vector3;
  65807. angle?: number;
  65808. }): Mesh;
  65809. }
  65810. }
  65811. declare module BABYLON {
  65812. /**
  65813. * Class containing static functions to help procedurally build meshes
  65814. */
  65815. export class MeshBuilder {
  65816. /**
  65817. * Creates a box mesh
  65818. * * The parameter `size` sets the size (float) of each box side (default 1)
  65819. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65820. * * 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)
  65821. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65823. * * 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
  65824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65825. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65826. * @param name defines the name of the mesh
  65827. * @param options defines the options used to create the mesh
  65828. * @param scene defines the hosting scene
  65829. * @returns the box mesh
  65830. */
  65831. static CreateBox(name: string, options: {
  65832. size?: number;
  65833. width?: number;
  65834. height?: number;
  65835. depth?: number;
  65836. faceUV?: Vector4[];
  65837. faceColors?: Color4[];
  65838. sideOrientation?: number;
  65839. frontUVs?: Vector4;
  65840. backUVs?: Vector4;
  65841. wrap?: boolean;
  65842. topBaseAt?: number;
  65843. bottomBaseAt?: number;
  65844. updatable?: boolean;
  65845. }, scene?: Nullable<Scene>): Mesh;
  65846. /**
  65847. * Creates a tiled box mesh
  65848. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65850. * @param name defines the name of the mesh
  65851. * @param options defines the options used to create the mesh
  65852. * @param scene defines the hosting scene
  65853. * @returns the tiled box mesh
  65854. */
  65855. static CreateTiledBox(name: string, options: {
  65856. pattern?: number;
  65857. size?: number;
  65858. width?: number;
  65859. height?: number;
  65860. depth: number;
  65861. tileSize?: number;
  65862. tileWidth?: number;
  65863. tileHeight?: number;
  65864. faceUV?: Vector4[];
  65865. faceColors?: Color4[];
  65866. alignHorizontal?: number;
  65867. alignVertical?: number;
  65868. sideOrientation?: number;
  65869. updatable?: boolean;
  65870. }, scene?: Nullable<Scene>): Mesh;
  65871. /**
  65872. * Creates a sphere mesh
  65873. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65874. * * 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`)
  65875. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65876. * * 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
  65877. * * 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)
  65878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65879. * * 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
  65880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65881. * @param name defines the name of the mesh
  65882. * @param options defines the options used to create the mesh
  65883. * @param scene defines the hosting scene
  65884. * @returns the sphere mesh
  65885. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65886. */
  65887. static CreateSphere(name: string, options: {
  65888. segments?: number;
  65889. diameter?: number;
  65890. diameterX?: number;
  65891. diameterY?: number;
  65892. diameterZ?: number;
  65893. arc?: number;
  65894. slice?: number;
  65895. sideOrientation?: number;
  65896. frontUVs?: Vector4;
  65897. backUVs?: Vector4;
  65898. updatable?: boolean;
  65899. }, scene?: Nullable<Scene>): Mesh;
  65900. /**
  65901. * Creates a plane polygonal mesh. By default, this is a disc
  65902. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65903. * * 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
  65904. * * 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
  65905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65906. * * 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
  65907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65908. * @param name defines the name of the mesh
  65909. * @param options defines the options used to create the mesh
  65910. * @param scene defines the hosting scene
  65911. * @returns the plane polygonal mesh
  65912. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65913. */
  65914. static CreateDisc(name: string, options: {
  65915. radius?: number;
  65916. tessellation?: number;
  65917. arc?: number;
  65918. updatable?: boolean;
  65919. sideOrientation?: number;
  65920. frontUVs?: Vector4;
  65921. backUVs?: Vector4;
  65922. }, scene?: Nullable<Scene>): Mesh;
  65923. /**
  65924. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65925. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65926. * * 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`)
  65927. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65928. * * 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
  65929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65930. * * 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
  65931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65932. * @param name defines the name of the mesh
  65933. * @param options defines the options used to create the mesh
  65934. * @param scene defines the hosting scene
  65935. * @returns the icosahedron mesh
  65936. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65937. */
  65938. static CreateIcoSphere(name: string, options: {
  65939. radius?: number;
  65940. radiusX?: number;
  65941. radiusY?: number;
  65942. radiusZ?: number;
  65943. flat?: boolean;
  65944. subdivisions?: number;
  65945. sideOrientation?: number;
  65946. frontUVs?: Vector4;
  65947. backUVs?: Vector4;
  65948. updatable?: boolean;
  65949. }, scene?: Nullable<Scene>): Mesh;
  65950. /**
  65951. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65952. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65953. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65954. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65955. * * 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
  65956. * * 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
  65957. * * 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
  65958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65959. * * 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
  65960. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65961. * * 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
  65962. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65963. * * 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
  65964. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65966. * @param name defines the name of the mesh
  65967. * @param options defines the options used to create the mesh
  65968. * @param scene defines the hosting scene
  65969. * @returns the ribbon mesh
  65970. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65971. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65972. */
  65973. static CreateRibbon(name: string, options: {
  65974. pathArray: Vector3[][];
  65975. closeArray?: boolean;
  65976. closePath?: boolean;
  65977. offset?: number;
  65978. updatable?: boolean;
  65979. sideOrientation?: number;
  65980. frontUVs?: Vector4;
  65981. backUVs?: Vector4;
  65982. instance?: Mesh;
  65983. invertUV?: boolean;
  65984. uvs?: Vector2[];
  65985. colors?: Color4[];
  65986. }, scene?: Nullable<Scene>): Mesh;
  65987. /**
  65988. * Creates a cylinder or a cone mesh
  65989. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65990. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65991. * * 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.
  65992. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65993. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65994. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65995. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65996. * * 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).
  65997. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65998. * * 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).
  65999. * * 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
  66000. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66001. * * 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
  66002. * * 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.
  66003. * * If `enclose` is false, a ring surface is one element.
  66004. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66005. * * 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
  66006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66007. * * 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
  66008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66009. * @param name defines the name of the mesh
  66010. * @param options defines the options used to create the mesh
  66011. * @param scene defines the hosting scene
  66012. * @returns the cylinder mesh
  66013. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66014. */
  66015. static CreateCylinder(name: string, options: {
  66016. height?: number;
  66017. diameterTop?: number;
  66018. diameterBottom?: number;
  66019. diameter?: number;
  66020. tessellation?: number;
  66021. subdivisions?: number;
  66022. arc?: number;
  66023. faceColors?: Color4[];
  66024. faceUV?: Vector4[];
  66025. updatable?: boolean;
  66026. hasRings?: boolean;
  66027. enclose?: boolean;
  66028. cap?: number;
  66029. sideOrientation?: number;
  66030. frontUVs?: Vector4;
  66031. backUVs?: Vector4;
  66032. }, scene?: Nullable<Scene>): Mesh;
  66033. /**
  66034. * Creates a torus mesh
  66035. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66036. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66037. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66039. * * 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
  66040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66041. * @param name defines the name of the mesh
  66042. * @param options defines the options used to create the mesh
  66043. * @param scene defines the hosting scene
  66044. * @returns the torus mesh
  66045. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66046. */
  66047. static CreateTorus(name: string, options: {
  66048. diameter?: number;
  66049. thickness?: number;
  66050. tessellation?: number;
  66051. updatable?: boolean;
  66052. sideOrientation?: number;
  66053. frontUVs?: Vector4;
  66054. backUVs?: Vector4;
  66055. }, scene?: Nullable<Scene>): Mesh;
  66056. /**
  66057. * Creates a torus knot mesh
  66058. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66059. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66060. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66061. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66063. * * 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
  66064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66065. * @param name defines the name of the mesh
  66066. * @param options defines the options used to create the mesh
  66067. * @param scene defines the hosting scene
  66068. * @returns the torus knot mesh
  66069. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66070. */
  66071. static CreateTorusKnot(name: string, options: {
  66072. radius?: number;
  66073. tube?: number;
  66074. radialSegments?: number;
  66075. tubularSegments?: number;
  66076. p?: number;
  66077. q?: number;
  66078. updatable?: boolean;
  66079. sideOrientation?: number;
  66080. frontUVs?: Vector4;
  66081. backUVs?: Vector4;
  66082. }, scene?: Nullable<Scene>): Mesh;
  66083. /**
  66084. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66085. * * 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
  66086. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66087. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66088. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66089. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66090. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66091. * * 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
  66092. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66095. * @param name defines the name of the new line system
  66096. * @param options defines the options used to create the line system
  66097. * @param scene defines the hosting scene
  66098. * @returns a new line system mesh
  66099. */
  66100. static CreateLineSystem(name: string, options: {
  66101. lines: Vector3[][];
  66102. updatable?: boolean;
  66103. instance?: Nullable<LinesMesh>;
  66104. colors?: Nullable<Color4[][]>;
  66105. useVertexAlpha?: boolean;
  66106. }, scene: Nullable<Scene>): LinesMesh;
  66107. /**
  66108. * Creates a line mesh
  66109. * 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
  66110. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66111. * * The parameter `points` is an array successive Vector3
  66112. * * 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
  66113. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66114. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66115. * * When updating an instance, remember that only point positions can change, not the number of points
  66116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66118. * @param name defines the name of the new line system
  66119. * @param options defines the options used to create the line system
  66120. * @param scene defines the hosting scene
  66121. * @returns a new line mesh
  66122. */
  66123. static CreateLines(name: string, options: {
  66124. points: Vector3[];
  66125. updatable?: boolean;
  66126. instance?: Nullable<LinesMesh>;
  66127. colors?: Color4[];
  66128. useVertexAlpha?: boolean;
  66129. }, scene?: Nullable<Scene>): LinesMesh;
  66130. /**
  66131. * Creates a dashed line mesh
  66132. * * 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
  66133. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66134. * * The parameter `points` is an array successive Vector3
  66135. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66136. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66137. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66138. * * 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
  66139. * * When updating an instance, remember that only point positions can change, not the number of points
  66140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66141. * @param name defines the name of the mesh
  66142. * @param options defines the options used to create the mesh
  66143. * @param scene defines the hosting scene
  66144. * @returns the dashed line mesh
  66145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66146. */
  66147. static CreateDashedLines(name: string, options: {
  66148. points: Vector3[];
  66149. dashSize?: number;
  66150. gapSize?: number;
  66151. dashNb?: number;
  66152. updatable?: boolean;
  66153. instance?: LinesMesh;
  66154. }, scene?: Nullable<Scene>): LinesMesh;
  66155. /**
  66156. * 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.
  66157. * * 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.
  66158. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66159. * * 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.
  66160. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66161. * * 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
  66162. * * 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
  66163. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66165. * * 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
  66166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66168. * @param name defines the name of the mesh
  66169. * @param options defines the options used to create the mesh
  66170. * @param scene defines the hosting scene
  66171. * @returns the extruded shape mesh
  66172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66174. */
  66175. static ExtrudeShape(name: string, options: {
  66176. shape: Vector3[];
  66177. path: Vector3[];
  66178. scale?: number;
  66179. rotation?: number;
  66180. cap?: number;
  66181. updatable?: boolean;
  66182. sideOrientation?: number;
  66183. frontUVs?: Vector4;
  66184. backUVs?: Vector4;
  66185. instance?: Mesh;
  66186. invertUV?: boolean;
  66187. }, scene?: Nullable<Scene>): Mesh;
  66188. /**
  66189. * Creates an custom extruded shape mesh.
  66190. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66191. * * 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.
  66192. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66193. * * 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
  66194. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66195. * * 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
  66196. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66197. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66198. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66199. * * 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
  66200. * * 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
  66201. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66203. * * 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
  66204. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66206. * @param name defines the name of the mesh
  66207. * @param options defines the options used to create the mesh
  66208. * @param scene defines the hosting scene
  66209. * @returns the custom extruded shape mesh
  66210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66211. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66213. */
  66214. static ExtrudeShapeCustom(name: string, options: {
  66215. shape: Vector3[];
  66216. path: Vector3[];
  66217. scaleFunction?: any;
  66218. rotationFunction?: any;
  66219. ribbonCloseArray?: boolean;
  66220. ribbonClosePath?: boolean;
  66221. cap?: number;
  66222. updatable?: boolean;
  66223. sideOrientation?: number;
  66224. frontUVs?: Vector4;
  66225. backUVs?: Vector4;
  66226. instance?: Mesh;
  66227. invertUV?: boolean;
  66228. }, scene?: Nullable<Scene>): Mesh;
  66229. /**
  66230. * Creates lathe mesh.
  66231. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66232. * * 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
  66233. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66234. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66235. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66236. * * 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
  66237. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66238. * * 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
  66239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66240. * * 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
  66241. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66243. * @param name defines the name of the mesh
  66244. * @param options defines the options used to create the mesh
  66245. * @param scene defines the hosting scene
  66246. * @returns the lathe mesh
  66247. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66248. */
  66249. static CreateLathe(name: string, options: {
  66250. shape: Vector3[];
  66251. radius?: number;
  66252. tessellation?: number;
  66253. clip?: number;
  66254. arc?: number;
  66255. closed?: boolean;
  66256. updatable?: boolean;
  66257. sideOrientation?: number;
  66258. frontUVs?: Vector4;
  66259. backUVs?: Vector4;
  66260. cap?: number;
  66261. invertUV?: boolean;
  66262. }, scene?: Nullable<Scene>): Mesh;
  66263. /**
  66264. * Creates a tiled plane mesh
  66265. * * You can set a limited pattern arrangement with the tiles
  66266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66267. * * 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
  66268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66269. * @param name defines the name of the mesh
  66270. * @param options defines the options used to create the mesh
  66271. * @param scene defines the hosting scene
  66272. * @returns the plane mesh
  66273. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66274. */
  66275. static CreateTiledPlane(name: string, options: {
  66276. pattern?: number;
  66277. tileSize?: number;
  66278. tileWidth?: number;
  66279. tileHeight?: number;
  66280. size?: number;
  66281. width?: number;
  66282. height?: number;
  66283. alignHorizontal?: number;
  66284. alignVertical?: number;
  66285. sideOrientation?: number;
  66286. frontUVs?: Vector4;
  66287. backUVs?: Vector4;
  66288. updatable?: boolean;
  66289. }, scene?: Nullable<Scene>): Mesh;
  66290. /**
  66291. * Creates a plane mesh
  66292. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66293. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66294. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66296. * * 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
  66297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66298. * @param name defines the name of the mesh
  66299. * @param options defines the options used to create the mesh
  66300. * @param scene defines the hosting scene
  66301. * @returns the plane mesh
  66302. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66303. */
  66304. static CreatePlane(name: string, options: {
  66305. size?: number;
  66306. width?: number;
  66307. height?: number;
  66308. sideOrientation?: number;
  66309. frontUVs?: Vector4;
  66310. backUVs?: Vector4;
  66311. updatable?: boolean;
  66312. sourcePlane?: Plane;
  66313. }, scene?: Nullable<Scene>): Mesh;
  66314. /**
  66315. * Creates a ground mesh
  66316. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66317. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66319. * @param name defines the name of the mesh
  66320. * @param options defines the options used to create the mesh
  66321. * @param scene defines the hosting scene
  66322. * @returns the ground mesh
  66323. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66324. */
  66325. static CreateGround(name: string, options: {
  66326. width?: number;
  66327. height?: number;
  66328. subdivisions?: number;
  66329. subdivisionsX?: number;
  66330. subdivisionsY?: number;
  66331. updatable?: boolean;
  66332. }, scene?: Nullable<Scene>): Mesh;
  66333. /**
  66334. * Creates a tiled ground mesh
  66335. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66336. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66337. * * 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
  66338. * * 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
  66339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66340. * @param name defines the name of the mesh
  66341. * @param options defines the options used to create the mesh
  66342. * @param scene defines the hosting scene
  66343. * @returns the tiled ground mesh
  66344. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66345. */
  66346. static CreateTiledGround(name: string, options: {
  66347. xmin: number;
  66348. zmin: number;
  66349. xmax: number;
  66350. zmax: number;
  66351. subdivisions?: {
  66352. w: number;
  66353. h: number;
  66354. };
  66355. precision?: {
  66356. w: number;
  66357. h: number;
  66358. };
  66359. updatable?: boolean;
  66360. }, scene?: Nullable<Scene>): Mesh;
  66361. /**
  66362. * Creates a ground mesh from a height map
  66363. * * The parameter `url` sets the URL of the height map image resource.
  66364. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66365. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66366. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66367. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66368. * * 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.
  66369. * * 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).
  66370. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66372. * @param name defines the name of the mesh
  66373. * @param url defines the url to the height map
  66374. * @param options defines the options used to create the mesh
  66375. * @param scene defines the hosting scene
  66376. * @returns the ground mesh
  66377. * @see https://doc.babylonjs.com/babylon101/height_map
  66378. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66379. */
  66380. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66381. width?: number;
  66382. height?: number;
  66383. subdivisions?: number;
  66384. minHeight?: number;
  66385. maxHeight?: number;
  66386. colorFilter?: Color3;
  66387. alphaFilter?: number;
  66388. updatable?: boolean;
  66389. onReady?: (mesh: GroundMesh) => void;
  66390. }, scene?: Nullable<Scene>): GroundMesh;
  66391. /**
  66392. * Creates a polygon mesh
  66393. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66394. * * 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
  66395. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66397. * * 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)
  66398. * * Remember you can only change the shape positions, not their number when updating a polygon
  66399. * @param name defines the name of the mesh
  66400. * @param options defines the options used to create the mesh
  66401. * @param scene defines the hosting scene
  66402. * @param earcutInjection can be used to inject your own earcut reference
  66403. * @returns the polygon mesh
  66404. */
  66405. static CreatePolygon(name: string, options: {
  66406. shape: Vector3[];
  66407. holes?: Vector3[][];
  66408. depth?: number;
  66409. faceUV?: Vector4[];
  66410. faceColors?: Color4[];
  66411. updatable?: boolean;
  66412. sideOrientation?: number;
  66413. frontUVs?: Vector4;
  66414. backUVs?: Vector4;
  66415. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66416. /**
  66417. * Creates an extruded polygon mesh, with depth in the Y direction.
  66418. * * 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)
  66419. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66420. * @param name defines the name of the mesh
  66421. * @param options defines the options used to create the mesh
  66422. * @param scene defines the hosting scene
  66423. * @param earcutInjection can be used to inject your own earcut reference
  66424. * @returns the polygon mesh
  66425. */
  66426. static ExtrudePolygon(name: string, options: {
  66427. shape: Vector3[];
  66428. holes?: Vector3[][];
  66429. depth?: number;
  66430. faceUV?: Vector4[];
  66431. faceColors?: Color4[];
  66432. updatable?: boolean;
  66433. sideOrientation?: number;
  66434. frontUVs?: Vector4;
  66435. backUVs?: Vector4;
  66436. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66437. /**
  66438. * Creates a tube mesh.
  66439. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66440. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66441. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66442. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66443. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66444. * * 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)
  66445. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66446. * * 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
  66447. * * 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
  66448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66449. * * 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
  66450. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66452. * @param name defines the name of the mesh
  66453. * @param options defines the options used to create the mesh
  66454. * @param scene defines the hosting scene
  66455. * @returns the tube mesh
  66456. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66457. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66458. */
  66459. static CreateTube(name: string, options: {
  66460. path: Vector3[];
  66461. radius?: number;
  66462. tessellation?: number;
  66463. radiusFunction?: {
  66464. (i: number, distance: number): number;
  66465. };
  66466. cap?: number;
  66467. arc?: number;
  66468. updatable?: boolean;
  66469. sideOrientation?: number;
  66470. frontUVs?: Vector4;
  66471. backUVs?: Vector4;
  66472. instance?: Mesh;
  66473. invertUV?: boolean;
  66474. }, scene?: Nullable<Scene>): Mesh;
  66475. /**
  66476. * Creates a polyhedron mesh
  66477. * * 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
  66478. * * The parameter `size` (positive float, default 1) sets the polygon size
  66479. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66480. * * 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`
  66481. * * 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
  66482. * * 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)`)
  66483. * * 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
  66484. * * 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
  66485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66486. * * 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
  66487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66488. * @param name defines the name of the mesh
  66489. * @param options defines the options used to create the mesh
  66490. * @param scene defines the hosting scene
  66491. * @returns the polyhedron mesh
  66492. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66493. */
  66494. static CreatePolyhedron(name: string, options: {
  66495. type?: number;
  66496. size?: number;
  66497. sizeX?: number;
  66498. sizeY?: number;
  66499. sizeZ?: number;
  66500. custom?: any;
  66501. faceUV?: Vector4[];
  66502. faceColors?: Color4[];
  66503. flat?: boolean;
  66504. updatable?: boolean;
  66505. sideOrientation?: number;
  66506. frontUVs?: Vector4;
  66507. backUVs?: Vector4;
  66508. }, scene?: Nullable<Scene>): Mesh;
  66509. /**
  66510. * Creates a decal mesh.
  66511. * 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
  66512. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66513. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66514. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66515. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66516. * @param name defines the name of the mesh
  66517. * @param sourceMesh defines the mesh where the decal must be applied
  66518. * @param options defines the options used to create the mesh
  66519. * @param scene defines the hosting scene
  66520. * @returns the decal mesh
  66521. * @see https://doc.babylonjs.com/how_to/decals
  66522. */
  66523. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66524. position?: Vector3;
  66525. normal?: Vector3;
  66526. size?: Vector3;
  66527. angle?: number;
  66528. }): Mesh;
  66529. /**
  66530. * Creates a Capsule Mesh
  66531. * @param name defines the name of the mesh.
  66532. * @param options the constructors options used to shape the mesh.
  66533. * @param scene defines the scene the mesh is scoped to.
  66534. * @returns the capsule mesh
  66535. * @see https://doc.babylonjs.com/how_to/capsule_shape
  66536. */
  66537. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  66538. }
  66539. }
  66540. declare module BABYLON {
  66541. /**
  66542. * A simplifier interface for future simplification implementations
  66543. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66544. */
  66545. export interface ISimplifier {
  66546. /**
  66547. * Simplification of a given mesh according to the given settings.
  66548. * Since this requires computation, it is assumed that the function runs async.
  66549. * @param settings The settings of the simplification, including quality and distance
  66550. * @param successCallback A callback that will be called after the mesh was simplified.
  66551. * @param errorCallback in case of an error, this callback will be called. optional.
  66552. */
  66553. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66554. }
  66555. /**
  66556. * Expected simplification settings.
  66557. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66558. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66559. */
  66560. export interface ISimplificationSettings {
  66561. /**
  66562. * Gets or sets the expected quality
  66563. */
  66564. quality: number;
  66565. /**
  66566. * Gets or sets the distance when this optimized version should be used
  66567. */
  66568. distance: number;
  66569. /**
  66570. * Gets an already optimized mesh
  66571. */
  66572. optimizeMesh?: boolean;
  66573. }
  66574. /**
  66575. * Class used to specify simplification options
  66576. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66577. */
  66578. export class SimplificationSettings implements ISimplificationSettings {
  66579. /** expected quality */
  66580. quality: number;
  66581. /** distance when this optimized version should be used */
  66582. distance: number;
  66583. /** already optimized mesh */
  66584. optimizeMesh?: boolean | undefined;
  66585. /**
  66586. * Creates a SimplificationSettings
  66587. * @param quality expected quality
  66588. * @param distance distance when this optimized version should be used
  66589. * @param optimizeMesh already optimized mesh
  66590. */
  66591. constructor(
  66592. /** expected quality */
  66593. quality: number,
  66594. /** distance when this optimized version should be used */
  66595. distance: number,
  66596. /** already optimized mesh */
  66597. optimizeMesh?: boolean | undefined);
  66598. }
  66599. /**
  66600. * Interface used to define a simplification task
  66601. */
  66602. export interface ISimplificationTask {
  66603. /**
  66604. * Array of settings
  66605. */
  66606. settings: Array<ISimplificationSettings>;
  66607. /**
  66608. * Simplification type
  66609. */
  66610. simplificationType: SimplificationType;
  66611. /**
  66612. * Mesh to simplify
  66613. */
  66614. mesh: Mesh;
  66615. /**
  66616. * Callback called on success
  66617. */
  66618. successCallback?: () => void;
  66619. /**
  66620. * Defines if parallel processing can be used
  66621. */
  66622. parallelProcessing: boolean;
  66623. }
  66624. /**
  66625. * Queue used to order the simplification tasks
  66626. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66627. */
  66628. export class SimplificationQueue {
  66629. private _simplificationArray;
  66630. /**
  66631. * Gets a boolean indicating that the process is still running
  66632. */
  66633. running: boolean;
  66634. /**
  66635. * Creates a new queue
  66636. */
  66637. constructor();
  66638. /**
  66639. * Adds a new simplification task
  66640. * @param task defines a task to add
  66641. */
  66642. addTask(task: ISimplificationTask): void;
  66643. /**
  66644. * Execute next task
  66645. */
  66646. executeNext(): void;
  66647. /**
  66648. * Execute a simplification task
  66649. * @param task defines the task to run
  66650. */
  66651. runSimplification(task: ISimplificationTask): void;
  66652. private getSimplifier;
  66653. }
  66654. /**
  66655. * The implemented types of simplification
  66656. * At the moment only Quadratic Error Decimation is implemented
  66657. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66658. */
  66659. export enum SimplificationType {
  66660. /** Quadratic error decimation */
  66661. QUADRATIC = 0
  66662. }
  66663. /**
  66664. * An implementation of the Quadratic Error simplification algorithm.
  66665. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66666. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66667. * @author RaananW
  66668. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66669. */
  66670. export class QuadraticErrorSimplification implements ISimplifier {
  66671. private _mesh;
  66672. private triangles;
  66673. private vertices;
  66674. private references;
  66675. private _reconstructedMesh;
  66676. /** Gets or sets the number pf sync interations */
  66677. syncIterations: number;
  66678. /** Gets or sets the aggressiveness of the simplifier */
  66679. aggressiveness: number;
  66680. /** Gets or sets the number of allowed iterations for decimation */
  66681. decimationIterations: number;
  66682. /** Gets or sets the espilon to use for bounding box computation */
  66683. boundingBoxEpsilon: number;
  66684. /**
  66685. * Creates a new QuadraticErrorSimplification
  66686. * @param _mesh defines the target mesh
  66687. */
  66688. constructor(_mesh: Mesh);
  66689. /**
  66690. * Simplification of a given mesh according to the given settings.
  66691. * Since this requires computation, it is assumed that the function runs async.
  66692. * @param settings The settings of the simplification, including quality and distance
  66693. * @param successCallback A callback that will be called after the mesh was simplified.
  66694. */
  66695. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66696. private runDecimation;
  66697. private initWithMesh;
  66698. private init;
  66699. private reconstructMesh;
  66700. private initDecimatedMesh;
  66701. private isFlipped;
  66702. private updateTriangles;
  66703. private identifyBorder;
  66704. private updateMesh;
  66705. private vertexError;
  66706. private calculateError;
  66707. }
  66708. }
  66709. declare module BABYLON {
  66710. interface Scene {
  66711. /** @hidden (Backing field) */
  66712. _simplificationQueue: SimplificationQueue;
  66713. /**
  66714. * Gets or sets the simplification queue attached to the scene
  66715. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66716. */
  66717. simplificationQueue: SimplificationQueue;
  66718. }
  66719. interface Mesh {
  66720. /**
  66721. * Simplify the mesh according to the given array of settings.
  66722. * Function will return immediately and will simplify async
  66723. * @param settings a collection of simplification settings
  66724. * @param parallelProcessing should all levels calculate parallel or one after the other
  66725. * @param simplificationType the type of simplification to run
  66726. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66727. * @returns the current mesh
  66728. */
  66729. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66730. }
  66731. /**
  66732. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66733. * created in a scene
  66734. */
  66735. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66736. /**
  66737. * The component name helpfull to identify the component in the list of scene components.
  66738. */
  66739. readonly name: string;
  66740. /**
  66741. * The scene the component belongs to.
  66742. */
  66743. scene: Scene;
  66744. /**
  66745. * Creates a new instance of the component for the given scene
  66746. * @param scene Defines the scene to register the component in
  66747. */
  66748. constructor(scene: Scene);
  66749. /**
  66750. * Registers the component in a given scene
  66751. */
  66752. register(): void;
  66753. /**
  66754. * Rebuilds the elements related to this component in case of
  66755. * context lost for instance.
  66756. */
  66757. rebuild(): void;
  66758. /**
  66759. * Disposes the component and the associated ressources
  66760. */
  66761. dispose(): void;
  66762. private _beforeCameraUpdate;
  66763. }
  66764. }
  66765. declare module BABYLON {
  66766. interface Mesh {
  66767. /**
  66768. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66769. */
  66770. thinInstanceEnablePicking: boolean;
  66771. /**
  66772. * Creates a new thin instance
  66773. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66774. * @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
  66775. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66776. */
  66777. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66778. /**
  66779. * Adds the transformation (matrix) of the current mesh as a thin instance
  66780. * @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
  66781. * @returns the thin instance index number
  66782. */
  66783. thinInstanceAddSelf(refresh: boolean): number;
  66784. /**
  66785. * Registers a custom attribute to be used with thin instances
  66786. * @param kind name of the attribute
  66787. * @param stride size in floats of the attribute
  66788. */
  66789. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66790. /**
  66791. * Sets the matrix of a thin instance
  66792. * @param index index of the thin instance
  66793. * @param matrix matrix to set
  66794. * @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
  66795. */
  66796. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66797. /**
  66798. * Sets the value of a custom attribute for a thin instance
  66799. * @param kind name of the attribute
  66800. * @param index index of the thin instance
  66801. * @param value value to set
  66802. * @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
  66803. */
  66804. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66805. /**
  66806. * 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.
  66807. */
  66808. thinInstanceCount: number;
  66809. /**
  66810. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66811. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66812. * @param buffer buffer to set
  66813. * @param stride size in floats of each value of the buffer
  66814. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66815. */
  66816. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66817. /**
  66818. * Gets the list of world matrices
  66819. * @return an array containing all the world matrices from the thin instances
  66820. */
  66821. thinInstanceGetWorldMatrices(): Matrix[];
  66822. /**
  66823. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66824. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66825. */
  66826. thinInstanceBufferUpdated(kind: string): void;
  66827. /**
  66828. * Applies a partial update to a buffer directly on the GPU
  66829. * 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
  66830. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66831. * @param data the data to set in the GPU buffer
  66832. * @param offset the offset in the GPU buffer where to update the data
  66833. */
  66834. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  66835. /**
  66836. * Refreshes the bounding info, taking into account all the thin instances defined
  66837. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66838. */
  66839. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66840. /** @hidden */
  66841. _thinInstanceInitializeUserStorage(): void;
  66842. /** @hidden */
  66843. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66844. /** @hidden */
  66845. _userThinInstanceBuffersStorage: {
  66846. data: {
  66847. [key: string]: Float32Array;
  66848. };
  66849. sizes: {
  66850. [key: string]: number;
  66851. };
  66852. vertexBuffers: {
  66853. [key: string]: Nullable<VertexBuffer>;
  66854. };
  66855. strides: {
  66856. [key: string]: number;
  66857. };
  66858. };
  66859. }
  66860. }
  66861. declare module BABYLON {
  66862. /**
  66863. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66864. */
  66865. export interface INavigationEnginePlugin {
  66866. /**
  66867. * plugin name
  66868. */
  66869. name: string;
  66870. /**
  66871. * Creates a navigation mesh
  66872. * @param meshes array of all the geometry used to compute the navigatio mesh
  66873. * @param parameters bunch of parameters used to filter geometry
  66874. */
  66875. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66876. /**
  66877. * Create a navigation mesh debug mesh
  66878. * @param scene is where the mesh will be added
  66879. * @returns debug display mesh
  66880. */
  66881. createDebugNavMesh(scene: Scene): Mesh;
  66882. /**
  66883. * Get a navigation mesh constrained position, closest to the parameter position
  66884. * @param position world position
  66885. * @returns the closest point to position constrained by the navigation mesh
  66886. */
  66887. getClosestPoint(position: Vector3): Vector3;
  66888. /**
  66889. * Get a navigation mesh constrained position, closest to the parameter position
  66890. * @param position world position
  66891. * @param result output the closest point to position constrained by the navigation mesh
  66892. */
  66893. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66894. /**
  66895. * Get a navigation mesh constrained position, within a particular radius
  66896. * @param position world position
  66897. * @param maxRadius the maximum distance to the constrained world position
  66898. * @returns the closest point to position constrained by the navigation mesh
  66899. */
  66900. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66901. /**
  66902. * Get a navigation mesh constrained position, within a particular radius
  66903. * @param position world position
  66904. * @param maxRadius the maximum distance to the constrained world position
  66905. * @param result output the closest point to position constrained by the navigation mesh
  66906. */
  66907. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66908. /**
  66909. * Compute the final position from a segment made of destination-position
  66910. * @param position world position
  66911. * @param destination world position
  66912. * @returns the resulting point along the navmesh
  66913. */
  66914. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66915. /**
  66916. * Compute the final position from a segment made of destination-position
  66917. * @param position world position
  66918. * @param destination world position
  66919. * @param result output the resulting point along the navmesh
  66920. */
  66921. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66922. /**
  66923. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66924. * @param start world position
  66925. * @param end world position
  66926. * @returns array containing world position composing the path
  66927. */
  66928. computePath(start: Vector3, end: Vector3): Vector3[];
  66929. /**
  66930. * If this plugin is supported
  66931. * @returns true if plugin is supported
  66932. */
  66933. isSupported(): boolean;
  66934. /**
  66935. * Create a new Crowd so you can add agents
  66936. * @param maxAgents the maximum agent count in the crowd
  66937. * @param maxAgentRadius the maximum radius an agent can have
  66938. * @param scene to attach the crowd to
  66939. * @returns the crowd you can add agents to
  66940. */
  66941. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66942. /**
  66943. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66944. * The queries will try to find a solution within those bounds
  66945. * default is (1,1,1)
  66946. * @param extent x,y,z value that define the extent around the queries point of reference
  66947. */
  66948. setDefaultQueryExtent(extent: Vector3): void;
  66949. /**
  66950. * Get the Bounding box extent specified by setDefaultQueryExtent
  66951. * @returns the box extent values
  66952. */
  66953. getDefaultQueryExtent(): Vector3;
  66954. /**
  66955. * build the navmesh from a previously saved state using getNavmeshData
  66956. * @param data the Uint8Array returned by getNavmeshData
  66957. */
  66958. buildFromNavmeshData(data: Uint8Array): void;
  66959. /**
  66960. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66961. * @returns data the Uint8Array that can be saved and reused
  66962. */
  66963. getNavmeshData(): Uint8Array;
  66964. /**
  66965. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66966. * @param result output the box extent values
  66967. */
  66968. getDefaultQueryExtentToRef(result: Vector3): void;
  66969. /**
  66970. * Release all resources
  66971. */
  66972. dispose(): void;
  66973. }
  66974. /**
  66975. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66976. */
  66977. export interface ICrowd {
  66978. /**
  66979. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66980. * You can attach anything to that node. The node position is updated in the scene update tick.
  66981. * @param pos world position that will be constrained by the navigation mesh
  66982. * @param parameters agent parameters
  66983. * @param transform hooked to the agent that will be update by the scene
  66984. * @returns agent index
  66985. */
  66986. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66987. /**
  66988. * Returns the agent position in world space
  66989. * @param index agent index returned by addAgent
  66990. * @returns world space position
  66991. */
  66992. getAgentPosition(index: number): Vector3;
  66993. /**
  66994. * Gets the agent position result in world space
  66995. * @param index agent index returned by addAgent
  66996. * @param result output world space position
  66997. */
  66998. getAgentPositionToRef(index: number, result: Vector3): void;
  66999. /**
  67000. * Gets the agent velocity in world space
  67001. * @param index agent index returned by addAgent
  67002. * @returns world space velocity
  67003. */
  67004. getAgentVelocity(index: number): Vector3;
  67005. /**
  67006. * Gets the agent velocity result in world space
  67007. * @param index agent index returned by addAgent
  67008. * @param result output world space velocity
  67009. */
  67010. getAgentVelocityToRef(index: number, result: Vector3): void;
  67011. /**
  67012. * remove a particular agent previously created
  67013. * @param index agent index returned by addAgent
  67014. */
  67015. removeAgent(index: number): void;
  67016. /**
  67017. * get the list of all agents attached to this crowd
  67018. * @returns list of agent indices
  67019. */
  67020. getAgents(): number[];
  67021. /**
  67022. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67023. * @param deltaTime in seconds
  67024. */
  67025. update(deltaTime: number): void;
  67026. /**
  67027. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67028. * @param index agent index returned by addAgent
  67029. * @param destination targeted world position
  67030. */
  67031. agentGoto(index: number, destination: Vector3): void;
  67032. /**
  67033. * Teleport the agent to a new position
  67034. * @param index agent index returned by addAgent
  67035. * @param destination targeted world position
  67036. */
  67037. agentTeleport(index: number, destination: Vector3): void;
  67038. /**
  67039. * Update agent parameters
  67040. * @param index agent index returned by addAgent
  67041. * @param parameters agent parameters
  67042. */
  67043. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67044. /**
  67045. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67046. * The queries will try to find a solution within those bounds
  67047. * default is (1,1,1)
  67048. * @param extent x,y,z value that define the extent around the queries point of reference
  67049. */
  67050. setDefaultQueryExtent(extent: Vector3): void;
  67051. /**
  67052. * Get the Bounding box extent specified by setDefaultQueryExtent
  67053. * @returns the box extent values
  67054. */
  67055. getDefaultQueryExtent(): Vector3;
  67056. /**
  67057. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67058. * @param result output the box extent values
  67059. */
  67060. getDefaultQueryExtentToRef(result: Vector3): void;
  67061. /**
  67062. * Release all resources
  67063. */
  67064. dispose(): void;
  67065. }
  67066. /**
  67067. * Configures an agent
  67068. */
  67069. export interface IAgentParameters {
  67070. /**
  67071. * Agent radius. [Limit: >= 0]
  67072. */
  67073. radius: number;
  67074. /**
  67075. * Agent height. [Limit: > 0]
  67076. */
  67077. height: number;
  67078. /**
  67079. * Maximum allowed acceleration. [Limit: >= 0]
  67080. */
  67081. maxAcceleration: number;
  67082. /**
  67083. * Maximum allowed speed. [Limit: >= 0]
  67084. */
  67085. maxSpeed: number;
  67086. /**
  67087. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67088. */
  67089. collisionQueryRange: number;
  67090. /**
  67091. * The path visibility optimization range. [Limit: > 0]
  67092. */
  67093. pathOptimizationRange: number;
  67094. /**
  67095. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67096. */
  67097. separationWeight: number;
  67098. }
  67099. /**
  67100. * Configures the navigation mesh creation
  67101. */
  67102. export interface INavMeshParameters {
  67103. /**
  67104. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67105. */
  67106. cs: number;
  67107. /**
  67108. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67109. */
  67110. ch: number;
  67111. /**
  67112. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67113. */
  67114. walkableSlopeAngle: number;
  67115. /**
  67116. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67117. * be considered walkable. [Limit: >= 3] [Units: vx]
  67118. */
  67119. walkableHeight: number;
  67120. /**
  67121. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67122. */
  67123. walkableClimb: number;
  67124. /**
  67125. * The distance to erode/shrink the walkable area of the heightfield away from
  67126. * obstructions. [Limit: >=0] [Units: vx]
  67127. */
  67128. walkableRadius: number;
  67129. /**
  67130. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67131. */
  67132. maxEdgeLen: number;
  67133. /**
  67134. * The maximum distance a simplfied contour's border edges should deviate
  67135. * the original raw contour. [Limit: >=0] [Units: vx]
  67136. */
  67137. maxSimplificationError: number;
  67138. /**
  67139. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67140. */
  67141. minRegionArea: number;
  67142. /**
  67143. * Any regions with a span count smaller than this value will, if possible,
  67144. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67145. */
  67146. mergeRegionArea: number;
  67147. /**
  67148. * The maximum number of vertices allowed for polygons generated during the
  67149. * contour to polygon conversion process. [Limit: >= 3]
  67150. */
  67151. maxVertsPerPoly: number;
  67152. /**
  67153. * Sets the sampling distance to use when generating the detail mesh.
  67154. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67155. */
  67156. detailSampleDist: number;
  67157. /**
  67158. * The maximum distance the detail mesh surface should deviate from heightfield
  67159. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67160. */
  67161. detailSampleMaxError: number;
  67162. }
  67163. }
  67164. declare module BABYLON {
  67165. /**
  67166. * RecastJS navigation plugin
  67167. */
  67168. export class RecastJSPlugin implements INavigationEnginePlugin {
  67169. /**
  67170. * Reference to the Recast library
  67171. */
  67172. bjsRECAST: any;
  67173. /**
  67174. * plugin name
  67175. */
  67176. name: string;
  67177. /**
  67178. * the first navmesh created. We might extend this to support multiple navmeshes
  67179. */
  67180. navMesh: any;
  67181. /**
  67182. * Initializes the recastJS plugin
  67183. * @param recastInjection can be used to inject your own recast reference
  67184. */
  67185. constructor(recastInjection?: any);
  67186. /**
  67187. * Creates a navigation mesh
  67188. * @param meshes array of all the geometry used to compute the navigatio mesh
  67189. * @param parameters bunch of parameters used to filter geometry
  67190. */
  67191. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67192. /**
  67193. * Create a navigation mesh debug mesh
  67194. * @param scene is where the mesh will be added
  67195. * @returns debug display mesh
  67196. */
  67197. createDebugNavMesh(scene: Scene): Mesh;
  67198. /**
  67199. * Get a navigation mesh constrained position, closest to the parameter position
  67200. * @param position world position
  67201. * @returns the closest point to position constrained by the navigation mesh
  67202. */
  67203. getClosestPoint(position: Vector3): Vector3;
  67204. /**
  67205. * Get a navigation mesh constrained position, closest to the parameter position
  67206. * @param position world position
  67207. * @param result output the closest point to position constrained by the navigation mesh
  67208. */
  67209. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67210. /**
  67211. * Get a navigation mesh constrained position, within a particular radius
  67212. * @param position world position
  67213. * @param maxRadius the maximum distance to the constrained world position
  67214. * @returns the closest point to position constrained by the navigation mesh
  67215. */
  67216. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67217. /**
  67218. * Get a navigation mesh constrained position, within a particular radius
  67219. * @param position world position
  67220. * @param maxRadius the maximum distance to the constrained world position
  67221. * @param result output the closest point to position constrained by the navigation mesh
  67222. */
  67223. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67224. /**
  67225. * Compute the final position from a segment made of destination-position
  67226. * @param position world position
  67227. * @param destination world position
  67228. * @returns the resulting point along the navmesh
  67229. */
  67230. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67231. /**
  67232. * Compute the final position from a segment made of destination-position
  67233. * @param position world position
  67234. * @param destination world position
  67235. * @param result output the resulting point along the navmesh
  67236. */
  67237. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67238. /**
  67239. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67240. * @param start world position
  67241. * @param end world position
  67242. * @returns array containing world position composing the path
  67243. */
  67244. computePath(start: Vector3, end: Vector3): Vector3[];
  67245. /**
  67246. * Create a new Crowd so you can add agents
  67247. * @param maxAgents the maximum agent count in the crowd
  67248. * @param maxAgentRadius the maximum radius an agent can have
  67249. * @param scene to attach the crowd to
  67250. * @returns the crowd you can add agents to
  67251. */
  67252. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67253. /**
  67254. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67255. * The queries will try to find a solution within those bounds
  67256. * default is (1,1,1)
  67257. * @param extent x,y,z value that define the extent around the queries point of reference
  67258. */
  67259. setDefaultQueryExtent(extent: Vector3): void;
  67260. /**
  67261. * Get the Bounding box extent specified by setDefaultQueryExtent
  67262. * @returns the box extent values
  67263. */
  67264. getDefaultQueryExtent(): Vector3;
  67265. /**
  67266. * build the navmesh from a previously saved state using getNavmeshData
  67267. * @param data the Uint8Array returned by getNavmeshData
  67268. */
  67269. buildFromNavmeshData(data: Uint8Array): void;
  67270. /**
  67271. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67272. * @returns data the Uint8Array that can be saved and reused
  67273. */
  67274. getNavmeshData(): Uint8Array;
  67275. /**
  67276. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67277. * @param result output the box extent values
  67278. */
  67279. getDefaultQueryExtentToRef(result: Vector3): void;
  67280. /**
  67281. * Disposes
  67282. */
  67283. dispose(): void;
  67284. /**
  67285. * If this plugin is supported
  67286. * @returns true if plugin is supported
  67287. */
  67288. isSupported(): boolean;
  67289. }
  67290. /**
  67291. * Recast detour crowd implementation
  67292. */
  67293. export class RecastJSCrowd implements ICrowd {
  67294. /**
  67295. * Recast/detour plugin
  67296. */
  67297. bjsRECASTPlugin: RecastJSPlugin;
  67298. /**
  67299. * Link to the detour crowd
  67300. */
  67301. recastCrowd: any;
  67302. /**
  67303. * One transform per agent
  67304. */
  67305. transforms: TransformNode[];
  67306. /**
  67307. * All agents created
  67308. */
  67309. agents: number[];
  67310. /**
  67311. * Link to the scene is kept to unregister the crowd from the scene
  67312. */
  67313. private _scene;
  67314. /**
  67315. * Observer for crowd updates
  67316. */
  67317. private _onBeforeAnimationsObserver;
  67318. /**
  67319. * Constructor
  67320. * @param plugin recastJS plugin
  67321. * @param maxAgents the maximum agent count in the crowd
  67322. * @param maxAgentRadius the maximum radius an agent can have
  67323. * @param scene to attach the crowd to
  67324. * @returns the crowd you can add agents to
  67325. */
  67326. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67327. /**
  67328. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67329. * You can attach anything to that node. The node position is updated in the scene update tick.
  67330. * @param pos world position that will be constrained by the navigation mesh
  67331. * @param parameters agent parameters
  67332. * @param transform hooked to the agent that will be update by the scene
  67333. * @returns agent index
  67334. */
  67335. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67336. /**
  67337. * Returns the agent position in world space
  67338. * @param index agent index returned by addAgent
  67339. * @returns world space position
  67340. */
  67341. getAgentPosition(index: number): Vector3;
  67342. /**
  67343. * Returns the agent position result in world space
  67344. * @param index agent index returned by addAgent
  67345. * @param result output world space position
  67346. */
  67347. getAgentPositionToRef(index: number, result: Vector3): void;
  67348. /**
  67349. * Returns the agent velocity in world space
  67350. * @param index agent index returned by addAgent
  67351. * @returns world space velocity
  67352. */
  67353. getAgentVelocity(index: number): Vector3;
  67354. /**
  67355. * Returns the agent velocity result in world space
  67356. * @param index agent index returned by addAgent
  67357. * @param result output world space velocity
  67358. */
  67359. getAgentVelocityToRef(index: number, result: Vector3): void;
  67360. /**
  67361. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67362. * @param index agent index returned by addAgent
  67363. * @param destination targeted world position
  67364. */
  67365. agentGoto(index: number, destination: Vector3): void;
  67366. /**
  67367. * Teleport the agent to a new position
  67368. * @param index agent index returned by addAgent
  67369. * @param destination targeted world position
  67370. */
  67371. agentTeleport(index: number, destination: Vector3): void;
  67372. /**
  67373. * Update agent parameters
  67374. * @param index agent index returned by addAgent
  67375. * @param parameters agent parameters
  67376. */
  67377. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67378. /**
  67379. * remove a particular agent previously created
  67380. * @param index agent index returned by addAgent
  67381. */
  67382. removeAgent(index: number): void;
  67383. /**
  67384. * get the list of all agents attached to this crowd
  67385. * @returns list of agent indices
  67386. */
  67387. getAgents(): number[];
  67388. /**
  67389. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67390. * @param deltaTime in seconds
  67391. */
  67392. update(deltaTime: number): void;
  67393. /**
  67394. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67395. * The queries will try to find a solution within those bounds
  67396. * default is (1,1,1)
  67397. * @param extent x,y,z value that define the extent around the queries point of reference
  67398. */
  67399. setDefaultQueryExtent(extent: Vector3): void;
  67400. /**
  67401. * Get the Bounding box extent specified by setDefaultQueryExtent
  67402. * @returns the box extent values
  67403. */
  67404. getDefaultQueryExtent(): Vector3;
  67405. /**
  67406. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67407. * @param result output the box extent values
  67408. */
  67409. getDefaultQueryExtentToRef(result: Vector3): void;
  67410. /**
  67411. * Release all resources
  67412. */
  67413. dispose(): void;
  67414. }
  67415. }
  67416. declare module BABYLON {
  67417. /**
  67418. * Class used to enable access to IndexedDB
  67419. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67420. */
  67421. export class Database implements IOfflineProvider {
  67422. private _callbackManifestChecked;
  67423. private _currentSceneUrl;
  67424. private _db;
  67425. private _enableSceneOffline;
  67426. private _enableTexturesOffline;
  67427. private _manifestVersionFound;
  67428. private _mustUpdateRessources;
  67429. private _hasReachedQuota;
  67430. private _isSupported;
  67431. private _idbFactory;
  67432. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67433. private static IsUASupportingBlobStorage;
  67434. /**
  67435. * Gets a boolean indicating if Database storate is enabled (off by default)
  67436. */
  67437. static IDBStorageEnabled: boolean;
  67438. /**
  67439. * Gets a boolean indicating if scene must be saved in the database
  67440. */
  67441. get enableSceneOffline(): boolean;
  67442. /**
  67443. * Gets a boolean indicating if textures must be saved in the database
  67444. */
  67445. get enableTexturesOffline(): boolean;
  67446. /**
  67447. * Creates a new Database
  67448. * @param urlToScene defines the url to load the scene
  67449. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67450. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67451. */
  67452. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67453. private static _ParseURL;
  67454. private static _ReturnFullUrlLocation;
  67455. private _checkManifestFile;
  67456. /**
  67457. * Open the database and make it available
  67458. * @param successCallback defines the callback to call on success
  67459. * @param errorCallback defines the callback to call on error
  67460. */
  67461. open(successCallback: () => void, errorCallback: () => void): void;
  67462. /**
  67463. * Loads an image from the database
  67464. * @param url defines the url to load from
  67465. * @param image defines the target DOM image
  67466. */
  67467. loadImage(url: string, image: HTMLImageElement): void;
  67468. private _loadImageFromDBAsync;
  67469. private _saveImageIntoDBAsync;
  67470. private _checkVersionFromDB;
  67471. private _loadVersionFromDBAsync;
  67472. private _saveVersionIntoDBAsync;
  67473. /**
  67474. * Loads a file from database
  67475. * @param url defines the URL to load from
  67476. * @param sceneLoaded defines a callback to call on success
  67477. * @param progressCallBack defines a callback to call when progress changed
  67478. * @param errorCallback defines a callback to call on error
  67479. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67480. */
  67481. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67482. private _loadFileAsync;
  67483. private _saveFileAsync;
  67484. /**
  67485. * Validates if xhr data is correct
  67486. * @param xhr defines the request to validate
  67487. * @param dataType defines the expected data type
  67488. * @returns true if data is correct
  67489. */
  67490. private static _ValidateXHRData;
  67491. }
  67492. }
  67493. declare module BABYLON {
  67494. /** @hidden */
  67495. export var gpuUpdateParticlesPixelShader: {
  67496. name: string;
  67497. shader: string;
  67498. };
  67499. }
  67500. declare module BABYLON {
  67501. /** @hidden */
  67502. export var gpuUpdateParticlesVertexShader: {
  67503. name: string;
  67504. shader: string;
  67505. };
  67506. }
  67507. declare module BABYLON {
  67508. /** @hidden */
  67509. export var clipPlaneFragmentDeclaration2: {
  67510. name: string;
  67511. shader: string;
  67512. };
  67513. }
  67514. declare module BABYLON {
  67515. /** @hidden */
  67516. export var gpuRenderParticlesPixelShader: {
  67517. name: string;
  67518. shader: string;
  67519. };
  67520. }
  67521. declare module BABYLON {
  67522. /** @hidden */
  67523. export var clipPlaneVertexDeclaration2: {
  67524. name: string;
  67525. shader: string;
  67526. };
  67527. }
  67528. declare module BABYLON {
  67529. /** @hidden */
  67530. export var gpuRenderParticlesVertexShader: {
  67531. name: string;
  67532. shader: string;
  67533. };
  67534. }
  67535. declare module BABYLON {
  67536. /**
  67537. * This represents a GPU particle system in Babylon
  67538. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67539. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67540. */
  67541. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67542. /**
  67543. * The layer mask we are rendering the particles through.
  67544. */
  67545. layerMask: number;
  67546. private _capacity;
  67547. private _activeCount;
  67548. private _currentActiveCount;
  67549. private _accumulatedCount;
  67550. private _renderEffect;
  67551. private _updateEffect;
  67552. private _buffer0;
  67553. private _buffer1;
  67554. private _spriteBuffer;
  67555. private _updateVAO;
  67556. private _renderVAO;
  67557. private _targetIndex;
  67558. private _sourceBuffer;
  67559. private _targetBuffer;
  67560. private _currentRenderId;
  67561. private _started;
  67562. private _stopped;
  67563. private _timeDelta;
  67564. private _randomTexture;
  67565. private _randomTexture2;
  67566. private _attributesStrideSize;
  67567. private _updateEffectOptions;
  67568. private _randomTextureSize;
  67569. private _actualFrame;
  67570. private _customEffect;
  67571. private readonly _rawTextureWidth;
  67572. /**
  67573. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67574. */
  67575. static get IsSupported(): boolean;
  67576. /**
  67577. * An event triggered when the system is disposed.
  67578. */
  67579. onDisposeObservable: Observable<IParticleSystem>;
  67580. /**
  67581. * Gets the maximum number of particles active at the same time.
  67582. * @returns The max number of active particles.
  67583. */
  67584. getCapacity(): number;
  67585. /**
  67586. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67587. * to override the particles.
  67588. */
  67589. forceDepthWrite: boolean;
  67590. /**
  67591. * Gets or set the number of active particles
  67592. */
  67593. get activeParticleCount(): number;
  67594. set activeParticleCount(value: number);
  67595. private _preWarmDone;
  67596. /**
  67597. * Specifies if the particles are updated in emitter local space or world space.
  67598. */
  67599. isLocal: boolean;
  67600. /** Gets or sets a matrix to use to compute projection */
  67601. defaultProjectionMatrix: Matrix;
  67602. /**
  67603. * Is this system ready to be used/rendered
  67604. * @return true if the system is ready
  67605. */
  67606. isReady(): boolean;
  67607. /**
  67608. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67609. * @returns True if it has been started, otherwise false.
  67610. */
  67611. isStarted(): boolean;
  67612. /**
  67613. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67614. * @returns True if it has been stopped, otherwise false.
  67615. */
  67616. isStopped(): boolean;
  67617. /**
  67618. * Gets a boolean indicating that the system is stopping
  67619. * @returns true if the system is currently stopping
  67620. */
  67621. isStopping(): boolean;
  67622. /**
  67623. * Gets the number of particles active at the same time.
  67624. * @returns The number of active particles.
  67625. */
  67626. getActiveCount(): number;
  67627. /**
  67628. * Starts the particle system and begins to emit
  67629. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67630. */
  67631. start(delay?: number): void;
  67632. /**
  67633. * Stops the particle system.
  67634. */
  67635. stop(): void;
  67636. /**
  67637. * Remove all active particles
  67638. */
  67639. reset(): void;
  67640. /**
  67641. * Returns the string "GPUParticleSystem"
  67642. * @returns a string containing the class name
  67643. */
  67644. getClassName(): string;
  67645. /**
  67646. * Gets the custom effect used to render the particles
  67647. * @param blendMode Blend mode for which the effect should be retrieved
  67648. * @returns The effect
  67649. */
  67650. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67651. /**
  67652. * Sets the custom effect used to render the particles
  67653. * @param effect The effect to set
  67654. * @param blendMode Blend mode for which the effect should be set
  67655. */
  67656. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67657. /** @hidden */
  67658. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67659. /**
  67660. * Observable that will be called just before the particles are drawn
  67661. */
  67662. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67663. /**
  67664. * Gets the name of the particle vertex shader
  67665. */
  67666. get vertexShaderName(): string;
  67667. private _colorGradientsTexture;
  67668. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67669. /**
  67670. * Adds a new color gradient
  67671. * @param gradient defines the gradient to use (between 0 and 1)
  67672. * @param color1 defines the color to affect to the specified gradient
  67673. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67674. * @returns the current particle system
  67675. */
  67676. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67677. private _refreshColorGradient;
  67678. /** Force the system to rebuild all gradients that need to be resync */
  67679. forceRefreshGradients(): void;
  67680. /**
  67681. * Remove a specific color gradient
  67682. * @param gradient defines the gradient to remove
  67683. * @returns the current particle system
  67684. */
  67685. removeColorGradient(gradient: number): GPUParticleSystem;
  67686. private _angularSpeedGradientsTexture;
  67687. private _sizeGradientsTexture;
  67688. private _velocityGradientsTexture;
  67689. private _limitVelocityGradientsTexture;
  67690. private _dragGradientsTexture;
  67691. private _addFactorGradient;
  67692. /**
  67693. * Adds a new size gradient
  67694. * @param gradient defines the gradient to use (between 0 and 1)
  67695. * @param factor defines the size factor to affect to the specified gradient
  67696. * @returns the current particle system
  67697. */
  67698. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67699. /**
  67700. * Remove a specific size gradient
  67701. * @param gradient defines the gradient to remove
  67702. * @returns the current particle system
  67703. */
  67704. removeSizeGradient(gradient: number): GPUParticleSystem;
  67705. private _refreshFactorGradient;
  67706. /**
  67707. * Adds a new angular speed gradient
  67708. * @param gradient defines the gradient to use (between 0 and 1)
  67709. * @param factor defines the angular speed to affect to the specified gradient
  67710. * @returns the current particle system
  67711. */
  67712. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67713. /**
  67714. * Remove a specific angular speed gradient
  67715. * @param gradient defines the gradient to remove
  67716. * @returns the current particle system
  67717. */
  67718. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67719. /**
  67720. * Adds a new velocity gradient
  67721. * @param gradient defines the gradient to use (between 0 and 1)
  67722. * @param factor defines the velocity to affect to the specified gradient
  67723. * @returns the current particle system
  67724. */
  67725. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67726. /**
  67727. * Remove a specific velocity gradient
  67728. * @param gradient defines the gradient to remove
  67729. * @returns the current particle system
  67730. */
  67731. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67732. /**
  67733. * Adds a new limit velocity gradient
  67734. * @param gradient defines the gradient to use (between 0 and 1)
  67735. * @param factor defines the limit velocity value to affect to the specified gradient
  67736. * @returns the current particle system
  67737. */
  67738. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67739. /**
  67740. * Remove a specific limit velocity gradient
  67741. * @param gradient defines the gradient to remove
  67742. * @returns the current particle system
  67743. */
  67744. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67745. /**
  67746. * Adds a new drag gradient
  67747. * @param gradient defines the gradient to use (between 0 and 1)
  67748. * @param factor defines the drag value to affect to the specified gradient
  67749. * @returns the current particle system
  67750. */
  67751. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67752. /**
  67753. * Remove a specific drag gradient
  67754. * @param gradient defines the gradient to remove
  67755. * @returns the current particle system
  67756. */
  67757. removeDragGradient(gradient: number): GPUParticleSystem;
  67758. /**
  67759. * Not supported by GPUParticleSystem
  67760. * @param gradient defines the gradient to use (between 0 and 1)
  67761. * @param factor defines the emit rate value to affect to the specified gradient
  67762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67763. * @returns the current particle system
  67764. */
  67765. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67766. /**
  67767. * Not supported by GPUParticleSystem
  67768. * @param gradient defines the gradient to remove
  67769. * @returns the current particle system
  67770. */
  67771. removeEmitRateGradient(gradient: number): IParticleSystem;
  67772. /**
  67773. * Not supported by GPUParticleSystem
  67774. * @param gradient defines the gradient to use (between 0 and 1)
  67775. * @param factor defines the start size value to affect to the specified gradient
  67776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67777. * @returns the current particle system
  67778. */
  67779. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67780. /**
  67781. * Not supported by GPUParticleSystem
  67782. * @param gradient defines the gradient to remove
  67783. * @returns the current particle system
  67784. */
  67785. removeStartSizeGradient(gradient: number): IParticleSystem;
  67786. /**
  67787. * Not supported by GPUParticleSystem
  67788. * @param gradient defines the gradient to use (between 0 and 1)
  67789. * @param min defines the color remap minimal range
  67790. * @param max defines the color remap maximal range
  67791. * @returns the current particle system
  67792. */
  67793. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67794. /**
  67795. * Not supported by GPUParticleSystem
  67796. * @param gradient defines the gradient to remove
  67797. * @returns the current particle system
  67798. */
  67799. removeColorRemapGradient(): IParticleSystem;
  67800. /**
  67801. * Not supported by GPUParticleSystem
  67802. * @param gradient defines the gradient to use (between 0 and 1)
  67803. * @param min defines the alpha remap minimal range
  67804. * @param max defines the alpha remap maximal range
  67805. * @returns the current particle system
  67806. */
  67807. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67808. /**
  67809. * Not supported by GPUParticleSystem
  67810. * @param gradient defines the gradient to remove
  67811. * @returns the current particle system
  67812. */
  67813. removeAlphaRemapGradient(): IParticleSystem;
  67814. /**
  67815. * Not supported by GPUParticleSystem
  67816. * @param gradient defines the gradient to use (between 0 and 1)
  67817. * @param color defines the color to affect to the specified gradient
  67818. * @returns the current particle system
  67819. */
  67820. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67821. /**
  67822. * Not supported by GPUParticleSystem
  67823. * @param gradient defines the gradient to remove
  67824. * @returns the current particle system
  67825. */
  67826. removeRampGradient(): IParticleSystem;
  67827. /**
  67828. * Not supported by GPUParticleSystem
  67829. * @returns the list of ramp gradients
  67830. */
  67831. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67832. /**
  67833. * Not supported by GPUParticleSystem
  67834. * Gets or sets a boolean indicating that ramp gradients must be used
  67835. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67836. */
  67837. get useRampGradients(): boolean;
  67838. set useRampGradients(value: boolean);
  67839. /**
  67840. * Not supported by GPUParticleSystem
  67841. * @param gradient defines the gradient to use (between 0 and 1)
  67842. * @param factor defines the life time factor to affect to the specified gradient
  67843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67844. * @returns the current particle system
  67845. */
  67846. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67847. /**
  67848. * Not supported by GPUParticleSystem
  67849. * @param gradient defines the gradient to remove
  67850. * @returns the current particle system
  67851. */
  67852. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67853. /**
  67854. * Instantiates a GPU particle system.
  67855. * 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.
  67856. * @param name The name of the particle system
  67857. * @param options The options used to create the system
  67858. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67859. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67860. * @param customEffect a custom effect used to change the way particles are rendered by default
  67861. */
  67862. constructor(name: string, options: Partial<{
  67863. capacity: number;
  67864. randomTextureSize: number;
  67865. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67866. protected _reset(): void;
  67867. private _createUpdateVAO;
  67868. private _createRenderVAO;
  67869. private _initialize;
  67870. /** @hidden */
  67871. _recreateUpdateEffect(): void;
  67872. private _getEffect;
  67873. /**
  67874. * Fill the defines array according to the current settings of the particle system
  67875. * @param defines Array to be updated
  67876. * @param blendMode blend mode to take into account when updating the array
  67877. */
  67878. fillDefines(defines: Array<string>, blendMode?: number): void;
  67879. /**
  67880. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67881. * @param uniforms Uniforms array to fill
  67882. * @param attributes Attributes array to fill
  67883. * @param samplers Samplers array to fill
  67884. */
  67885. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67886. /** @hidden */
  67887. _recreateRenderEffect(): Effect;
  67888. /**
  67889. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67890. * @param preWarm defines if we are in the pre-warmimg phase
  67891. */
  67892. animate(preWarm?: boolean): void;
  67893. private _createFactorGradientTexture;
  67894. private _createSizeGradientTexture;
  67895. private _createAngularSpeedGradientTexture;
  67896. private _createVelocityGradientTexture;
  67897. private _createLimitVelocityGradientTexture;
  67898. private _createDragGradientTexture;
  67899. private _createColorGradientTexture;
  67900. /**
  67901. * Renders the particle system in its current state
  67902. * @param preWarm defines if the system should only update the particles but not render them
  67903. * @returns the current number of particles
  67904. */
  67905. render(preWarm?: boolean): number;
  67906. /**
  67907. * Rebuilds the particle system
  67908. */
  67909. rebuild(): void;
  67910. private _releaseBuffers;
  67911. private _releaseVAOs;
  67912. /**
  67913. * Disposes the particle system and free the associated resources
  67914. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67915. */
  67916. dispose(disposeTexture?: boolean): void;
  67917. /**
  67918. * Clones the particle system.
  67919. * @param name The name of the cloned object
  67920. * @param newEmitter The new emitter to use
  67921. * @returns the cloned particle system
  67922. */
  67923. clone(name: string, newEmitter: any): GPUParticleSystem;
  67924. /**
  67925. * Serializes the particle system to a JSON object
  67926. * @param serializeTexture defines if the texture must be serialized as well
  67927. * @returns the JSON object
  67928. */
  67929. serialize(serializeTexture?: boolean): any;
  67930. /**
  67931. * Parses a JSON object to create a GPU particle system.
  67932. * @param parsedParticleSystem The JSON object to parse
  67933. * @param sceneOrEngine The scene or the engine to create the particle system in
  67934. * @param rootUrl The root url to use to load external dependencies like texture
  67935. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67936. * @returns the parsed GPU particle system
  67937. */
  67938. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67939. }
  67940. }
  67941. declare module BABYLON {
  67942. /**
  67943. * Represents a set of particle systems working together to create a specific effect
  67944. */
  67945. export class ParticleSystemSet implements IDisposable {
  67946. /**
  67947. * Gets or sets base Assets URL
  67948. */
  67949. static BaseAssetsUrl: string;
  67950. private _emitterCreationOptions;
  67951. private _emitterNode;
  67952. /**
  67953. * Gets the particle system list
  67954. */
  67955. systems: IParticleSystem[];
  67956. /**
  67957. * Gets the emitter node used with this set
  67958. */
  67959. get emitterNode(): Nullable<TransformNode>;
  67960. /**
  67961. * Creates a new emitter mesh as a sphere
  67962. * @param options defines the options used to create the sphere
  67963. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67964. * @param scene defines the hosting scene
  67965. */
  67966. setEmitterAsSphere(options: {
  67967. diameter: number;
  67968. segments: number;
  67969. color: Color3;
  67970. }, renderingGroupId: number, scene: Scene): void;
  67971. /**
  67972. * Starts all particle systems of the set
  67973. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67974. */
  67975. start(emitter?: AbstractMesh): void;
  67976. /**
  67977. * Release all associated resources
  67978. */
  67979. dispose(): void;
  67980. /**
  67981. * Serialize the set into a JSON compatible object
  67982. * @param serializeTexture defines if the texture must be serialized as well
  67983. * @returns a JSON compatible representation of the set
  67984. */
  67985. serialize(serializeTexture?: boolean): any;
  67986. /**
  67987. * Parse a new ParticleSystemSet from a serialized source
  67988. * @param data defines a JSON compatible representation of the set
  67989. * @param scene defines the hosting scene
  67990. * @param gpu defines if we want GPU particles or CPU particles
  67991. * @returns a new ParticleSystemSet
  67992. */
  67993. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67994. }
  67995. }
  67996. declare module BABYLON {
  67997. /**
  67998. * This class is made for on one-liner static method to help creating particle system set.
  67999. */
  68000. export class ParticleHelper {
  68001. /**
  68002. * Gets or sets base Assets URL
  68003. */
  68004. static BaseAssetsUrl: string;
  68005. /** Define the Url to load snippets */
  68006. static SnippetUrl: string;
  68007. /**
  68008. * Create a default particle system that you can tweak
  68009. * @param emitter defines the emitter to use
  68010. * @param capacity defines the system capacity (default is 500 particles)
  68011. * @param scene defines the hosting scene
  68012. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68013. * @returns the new Particle system
  68014. */
  68015. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68016. /**
  68017. * This is the main static method (one-liner) of this helper to create different particle systems
  68018. * @param type This string represents the type to the particle system to create
  68019. * @param scene The scene where the particle system should live
  68020. * @param gpu If the system will use gpu
  68021. * @returns the ParticleSystemSet created
  68022. */
  68023. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68024. /**
  68025. * Static function used to export a particle system to a ParticleSystemSet variable.
  68026. * Please note that the emitter shape is not exported
  68027. * @param systems defines the particle systems to export
  68028. * @returns the created particle system set
  68029. */
  68030. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68031. /**
  68032. * Creates a particle system from a snippet saved in a remote file
  68033. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68034. * @param url defines the url to load from
  68035. * @param scene defines the hosting scene
  68036. * @param gpu If the system will use gpu
  68037. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68038. * @returns a promise that will resolve to the new particle system
  68039. */
  68040. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68041. /**
  68042. * Creates a particle system from a snippet saved by the particle system editor
  68043. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68044. * @param scene defines the hosting scene
  68045. * @param gpu If the system will use gpu
  68046. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68047. * @returns a promise that will resolve to the new particle system
  68048. */
  68049. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68050. }
  68051. }
  68052. declare module BABYLON {
  68053. interface Engine {
  68054. /**
  68055. * Create an effect to use with particle systems.
  68056. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68057. * the particle system for which you want to create a custom effect in the last parameter
  68058. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68059. * @param uniformsNames defines a list of attribute names
  68060. * @param samplers defines an array of string used to represent textures
  68061. * @param defines defines the string containing the defines to use to compile the shaders
  68062. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68063. * @param onCompiled defines a function to call when the effect creation is successful
  68064. * @param onError defines a function to call when the effect creation has failed
  68065. * @param particleSystem the particle system you want to create the effect for
  68066. * @returns the new Effect
  68067. */
  68068. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68069. }
  68070. interface Mesh {
  68071. /**
  68072. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68073. * @returns an array of IParticleSystem
  68074. */
  68075. getEmittedParticleSystems(): IParticleSystem[];
  68076. /**
  68077. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68078. * @returns an array of IParticleSystem
  68079. */
  68080. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68081. }
  68082. }
  68083. declare module BABYLON {
  68084. /** Defines the 4 color options */
  68085. export enum PointColor {
  68086. /** color value */
  68087. Color = 2,
  68088. /** uv value */
  68089. UV = 1,
  68090. /** random value */
  68091. Random = 0,
  68092. /** stated value */
  68093. Stated = 3
  68094. }
  68095. /**
  68096. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68097. * 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.
  68098. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68099. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68100. *
  68101. * Full documentation here : TO BE ENTERED
  68102. */
  68103. export class PointsCloudSystem implements IDisposable {
  68104. /**
  68105. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68106. * Example : var p = SPS.particles[i];
  68107. */
  68108. particles: CloudPoint[];
  68109. /**
  68110. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68111. */
  68112. nbParticles: number;
  68113. /**
  68114. * This a counter for your own usage. It's not set by any SPS functions.
  68115. */
  68116. counter: number;
  68117. /**
  68118. * The PCS name. This name is also given to the underlying mesh.
  68119. */
  68120. name: string;
  68121. /**
  68122. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68123. */
  68124. mesh: Mesh;
  68125. /**
  68126. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68127. * Please read :
  68128. */
  68129. vars: any;
  68130. /**
  68131. * @hidden
  68132. */
  68133. _size: number;
  68134. private _scene;
  68135. private _promises;
  68136. private _positions;
  68137. private _indices;
  68138. private _normals;
  68139. private _colors;
  68140. private _uvs;
  68141. private _indices32;
  68142. private _positions32;
  68143. private _colors32;
  68144. private _uvs32;
  68145. private _updatable;
  68146. private _isVisibilityBoxLocked;
  68147. private _alwaysVisible;
  68148. private _groups;
  68149. private _groupCounter;
  68150. private _computeParticleColor;
  68151. private _computeParticleTexture;
  68152. private _computeParticleRotation;
  68153. private _computeBoundingBox;
  68154. private _isReady;
  68155. /**
  68156. * Creates a PCS (Points Cloud System) object
  68157. * @param name (String) is the PCS name, this will be the underlying mesh name
  68158. * @param pointSize (number) is the size for each point
  68159. * @param scene (Scene) is the scene in which the PCS is added
  68160. * @param options defines the options of the PCS e.g.
  68161. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68162. */
  68163. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68164. updatable?: boolean;
  68165. });
  68166. /**
  68167. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68168. * If no points were added to the PCS, the returned mesh is just a single point.
  68169. * @returns a promise for the created mesh
  68170. */
  68171. buildMeshAsync(): Promise<Mesh>;
  68172. /**
  68173. * @hidden
  68174. */
  68175. private _buildMesh;
  68176. private _addParticle;
  68177. private _randomUnitVector;
  68178. private _getColorIndicesForCoord;
  68179. private _setPointsColorOrUV;
  68180. private _colorFromTexture;
  68181. private _calculateDensity;
  68182. /**
  68183. * Adds points to the PCS in random positions within a unit sphere
  68184. * @param nb (positive integer) the number of particles to be created from this model
  68185. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68186. * @returns the number of groups in the system
  68187. */
  68188. addPoints(nb: number, pointFunction?: any): number;
  68189. /**
  68190. * Adds points to the PCS from the surface of the model shape
  68191. * @param mesh is any Mesh object that will be used as a surface model for the points
  68192. * @param nb (positive integer) the number of particles to be created from this model
  68193. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68194. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68195. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68196. * @returns the number of groups in the system
  68197. */
  68198. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68199. /**
  68200. * Adds points to the PCS inside the model shape
  68201. * @param mesh is any Mesh object that will be used as a surface model for the points
  68202. * @param nb (positive integer) the number of particles to be created from this model
  68203. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68204. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68205. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68206. * @returns the number of groups in the system
  68207. */
  68208. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68209. /**
  68210. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68211. * This method calls `updateParticle()` for each particle of the SPS.
  68212. * For an animated SPS, it is usually called within the render loop.
  68213. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68214. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68215. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68216. * @returns the PCS.
  68217. */
  68218. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68219. /**
  68220. * Disposes the PCS.
  68221. */
  68222. dispose(): void;
  68223. /**
  68224. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68225. * doc :
  68226. * @returns the PCS.
  68227. */
  68228. refreshVisibleSize(): PointsCloudSystem;
  68229. /**
  68230. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68231. * @param size the size (float) of the visibility box
  68232. * note : this doesn't lock the PCS mesh bounding box.
  68233. * doc :
  68234. */
  68235. setVisibilityBox(size: number): void;
  68236. /**
  68237. * Gets whether the PCS is always visible or not
  68238. * doc :
  68239. */
  68240. get isAlwaysVisible(): boolean;
  68241. /**
  68242. * Sets the PCS as always visible or not
  68243. * doc :
  68244. */
  68245. set isAlwaysVisible(val: boolean);
  68246. /**
  68247. * Tells to `setParticles()` to compute the particle rotations or not
  68248. * Default value : false. The PCS is faster when it's set to false
  68249. * Note : particle rotations are only applied to parent particles
  68250. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68251. */
  68252. set computeParticleRotation(val: boolean);
  68253. /**
  68254. * Tells to `setParticles()` to compute the particle colors or not.
  68255. * Default value : true. The PCS is faster when it's set to false.
  68256. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68257. */
  68258. set computeParticleColor(val: boolean);
  68259. set computeParticleTexture(val: boolean);
  68260. /**
  68261. * Gets if `setParticles()` computes the particle colors or not.
  68262. * Default value : false. The PCS is faster when it's set to false.
  68263. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68264. */
  68265. get computeParticleColor(): boolean;
  68266. /**
  68267. * Gets if `setParticles()` computes the particle textures or not.
  68268. * Default value : false. The PCS is faster when it's set to false.
  68269. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68270. */
  68271. get computeParticleTexture(): boolean;
  68272. /**
  68273. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68274. */
  68275. set computeBoundingBox(val: boolean);
  68276. /**
  68277. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68278. */
  68279. get computeBoundingBox(): boolean;
  68280. /**
  68281. * This function does nothing. It may be overwritten to set all the particle first values.
  68282. * The PCS doesn't call this function, you may have to call it by your own.
  68283. * doc :
  68284. */
  68285. initParticles(): void;
  68286. /**
  68287. * This function does nothing. It may be overwritten to recycle a particle
  68288. * The PCS doesn't call this function, you can to call it
  68289. * doc :
  68290. * @param particle The particle to recycle
  68291. * @returns the recycled particle
  68292. */
  68293. recycleParticle(particle: CloudPoint): CloudPoint;
  68294. /**
  68295. * Updates a particle : this function should be overwritten by the user.
  68296. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68297. * doc :
  68298. * @example : just set a particle position or velocity and recycle conditions
  68299. * @param particle The particle to update
  68300. * @returns the updated particle
  68301. */
  68302. updateParticle(particle: CloudPoint): CloudPoint;
  68303. /**
  68304. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68305. * This does nothing and may be overwritten by the user.
  68306. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68307. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68308. * @param update the boolean update value actually passed to setParticles()
  68309. */
  68310. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68311. /**
  68312. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68313. * This will be passed three parameters.
  68314. * This does nothing and may be overwritten by the user.
  68315. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68316. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68317. * @param update the boolean update value actually passed to setParticles()
  68318. */
  68319. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68320. }
  68321. }
  68322. declare module BABYLON {
  68323. /**
  68324. * Represents one particle of a points cloud system.
  68325. */
  68326. export class CloudPoint {
  68327. /**
  68328. * particle global index
  68329. */
  68330. idx: number;
  68331. /**
  68332. * The color of the particle
  68333. */
  68334. color: Nullable<Color4>;
  68335. /**
  68336. * The world space position of the particle.
  68337. */
  68338. position: Vector3;
  68339. /**
  68340. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68341. */
  68342. rotation: Vector3;
  68343. /**
  68344. * The world space rotation quaternion of the particle.
  68345. */
  68346. rotationQuaternion: Nullable<Quaternion>;
  68347. /**
  68348. * The uv of the particle.
  68349. */
  68350. uv: Nullable<Vector2>;
  68351. /**
  68352. * The current speed of the particle.
  68353. */
  68354. velocity: Vector3;
  68355. /**
  68356. * The pivot point in the particle local space.
  68357. */
  68358. pivot: Vector3;
  68359. /**
  68360. * Must the particle be translated from its pivot point in its local space ?
  68361. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68362. * Default : false
  68363. */
  68364. translateFromPivot: boolean;
  68365. /**
  68366. * Index of this particle in the global "positions" array (Internal use)
  68367. * @hidden
  68368. */
  68369. _pos: number;
  68370. /**
  68371. * @hidden Index of this particle in the global "indices" array (Internal use)
  68372. */
  68373. _ind: number;
  68374. /**
  68375. * Group this particle belongs to
  68376. */
  68377. _group: PointsGroup;
  68378. /**
  68379. * Group id of this particle
  68380. */
  68381. groupId: number;
  68382. /**
  68383. * Index of the particle in its group id (Internal use)
  68384. */
  68385. idxInGroup: number;
  68386. /**
  68387. * @hidden Particle BoundingInfo object (Internal use)
  68388. */
  68389. _boundingInfo: BoundingInfo;
  68390. /**
  68391. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68392. */
  68393. _pcs: PointsCloudSystem;
  68394. /**
  68395. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68396. */
  68397. _stillInvisible: boolean;
  68398. /**
  68399. * @hidden Last computed particle rotation matrix
  68400. */
  68401. _rotationMatrix: number[];
  68402. /**
  68403. * Parent particle Id, if any.
  68404. * Default null.
  68405. */
  68406. parentId: Nullable<number>;
  68407. /**
  68408. * @hidden Internal global position in the PCS.
  68409. */
  68410. _globalPosition: Vector3;
  68411. /**
  68412. * Creates a Point Cloud object.
  68413. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68414. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68415. * @param group (PointsGroup) is the group the particle belongs to
  68416. * @param groupId (integer) is the group identifier in the PCS.
  68417. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68418. * @param pcs defines the PCS it is associated to
  68419. */
  68420. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68421. /**
  68422. * get point size
  68423. */
  68424. get size(): Vector3;
  68425. /**
  68426. * Set point size
  68427. */
  68428. set size(scale: Vector3);
  68429. /**
  68430. * Legacy support, changed quaternion to rotationQuaternion
  68431. */
  68432. get quaternion(): Nullable<Quaternion>;
  68433. /**
  68434. * Legacy support, changed quaternion to rotationQuaternion
  68435. */
  68436. set quaternion(q: Nullable<Quaternion>);
  68437. /**
  68438. * Returns a boolean. True if the particle intersects a mesh, else false
  68439. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68440. * @param target is the object (point or mesh) what the intersection is computed against
  68441. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68442. * @returns true if it intersects
  68443. */
  68444. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68445. /**
  68446. * get the rotation matrix of the particle
  68447. * @hidden
  68448. */
  68449. getRotationMatrix(m: Matrix): void;
  68450. }
  68451. /**
  68452. * Represents a group of points in a points cloud system
  68453. * * PCS internal tool, don't use it manually.
  68454. */
  68455. export class PointsGroup {
  68456. /**
  68457. * The group id
  68458. * @hidden
  68459. */
  68460. groupID: number;
  68461. /**
  68462. * image data for group (internal use)
  68463. * @hidden
  68464. */
  68465. _groupImageData: Nullable<ArrayBufferView>;
  68466. /**
  68467. * Image Width (internal use)
  68468. * @hidden
  68469. */
  68470. _groupImgWidth: number;
  68471. /**
  68472. * Image Height (internal use)
  68473. * @hidden
  68474. */
  68475. _groupImgHeight: number;
  68476. /**
  68477. * Custom position function (internal use)
  68478. * @hidden
  68479. */
  68480. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68481. /**
  68482. * density per facet for surface points
  68483. * @hidden
  68484. */
  68485. _groupDensity: number[];
  68486. /**
  68487. * Only when points are colored by texture carries pointer to texture list array
  68488. * @hidden
  68489. */
  68490. _textureNb: number;
  68491. /**
  68492. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68493. * PCS internal tool, don't use it manually.
  68494. * @hidden
  68495. */
  68496. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68497. }
  68498. }
  68499. declare module BABYLON {
  68500. interface Scene {
  68501. /** @hidden (Backing field) */
  68502. _physicsEngine: Nullable<IPhysicsEngine>;
  68503. /** @hidden */
  68504. _physicsTimeAccumulator: number;
  68505. /**
  68506. * Gets the current physics engine
  68507. * @returns a IPhysicsEngine or null if none attached
  68508. */
  68509. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68510. /**
  68511. * Enables physics to the current scene
  68512. * @param gravity defines the scene's gravity for the physics engine
  68513. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68514. * @return a boolean indicating if the physics engine was initialized
  68515. */
  68516. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68517. /**
  68518. * Disables and disposes the physics engine associated with the scene
  68519. */
  68520. disablePhysicsEngine(): void;
  68521. /**
  68522. * Gets a boolean indicating if there is an active physics engine
  68523. * @returns a boolean indicating if there is an active physics engine
  68524. */
  68525. isPhysicsEnabled(): boolean;
  68526. /**
  68527. * Deletes a physics compound impostor
  68528. * @param compound defines the compound to delete
  68529. */
  68530. deleteCompoundImpostor(compound: any): void;
  68531. /**
  68532. * An event triggered when physic simulation is about to be run
  68533. */
  68534. onBeforePhysicsObservable: Observable<Scene>;
  68535. /**
  68536. * An event triggered when physic simulation has been done
  68537. */
  68538. onAfterPhysicsObservable: Observable<Scene>;
  68539. }
  68540. interface AbstractMesh {
  68541. /** @hidden */
  68542. _physicsImpostor: Nullable<PhysicsImpostor>;
  68543. /**
  68544. * Gets or sets impostor used for physic simulation
  68545. * @see https://doc.babylonjs.com/features/physics_engine
  68546. */
  68547. physicsImpostor: Nullable<PhysicsImpostor>;
  68548. /**
  68549. * Gets the current physics impostor
  68550. * @see https://doc.babylonjs.com/features/physics_engine
  68551. * @returns a physics impostor or null
  68552. */
  68553. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68554. /** Apply a physic impulse to the mesh
  68555. * @param force defines the force to apply
  68556. * @param contactPoint defines where to apply the force
  68557. * @returns the current mesh
  68558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68559. */
  68560. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68561. /**
  68562. * Creates a physic joint between two meshes
  68563. * @param otherMesh defines the other mesh to use
  68564. * @param pivot1 defines the pivot to use on this mesh
  68565. * @param pivot2 defines the pivot to use on the other mesh
  68566. * @param options defines additional options (can be plugin dependent)
  68567. * @returns the current mesh
  68568. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68569. */
  68570. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68571. /** @hidden */
  68572. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68573. }
  68574. /**
  68575. * Defines the physics engine scene component responsible to manage a physics engine
  68576. */
  68577. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68578. /**
  68579. * The component name helpful to identify the component in the list of scene components.
  68580. */
  68581. readonly name: string;
  68582. /**
  68583. * The scene the component belongs to.
  68584. */
  68585. scene: Scene;
  68586. /**
  68587. * Creates a new instance of the component for the given scene
  68588. * @param scene Defines the scene to register the component in
  68589. */
  68590. constructor(scene: Scene);
  68591. /**
  68592. * Registers the component in a given scene
  68593. */
  68594. register(): void;
  68595. /**
  68596. * Rebuilds the elements related to this component in case of
  68597. * context lost for instance.
  68598. */
  68599. rebuild(): void;
  68600. /**
  68601. * Disposes the component and the associated ressources
  68602. */
  68603. dispose(): void;
  68604. }
  68605. }
  68606. declare module BABYLON {
  68607. /**
  68608. * A helper for physics simulations
  68609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68610. */
  68611. export class PhysicsHelper {
  68612. private _scene;
  68613. private _physicsEngine;
  68614. /**
  68615. * Initializes the Physics helper
  68616. * @param scene Babylon.js scene
  68617. */
  68618. constructor(scene: Scene);
  68619. /**
  68620. * Applies a radial explosion impulse
  68621. * @param origin the origin of the explosion
  68622. * @param radiusOrEventOptions the radius or the options of radial explosion
  68623. * @param strength the explosion strength
  68624. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68625. * @returns A physics radial explosion event, or null
  68626. */
  68627. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68628. /**
  68629. * Applies a radial explosion force
  68630. * @param origin the origin of the explosion
  68631. * @param radiusOrEventOptions the radius or the options of radial explosion
  68632. * @param strength the explosion strength
  68633. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68634. * @returns A physics radial explosion event, or null
  68635. */
  68636. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68637. /**
  68638. * Creates a gravitational field
  68639. * @param origin the origin of the explosion
  68640. * @param radiusOrEventOptions the radius or the options of radial explosion
  68641. * @param strength the explosion strength
  68642. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68643. * @returns A physics gravitational field event, or null
  68644. */
  68645. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68646. /**
  68647. * Creates a physics updraft event
  68648. * @param origin the origin of the updraft
  68649. * @param radiusOrEventOptions the radius or the options of the updraft
  68650. * @param strength the strength of the updraft
  68651. * @param height the height of the updraft
  68652. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68653. * @returns A physics updraft event, or null
  68654. */
  68655. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68656. /**
  68657. * Creates a physics vortex event
  68658. * @param origin the of the vortex
  68659. * @param radiusOrEventOptions the radius or the options of the vortex
  68660. * @param strength the strength of the vortex
  68661. * @param height the height of the vortex
  68662. * @returns a Physics vortex event, or null
  68663. * A physics vortex event or null
  68664. */
  68665. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68666. }
  68667. /**
  68668. * Represents a physics radial explosion event
  68669. */
  68670. class PhysicsRadialExplosionEvent {
  68671. private _scene;
  68672. private _options;
  68673. private _sphere;
  68674. private _dataFetched;
  68675. /**
  68676. * Initializes a radial explosioin event
  68677. * @param _scene BabylonJS scene
  68678. * @param _options The options for the vortex event
  68679. */
  68680. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68681. /**
  68682. * Returns the data related to the radial explosion event (sphere).
  68683. * @returns The radial explosion event data
  68684. */
  68685. getData(): PhysicsRadialExplosionEventData;
  68686. /**
  68687. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68688. * @param impostor A physics imposter
  68689. * @param origin the origin of the explosion
  68690. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68691. */
  68692. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68693. /**
  68694. * Triggers affecterd impostors callbacks
  68695. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68696. */
  68697. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68698. /**
  68699. * Disposes the sphere.
  68700. * @param force Specifies if the sphere should be disposed by force
  68701. */
  68702. dispose(force?: boolean): void;
  68703. /*** Helpers ***/
  68704. private _prepareSphere;
  68705. private _intersectsWithSphere;
  68706. }
  68707. /**
  68708. * Represents a gravitational field event
  68709. */
  68710. class PhysicsGravitationalFieldEvent {
  68711. private _physicsHelper;
  68712. private _scene;
  68713. private _origin;
  68714. private _options;
  68715. private _tickCallback;
  68716. private _sphere;
  68717. private _dataFetched;
  68718. /**
  68719. * Initializes the physics gravitational field event
  68720. * @param _physicsHelper A physics helper
  68721. * @param _scene BabylonJS scene
  68722. * @param _origin The origin position of the gravitational field event
  68723. * @param _options The options for the vortex event
  68724. */
  68725. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68726. /**
  68727. * Returns the data related to the gravitational field event (sphere).
  68728. * @returns A gravitational field event
  68729. */
  68730. getData(): PhysicsGravitationalFieldEventData;
  68731. /**
  68732. * Enables the gravitational field.
  68733. */
  68734. enable(): void;
  68735. /**
  68736. * Disables the gravitational field.
  68737. */
  68738. disable(): void;
  68739. /**
  68740. * Disposes the sphere.
  68741. * @param force The force to dispose from the gravitational field event
  68742. */
  68743. dispose(force?: boolean): void;
  68744. private _tick;
  68745. }
  68746. /**
  68747. * Represents a physics updraft event
  68748. */
  68749. class PhysicsUpdraftEvent {
  68750. private _scene;
  68751. private _origin;
  68752. private _options;
  68753. private _physicsEngine;
  68754. private _originTop;
  68755. private _originDirection;
  68756. private _tickCallback;
  68757. private _cylinder;
  68758. private _cylinderPosition;
  68759. private _dataFetched;
  68760. /**
  68761. * Initializes the physics updraft event
  68762. * @param _scene BabylonJS scene
  68763. * @param _origin The origin position of the updraft
  68764. * @param _options The options for the updraft event
  68765. */
  68766. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68767. /**
  68768. * Returns the data related to the updraft event (cylinder).
  68769. * @returns A physics updraft event
  68770. */
  68771. getData(): PhysicsUpdraftEventData;
  68772. /**
  68773. * Enables the updraft.
  68774. */
  68775. enable(): void;
  68776. /**
  68777. * Disables the updraft.
  68778. */
  68779. disable(): void;
  68780. /**
  68781. * Disposes the cylinder.
  68782. * @param force Specifies if the updraft should be disposed by force
  68783. */
  68784. dispose(force?: boolean): void;
  68785. private getImpostorHitData;
  68786. private _tick;
  68787. /*** Helpers ***/
  68788. private _prepareCylinder;
  68789. private _intersectsWithCylinder;
  68790. }
  68791. /**
  68792. * Represents a physics vortex event
  68793. */
  68794. class PhysicsVortexEvent {
  68795. private _scene;
  68796. private _origin;
  68797. private _options;
  68798. private _physicsEngine;
  68799. private _originTop;
  68800. private _tickCallback;
  68801. private _cylinder;
  68802. private _cylinderPosition;
  68803. private _dataFetched;
  68804. /**
  68805. * Initializes the physics vortex event
  68806. * @param _scene The BabylonJS scene
  68807. * @param _origin The origin position of the vortex
  68808. * @param _options The options for the vortex event
  68809. */
  68810. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68811. /**
  68812. * Returns the data related to the vortex event (cylinder).
  68813. * @returns The physics vortex event data
  68814. */
  68815. getData(): PhysicsVortexEventData;
  68816. /**
  68817. * Enables the vortex.
  68818. */
  68819. enable(): void;
  68820. /**
  68821. * Disables the cortex.
  68822. */
  68823. disable(): void;
  68824. /**
  68825. * Disposes the sphere.
  68826. * @param force
  68827. */
  68828. dispose(force?: boolean): void;
  68829. private getImpostorHitData;
  68830. private _tick;
  68831. /*** Helpers ***/
  68832. private _prepareCylinder;
  68833. private _intersectsWithCylinder;
  68834. }
  68835. /**
  68836. * Options fot the radial explosion event
  68837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68838. */
  68839. export class PhysicsRadialExplosionEventOptions {
  68840. /**
  68841. * The radius of the sphere for the radial explosion.
  68842. */
  68843. radius: number;
  68844. /**
  68845. * The strenth of the explosion.
  68846. */
  68847. strength: number;
  68848. /**
  68849. * The strenght of the force in correspondence to the distance of the affected object
  68850. */
  68851. falloff: PhysicsRadialImpulseFalloff;
  68852. /**
  68853. * Sphere options for the radial explosion.
  68854. */
  68855. sphere: {
  68856. segments: number;
  68857. diameter: number;
  68858. };
  68859. /**
  68860. * Sphere options for the radial explosion.
  68861. */
  68862. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68863. }
  68864. /**
  68865. * Options fot the updraft event
  68866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68867. */
  68868. export class PhysicsUpdraftEventOptions {
  68869. /**
  68870. * The radius of the cylinder for the vortex
  68871. */
  68872. radius: number;
  68873. /**
  68874. * The strenth of the updraft.
  68875. */
  68876. strength: number;
  68877. /**
  68878. * The height of the cylinder for the updraft.
  68879. */
  68880. height: number;
  68881. /**
  68882. * The mode for the the updraft.
  68883. */
  68884. updraftMode: PhysicsUpdraftMode;
  68885. }
  68886. /**
  68887. * Options fot the vortex event
  68888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68889. */
  68890. export class PhysicsVortexEventOptions {
  68891. /**
  68892. * The radius of the cylinder for the vortex
  68893. */
  68894. radius: number;
  68895. /**
  68896. * The strenth of the vortex.
  68897. */
  68898. strength: number;
  68899. /**
  68900. * The height of the cylinder for the vortex.
  68901. */
  68902. height: number;
  68903. /**
  68904. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68905. */
  68906. centripetalForceThreshold: number;
  68907. /**
  68908. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68909. */
  68910. centripetalForceMultiplier: number;
  68911. /**
  68912. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68913. */
  68914. centrifugalForceMultiplier: number;
  68915. /**
  68916. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68917. */
  68918. updraftForceMultiplier: number;
  68919. }
  68920. /**
  68921. * The strenght of the force in correspondence to the distance of the affected object
  68922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68923. */
  68924. export enum PhysicsRadialImpulseFalloff {
  68925. /** Defines that impulse is constant in strength across it's whole radius */
  68926. Constant = 0,
  68927. /** Defines that impulse gets weaker if it's further from the origin */
  68928. Linear = 1
  68929. }
  68930. /**
  68931. * The strength of the force in correspondence to the distance of the affected object
  68932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68933. */
  68934. export enum PhysicsUpdraftMode {
  68935. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68936. Center = 0,
  68937. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68938. Perpendicular = 1
  68939. }
  68940. /**
  68941. * Interface for a physics hit data
  68942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68943. */
  68944. export interface PhysicsHitData {
  68945. /**
  68946. * The force applied at the contact point
  68947. */
  68948. force: Vector3;
  68949. /**
  68950. * The contact point
  68951. */
  68952. contactPoint: Vector3;
  68953. /**
  68954. * The distance from the origin to the contact point
  68955. */
  68956. distanceFromOrigin: number;
  68957. }
  68958. /**
  68959. * Interface for radial explosion event data
  68960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68961. */
  68962. export interface PhysicsRadialExplosionEventData {
  68963. /**
  68964. * A sphere used for the radial explosion event
  68965. */
  68966. sphere: Mesh;
  68967. }
  68968. /**
  68969. * Interface for gravitational field event data
  68970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68971. */
  68972. export interface PhysicsGravitationalFieldEventData {
  68973. /**
  68974. * A sphere mesh used for the gravitational field event
  68975. */
  68976. sphere: Mesh;
  68977. }
  68978. /**
  68979. * Interface for updraft event data
  68980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68981. */
  68982. export interface PhysicsUpdraftEventData {
  68983. /**
  68984. * A cylinder used for the updraft event
  68985. */
  68986. cylinder: Mesh;
  68987. }
  68988. /**
  68989. * Interface for vortex event data
  68990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68991. */
  68992. export interface PhysicsVortexEventData {
  68993. /**
  68994. * A cylinder used for the vortex event
  68995. */
  68996. cylinder: Mesh;
  68997. }
  68998. /**
  68999. * Interface for an affected physics impostor
  69000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69001. */
  69002. export interface PhysicsAffectedImpostorWithData {
  69003. /**
  69004. * The impostor affected by the effect
  69005. */
  69006. impostor: PhysicsImpostor;
  69007. /**
  69008. * The data about the hit/horce from the explosion
  69009. */
  69010. hitData: PhysicsHitData;
  69011. }
  69012. }
  69013. declare module BABYLON {
  69014. /** @hidden */
  69015. export var blackAndWhitePixelShader: {
  69016. name: string;
  69017. shader: string;
  69018. };
  69019. }
  69020. declare module BABYLON {
  69021. /**
  69022. * Post process used to render in black and white
  69023. */
  69024. export class BlackAndWhitePostProcess extends PostProcess {
  69025. /**
  69026. * Linear about to convert he result to black and white (default: 1)
  69027. */
  69028. degree: number;
  69029. /**
  69030. * Gets a string identifying the name of the class
  69031. * @returns "BlackAndWhitePostProcess" string
  69032. */
  69033. getClassName(): string;
  69034. /**
  69035. * Creates a black and white post process
  69036. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69037. * @param name The name of the effect.
  69038. * @param options The required width/height ratio to downsize to before computing the render pass.
  69039. * @param camera The camera to apply the render pass to.
  69040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69041. * @param engine The engine which the post process will be applied. (default: current engine)
  69042. * @param reusable If the post process can be reused on the same frame. (default: false)
  69043. */
  69044. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69045. /** @hidden */
  69046. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69047. }
  69048. }
  69049. declare module BABYLON {
  69050. /**
  69051. * This represents a set of one or more post processes in Babylon.
  69052. * A post process can be used to apply a shader to a texture after it is rendered.
  69053. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69054. */
  69055. export class PostProcessRenderEffect {
  69056. private _postProcesses;
  69057. private _getPostProcesses;
  69058. private _singleInstance;
  69059. private _cameras;
  69060. private _indicesForCamera;
  69061. /**
  69062. * Name of the effect
  69063. * @hidden
  69064. */
  69065. _name: string;
  69066. /**
  69067. * Instantiates a post process render effect.
  69068. * A post process can be used to apply a shader to a texture after it is rendered.
  69069. * @param engine The engine the effect is tied to
  69070. * @param name The name of the effect
  69071. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69072. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69073. */
  69074. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69075. /**
  69076. * Checks if all the post processes in the effect are supported.
  69077. */
  69078. get isSupported(): boolean;
  69079. /**
  69080. * Updates the current state of the effect
  69081. * @hidden
  69082. */
  69083. _update(): void;
  69084. /**
  69085. * Attaches the effect on cameras
  69086. * @param cameras The camera to attach to.
  69087. * @hidden
  69088. */
  69089. _attachCameras(cameras: Camera): void;
  69090. /**
  69091. * Attaches the effect on cameras
  69092. * @param cameras The camera to attach to.
  69093. * @hidden
  69094. */
  69095. _attachCameras(cameras: Camera[]): void;
  69096. /**
  69097. * Detaches the effect on cameras
  69098. * @param cameras The camera to detatch from.
  69099. * @hidden
  69100. */
  69101. _detachCameras(cameras: Camera): void;
  69102. /**
  69103. * Detatches the effect on cameras
  69104. * @param cameras The camera to detatch from.
  69105. * @hidden
  69106. */
  69107. _detachCameras(cameras: Camera[]): void;
  69108. /**
  69109. * Enables the effect on given cameras
  69110. * @param cameras The camera to enable.
  69111. * @hidden
  69112. */
  69113. _enable(cameras: Camera): void;
  69114. /**
  69115. * Enables the effect on given cameras
  69116. * @param cameras The camera to enable.
  69117. * @hidden
  69118. */
  69119. _enable(cameras: Nullable<Camera[]>): void;
  69120. /**
  69121. * Disables the effect on the given cameras
  69122. * @param cameras The camera to disable.
  69123. * @hidden
  69124. */
  69125. _disable(cameras: Camera): void;
  69126. /**
  69127. * Disables the effect on the given cameras
  69128. * @param cameras The camera to disable.
  69129. * @hidden
  69130. */
  69131. _disable(cameras: Nullable<Camera[]>): void;
  69132. /**
  69133. * Gets a list of the post processes contained in the effect.
  69134. * @param camera The camera to get the post processes on.
  69135. * @returns The list of the post processes in the effect.
  69136. */
  69137. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69138. }
  69139. }
  69140. declare module BABYLON {
  69141. /** @hidden */
  69142. export var extractHighlightsPixelShader: {
  69143. name: string;
  69144. shader: string;
  69145. };
  69146. }
  69147. declare module BABYLON {
  69148. /**
  69149. * 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.
  69150. */
  69151. export class ExtractHighlightsPostProcess extends PostProcess {
  69152. /**
  69153. * The luminance threshold, pixels below this value will be set to black.
  69154. */
  69155. threshold: number;
  69156. /** @hidden */
  69157. _exposure: number;
  69158. /**
  69159. * Post process which has the input texture to be used when performing highlight extraction
  69160. * @hidden
  69161. */
  69162. _inputPostProcess: Nullable<PostProcess>;
  69163. /**
  69164. * Gets a string identifying the name of the class
  69165. * @returns "ExtractHighlightsPostProcess" string
  69166. */
  69167. getClassName(): string;
  69168. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69169. }
  69170. }
  69171. declare module BABYLON {
  69172. /** @hidden */
  69173. export var bloomMergePixelShader: {
  69174. name: string;
  69175. shader: string;
  69176. };
  69177. }
  69178. declare module BABYLON {
  69179. /**
  69180. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69181. */
  69182. export class BloomMergePostProcess extends PostProcess {
  69183. /** Weight of the bloom to be added to the original input. */
  69184. weight: number;
  69185. /**
  69186. * Gets a string identifying the name of the class
  69187. * @returns "BloomMergePostProcess" string
  69188. */
  69189. getClassName(): string;
  69190. /**
  69191. * Creates a new instance of @see BloomMergePostProcess
  69192. * @param name The name of the effect.
  69193. * @param originalFromInput Post process which's input will be used for the merge.
  69194. * @param blurred Blurred highlights post process which's output will be used.
  69195. * @param weight Weight of the bloom to be added to the original input.
  69196. * @param options The required width/height ratio to downsize to before computing the render pass.
  69197. * @param camera The camera to apply the render pass to.
  69198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69199. * @param engine The engine which the post process will be applied. (default: current engine)
  69200. * @param reusable If the post process can be reused on the same frame. (default: false)
  69201. * @param textureType Type of textures used when performing the post process. (default: 0)
  69202. * @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)
  69203. */
  69204. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69205. /** Weight of the bloom to be added to the original input. */
  69206. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69207. }
  69208. }
  69209. declare module BABYLON {
  69210. /**
  69211. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69212. */
  69213. export class BloomEffect extends PostProcessRenderEffect {
  69214. private bloomScale;
  69215. /**
  69216. * @hidden Internal
  69217. */
  69218. _effects: Array<PostProcess>;
  69219. /**
  69220. * @hidden Internal
  69221. */
  69222. _downscale: ExtractHighlightsPostProcess;
  69223. private _blurX;
  69224. private _blurY;
  69225. private _merge;
  69226. /**
  69227. * The luminance threshold to find bright areas of the image to bloom.
  69228. */
  69229. get threshold(): number;
  69230. set threshold(value: number);
  69231. /**
  69232. * The strength of the bloom.
  69233. */
  69234. get weight(): number;
  69235. set weight(value: number);
  69236. /**
  69237. * Specifies the size of the bloom blur kernel, relative to the final output size
  69238. */
  69239. get kernel(): number;
  69240. set kernel(value: number);
  69241. /**
  69242. * Creates a new instance of @see BloomEffect
  69243. * @param scene The scene the effect belongs to.
  69244. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69245. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69246. * @param bloomWeight The the strength of bloom.
  69247. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69248. * @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)
  69249. */
  69250. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69251. /**
  69252. * Disposes each of the internal effects for a given camera.
  69253. * @param camera The camera to dispose the effect on.
  69254. */
  69255. disposeEffects(camera: Camera): void;
  69256. /**
  69257. * @hidden Internal
  69258. */
  69259. _updateEffects(): void;
  69260. /**
  69261. * Internal
  69262. * @returns if all the contained post processes are ready.
  69263. * @hidden
  69264. */
  69265. _isReady(): boolean;
  69266. }
  69267. }
  69268. declare module BABYLON {
  69269. /** @hidden */
  69270. export var chromaticAberrationPixelShader: {
  69271. name: string;
  69272. shader: string;
  69273. };
  69274. }
  69275. declare module BABYLON {
  69276. /**
  69277. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69278. */
  69279. export class ChromaticAberrationPostProcess extends PostProcess {
  69280. /**
  69281. * The amount of seperation of rgb channels (default: 30)
  69282. */
  69283. aberrationAmount: number;
  69284. /**
  69285. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69286. */
  69287. radialIntensity: number;
  69288. /**
  69289. * 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))
  69290. */
  69291. direction: Vector2;
  69292. /**
  69293. * 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))
  69294. */
  69295. centerPosition: Vector2;
  69296. /** The width of the screen to apply the effect on */
  69297. screenWidth: number;
  69298. /** The height of the screen to apply the effect on */
  69299. screenHeight: number;
  69300. /**
  69301. * Gets a string identifying the name of the class
  69302. * @returns "ChromaticAberrationPostProcess" string
  69303. */
  69304. getClassName(): string;
  69305. /**
  69306. * Creates a new instance ChromaticAberrationPostProcess
  69307. * @param name The name of the effect.
  69308. * @param screenWidth The width of the screen to apply the effect on.
  69309. * @param screenHeight The height of the screen to apply the effect on.
  69310. * @param options The required width/height ratio to downsize to before computing the render pass.
  69311. * @param camera The camera to apply the render pass to.
  69312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69313. * @param engine The engine which the post process will be applied. (default: current engine)
  69314. * @param reusable If the post process can be reused on the same frame. (default: false)
  69315. * @param textureType Type of textures used when performing the post process. (default: 0)
  69316. * @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)
  69317. */
  69318. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69319. /** @hidden */
  69320. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69321. }
  69322. }
  69323. declare module BABYLON {
  69324. /** @hidden */
  69325. export var circleOfConfusionPixelShader: {
  69326. name: string;
  69327. shader: string;
  69328. };
  69329. }
  69330. declare module BABYLON {
  69331. /**
  69332. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69333. */
  69334. export class CircleOfConfusionPostProcess extends PostProcess {
  69335. /**
  69336. * 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.
  69337. */
  69338. lensSize: number;
  69339. /**
  69340. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69341. */
  69342. fStop: number;
  69343. /**
  69344. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69345. */
  69346. focusDistance: number;
  69347. /**
  69348. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69349. */
  69350. focalLength: number;
  69351. /**
  69352. * Gets a string identifying the name of the class
  69353. * @returns "CircleOfConfusionPostProcess" string
  69354. */
  69355. getClassName(): string;
  69356. private _depthTexture;
  69357. /**
  69358. * Creates a new instance CircleOfConfusionPostProcess
  69359. * @param name The name of the effect.
  69360. * @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.
  69361. * @param options The required width/height ratio to downsize to before computing the render pass.
  69362. * @param camera The camera to apply the render pass to.
  69363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69364. * @param engine The engine which the post process will be applied. (default: current engine)
  69365. * @param reusable If the post process can be reused on the same frame. (default: false)
  69366. * @param textureType Type of textures used when performing the post process. (default: 0)
  69367. * @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)
  69368. */
  69369. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69370. /**
  69371. * 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.
  69372. */
  69373. set depthTexture(value: RenderTargetTexture);
  69374. }
  69375. }
  69376. declare module BABYLON {
  69377. /** @hidden */
  69378. export var colorCorrectionPixelShader: {
  69379. name: string;
  69380. shader: string;
  69381. };
  69382. }
  69383. declare module BABYLON {
  69384. /**
  69385. *
  69386. * This post-process allows the modification of rendered colors by using
  69387. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69388. *
  69389. * The object needs to be provided an url to a texture containing the color
  69390. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69391. * Use an image editing software to tweak the LUT to match your needs.
  69392. *
  69393. * For an example of a color LUT, see here:
  69394. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69395. * For explanations on color grading, see here:
  69396. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69397. *
  69398. */
  69399. export class ColorCorrectionPostProcess extends PostProcess {
  69400. private _colorTableTexture;
  69401. /**
  69402. * Gets the color table url used to create the LUT texture
  69403. */
  69404. colorTableUrl: string;
  69405. /**
  69406. * Gets a string identifying the name of the class
  69407. * @returns "ColorCorrectionPostProcess" string
  69408. */
  69409. getClassName(): string;
  69410. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69411. /** @hidden */
  69412. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69413. }
  69414. }
  69415. declare module BABYLON {
  69416. /** @hidden */
  69417. export var convolutionPixelShader: {
  69418. name: string;
  69419. shader: string;
  69420. };
  69421. }
  69422. declare module BABYLON {
  69423. /**
  69424. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69425. * input texture to perform effects such as edge detection or sharpening
  69426. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69427. */
  69428. export class ConvolutionPostProcess extends PostProcess {
  69429. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69430. kernel: number[];
  69431. /**
  69432. * Gets a string identifying the name of the class
  69433. * @returns "ConvolutionPostProcess" string
  69434. */
  69435. getClassName(): string;
  69436. /**
  69437. * Creates a new instance ConvolutionPostProcess
  69438. * @param name The name of the effect.
  69439. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69440. * @param options The required width/height ratio to downsize to before computing the render pass.
  69441. * @param camera The camera to apply the render pass to.
  69442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69443. * @param engine The engine which the post process will be applied. (default: current engine)
  69444. * @param reusable If the post process can be reused on the same frame. (default: false)
  69445. * @param textureType Type of textures used when performing the post process. (default: 0)
  69446. */
  69447. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69448. /** @hidden */
  69449. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69450. /**
  69451. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69452. */
  69453. static EdgeDetect0Kernel: number[];
  69454. /**
  69455. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69456. */
  69457. static EdgeDetect1Kernel: number[];
  69458. /**
  69459. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69460. */
  69461. static EdgeDetect2Kernel: number[];
  69462. /**
  69463. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69464. */
  69465. static SharpenKernel: number[];
  69466. /**
  69467. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69468. */
  69469. static EmbossKernel: number[];
  69470. /**
  69471. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69472. */
  69473. static GaussianKernel: number[];
  69474. }
  69475. }
  69476. declare module BABYLON {
  69477. /**
  69478. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69479. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69480. * based on samples that have a large difference in distance than the center pixel.
  69481. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69482. */
  69483. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69484. /**
  69485. * The direction the blur should be applied
  69486. */
  69487. direction: Vector2;
  69488. /**
  69489. * Gets a string identifying the name of the class
  69490. * @returns "DepthOfFieldBlurPostProcess" string
  69491. */
  69492. getClassName(): string;
  69493. /**
  69494. * Creates a new instance CircleOfConfusionPostProcess
  69495. * @param name The name of the effect.
  69496. * @param scene The scene the effect belongs to.
  69497. * @param direction The direction the blur should be applied.
  69498. * @param kernel The size of the kernel used to blur.
  69499. * @param options The required width/height ratio to downsize to before computing the render pass.
  69500. * @param camera The camera to apply the render pass to.
  69501. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69502. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69504. * @param engine The engine which the post process will be applied. (default: current engine)
  69505. * @param reusable If the post process can be reused on the same frame. (default: false)
  69506. * @param textureType Type of textures used when performing the post process. (default: 0)
  69507. * @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)
  69508. */
  69509. 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);
  69510. }
  69511. }
  69512. declare module BABYLON {
  69513. /** @hidden */
  69514. export var depthOfFieldMergePixelShader: {
  69515. name: string;
  69516. shader: string;
  69517. };
  69518. }
  69519. declare module BABYLON {
  69520. /**
  69521. * Options to be set when merging outputs from the default pipeline.
  69522. */
  69523. export class DepthOfFieldMergePostProcessOptions {
  69524. /**
  69525. * The original image to merge on top of
  69526. */
  69527. originalFromInput: PostProcess;
  69528. /**
  69529. * Parameters to perform the merge of the depth of field effect
  69530. */
  69531. depthOfField?: {
  69532. circleOfConfusion: PostProcess;
  69533. blurSteps: Array<PostProcess>;
  69534. };
  69535. /**
  69536. * Parameters to perform the merge of bloom effect
  69537. */
  69538. bloom?: {
  69539. blurred: PostProcess;
  69540. weight: number;
  69541. };
  69542. }
  69543. /**
  69544. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69545. */
  69546. export class DepthOfFieldMergePostProcess extends PostProcess {
  69547. private blurSteps;
  69548. /**
  69549. * Gets a string identifying the name of the class
  69550. * @returns "DepthOfFieldMergePostProcess" string
  69551. */
  69552. getClassName(): string;
  69553. /**
  69554. * Creates a new instance of DepthOfFieldMergePostProcess
  69555. * @param name The name of the effect.
  69556. * @param originalFromInput Post process which's input will be used for the merge.
  69557. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69558. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69559. * @param options The required width/height ratio to downsize to before computing the render pass.
  69560. * @param camera The camera to apply the render pass to.
  69561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69562. * @param engine The engine which the post process will be applied. (default: current engine)
  69563. * @param reusable If the post process can be reused on the same frame. (default: false)
  69564. * @param textureType Type of textures used when performing the post process. (default: 0)
  69565. * @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)
  69566. */
  69567. 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);
  69568. /**
  69569. * Updates the effect with the current post process compile time values and recompiles the shader.
  69570. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69571. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69572. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69573. * @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
  69574. * @param onCompiled Called when the shader has been compiled.
  69575. * @param onError Called if there is an error when compiling a shader.
  69576. */
  69577. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69578. }
  69579. }
  69580. declare module BABYLON {
  69581. /**
  69582. * Specifies the level of max blur that should be applied when using the depth of field effect
  69583. */
  69584. export enum DepthOfFieldEffectBlurLevel {
  69585. /**
  69586. * Subtle blur
  69587. */
  69588. Low = 0,
  69589. /**
  69590. * Medium blur
  69591. */
  69592. Medium = 1,
  69593. /**
  69594. * Large blur
  69595. */
  69596. High = 2
  69597. }
  69598. /**
  69599. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69600. */
  69601. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69602. private _circleOfConfusion;
  69603. /**
  69604. * @hidden Internal, blurs from high to low
  69605. */
  69606. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69607. private _depthOfFieldBlurY;
  69608. private _dofMerge;
  69609. /**
  69610. * @hidden Internal post processes in depth of field effect
  69611. */
  69612. _effects: Array<PostProcess>;
  69613. /**
  69614. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69615. */
  69616. set focalLength(value: number);
  69617. get focalLength(): number;
  69618. /**
  69619. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69620. */
  69621. set fStop(value: number);
  69622. get fStop(): number;
  69623. /**
  69624. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69625. */
  69626. set focusDistance(value: number);
  69627. get focusDistance(): number;
  69628. /**
  69629. * 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.
  69630. */
  69631. set lensSize(value: number);
  69632. get lensSize(): number;
  69633. /**
  69634. * Creates a new instance DepthOfFieldEffect
  69635. * @param scene The scene the effect belongs to.
  69636. * @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.
  69637. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69638. * @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)
  69639. */
  69640. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69641. /**
  69642. * Get the current class name of the current effet
  69643. * @returns "DepthOfFieldEffect"
  69644. */
  69645. getClassName(): string;
  69646. /**
  69647. * 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.
  69648. */
  69649. set depthTexture(value: RenderTargetTexture);
  69650. /**
  69651. * Disposes each of the internal effects for a given camera.
  69652. * @param camera The camera to dispose the effect on.
  69653. */
  69654. disposeEffects(camera: Camera): void;
  69655. /**
  69656. * @hidden Internal
  69657. */
  69658. _updateEffects(): void;
  69659. /**
  69660. * Internal
  69661. * @returns if all the contained post processes are ready.
  69662. * @hidden
  69663. */
  69664. _isReady(): boolean;
  69665. }
  69666. }
  69667. declare module BABYLON {
  69668. /** @hidden */
  69669. export var displayPassPixelShader: {
  69670. name: string;
  69671. shader: string;
  69672. };
  69673. }
  69674. declare module BABYLON {
  69675. /**
  69676. * DisplayPassPostProcess which produces an output the same as it's input
  69677. */
  69678. export class DisplayPassPostProcess extends PostProcess {
  69679. /**
  69680. * Gets a string identifying the name of the class
  69681. * @returns "DisplayPassPostProcess" string
  69682. */
  69683. getClassName(): string;
  69684. /**
  69685. * Creates the DisplayPassPostProcess
  69686. * @param name The name of the effect.
  69687. * @param options The required width/height ratio to downsize to before computing the render pass.
  69688. * @param camera The camera to apply the render pass to.
  69689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69690. * @param engine The engine which the post process will be applied. (default: current engine)
  69691. * @param reusable If the post process can be reused on the same frame. (default: false)
  69692. */
  69693. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69694. /** @hidden */
  69695. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69696. }
  69697. }
  69698. declare module BABYLON {
  69699. /** @hidden */
  69700. export var filterPixelShader: {
  69701. name: string;
  69702. shader: string;
  69703. };
  69704. }
  69705. declare module BABYLON {
  69706. /**
  69707. * Applies a kernel filter to the image
  69708. */
  69709. export class FilterPostProcess extends PostProcess {
  69710. /** The matrix to be applied to the image */
  69711. kernelMatrix: Matrix;
  69712. /**
  69713. * Gets a string identifying the name of the class
  69714. * @returns "FilterPostProcess" string
  69715. */
  69716. getClassName(): string;
  69717. /**
  69718. *
  69719. * @param name The name of the effect.
  69720. * @param kernelMatrix The matrix to be applied to the image
  69721. * @param options The required width/height ratio to downsize to before computing the render pass.
  69722. * @param camera The camera to apply the render pass to.
  69723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69724. * @param engine The engine which the post process will be applied. (default: current engine)
  69725. * @param reusable If the post process can be reused on the same frame. (default: false)
  69726. */
  69727. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69728. /** @hidden */
  69729. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69730. }
  69731. }
  69732. declare module BABYLON {
  69733. /** @hidden */
  69734. export var fxaaPixelShader: {
  69735. name: string;
  69736. shader: string;
  69737. };
  69738. }
  69739. declare module BABYLON {
  69740. /** @hidden */
  69741. export var fxaaVertexShader: {
  69742. name: string;
  69743. shader: string;
  69744. };
  69745. }
  69746. declare module BABYLON {
  69747. /**
  69748. * Fxaa post process
  69749. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69750. */
  69751. export class FxaaPostProcess extends PostProcess {
  69752. /**
  69753. * Gets a string identifying the name of the class
  69754. * @returns "FxaaPostProcess" string
  69755. */
  69756. getClassName(): string;
  69757. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69758. private _getDefines;
  69759. /** @hidden */
  69760. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69761. }
  69762. }
  69763. declare module BABYLON {
  69764. /** @hidden */
  69765. export var grainPixelShader: {
  69766. name: string;
  69767. shader: string;
  69768. };
  69769. }
  69770. declare module BABYLON {
  69771. /**
  69772. * The GrainPostProcess adds noise to the image at mid luminance levels
  69773. */
  69774. export class GrainPostProcess extends PostProcess {
  69775. /**
  69776. * The intensity of the grain added (default: 30)
  69777. */
  69778. intensity: number;
  69779. /**
  69780. * If the grain should be randomized on every frame
  69781. */
  69782. animated: boolean;
  69783. /**
  69784. * Gets a string identifying the name of the class
  69785. * @returns "GrainPostProcess" string
  69786. */
  69787. getClassName(): string;
  69788. /**
  69789. * Creates a new instance of @see GrainPostProcess
  69790. * @param name The name of the effect.
  69791. * @param options The required width/height ratio to downsize to before computing the render pass.
  69792. * @param camera The camera to apply the render pass to.
  69793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69794. * @param engine The engine which the post process will be applied. (default: current engine)
  69795. * @param reusable If the post process can be reused on the same frame. (default: false)
  69796. * @param textureType Type of textures used when performing the post process. (default: 0)
  69797. * @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)
  69798. */
  69799. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69800. /** @hidden */
  69801. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69802. }
  69803. }
  69804. declare module BABYLON {
  69805. /** @hidden */
  69806. export var highlightsPixelShader: {
  69807. name: string;
  69808. shader: string;
  69809. };
  69810. }
  69811. declare module BABYLON {
  69812. /**
  69813. * Extracts highlights from the image
  69814. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69815. */
  69816. export class HighlightsPostProcess extends PostProcess {
  69817. /**
  69818. * Gets a string identifying the name of the class
  69819. * @returns "HighlightsPostProcess" string
  69820. */
  69821. getClassName(): string;
  69822. /**
  69823. * Extracts highlights from the image
  69824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69825. * @param name The name of the effect.
  69826. * @param options The required width/height ratio to downsize to before computing the render pass.
  69827. * @param camera The camera to apply the render pass to.
  69828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69829. * @param engine The engine which the post process will be applied. (default: current engine)
  69830. * @param reusable If the post process can be reused on the same frame. (default: false)
  69831. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69832. */
  69833. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69834. }
  69835. }
  69836. declare module BABYLON {
  69837. /** @hidden */
  69838. export var mrtFragmentDeclaration: {
  69839. name: string;
  69840. shader: string;
  69841. };
  69842. }
  69843. declare module BABYLON {
  69844. /** @hidden */
  69845. export var geometryPixelShader: {
  69846. name: string;
  69847. shader: string;
  69848. };
  69849. }
  69850. declare module BABYLON {
  69851. /** @hidden */
  69852. export var geometryVertexShader: {
  69853. name: string;
  69854. shader: string;
  69855. };
  69856. }
  69857. declare module BABYLON {
  69858. /** @hidden */
  69859. interface ISavedTransformationMatrix {
  69860. world: Matrix;
  69861. viewProjection: Matrix;
  69862. }
  69863. /**
  69864. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69865. */
  69866. export class GeometryBufferRenderer {
  69867. /**
  69868. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69869. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69870. */
  69871. static readonly POSITION_TEXTURE_TYPE: number;
  69872. /**
  69873. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69874. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69875. */
  69876. static readonly VELOCITY_TEXTURE_TYPE: number;
  69877. /**
  69878. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69879. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69880. */
  69881. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69882. /**
  69883. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69884. * in order to compute objects velocities when enableVelocity is set to "true"
  69885. * @hidden
  69886. */
  69887. _previousTransformationMatrices: {
  69888. [index: number]: ISavedTransformationMatrix;
  69889. };
  69890. /**
  69891. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69892. * in order to compute objects velocities when enableVelocity is set to "true"
  69893. * @hidden
  69894. */
  69895. _previousBonesTransformationMatrices: {
  69896. [index: number]: Float32Array;
  69897. };
  69898. /**
  69899. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69900. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69901. */
  69902. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69903. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69904. renderTransparentMeshes: boolean;
  69905. private _scene;
  69906. private _resizeObserver;
  69907. private _multiRenderTarget;
  69908. private _ratio;
  69909. private _enablePosition;
  69910. private _enableVelocity;
  69911. private _enableReflectivity;
  69912. private _positionIndex;
  69913. private _velocityIndex;
  69914. private _reflectivityIndex;
  69915. protected _effect: Effect;
  69916. protected _cachedDefines: string;
  69917. /**
  69918. * Set the render list (meshes to be rendered) used in the G buffer.
  69919. */
  69920. set renderList(meshes: Mesh[]);
  69921. /**
  69922. * Gets wether or not G buffer are supported by the running hardware.
  69923. * This requires draw buffer supports
  69924. */
  69925. get isSupported(): boolean;
  69926. /**
  69927. * Returns the index of the given texture type in the G-Buffer textures array
  69928. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69929. * @returns the index of the given texture type in the G-Buffer textures array
  69930. */
  69931. getTextureIndex(textureType: number): number;
  69932. /**
  69933. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69934. */
  69935. get enablePosition(): boolean;
  69936. /**
  69937. * Sets whether or not objects positions are enabled for the G buffer.
  69938. */
  69939. set enablePosition(enable: boolean);
  69940. /**
  69941. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69942. */
  69943. get enableVelocity(): boolean;
  69944. /**
  69945. * Sets wether or not objects velocities are enabled for the G buffer.
  69946. */
  69947. set enableVelocity(enable: boolean);
  69948. /**
  69949. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69950. */
  69951. get enableReflectivity(): boolean;
  69952. /**
  69953. * Sets wether or not objects roughness are enabled for the G buffer.
  69954. */
  69955. set enableReflectivity(enable: boolean);
  69956. /**
  69957. * Gets the scene associated with the buffer.
  69958. */
  69959. get scene(): Scene;
  69960. /**
  69961. * Gets the ratio used by the buffer during its creation.
  69962. * How big is the buffer related to the main canvas.
  69963. */
  69964. get ratio(): number;
  69965. /** @hidden */
  69966. static _SceneComponentInitialization: (scene: Scene) => void;
  69967. /**
  69968. * Creates a new G Buffer for the scene
  69969. * @param scene The scene the buffer belongs to
  69970. * @param ratio How big is the buffer related to the main canvas.
  69971. */
  69972. constructor(scene: Scene, ratio?: number);
  69973. /**
  69974. * Checks wether everything is ready to render a submesh to the G buffer.
  69975. * @param subMesh the submesh to check readiness for
  69976. * @param useInstances is the mesh drawn using instance or not
  69977. * @returns true if ready otherwise false
  69978. */
  69979. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69980. /**
  69981. * Gets the current underlying G Buffer.
  69982. * @returns the buffer
  69983. */
  69984. getGBuffer(): MultiRenderTarget;
  69985. /**
  69986. * Gets the number of samples used to render the buffer (anti aliasing).
  69987. */
  69988. get samples(): number;
  69989. /**
  69990. * Sets the number of samples used to render the buffer (anti aliasing).
  69991. */
  69992. set samples(value: number);
  69993. /**
  69994. * Disposes the renderer and frees up associated resources.
  69995. */
  69996. dispose(): void;
  69997. protected _createRenderTargets(): void;
  69998. private _copyBonesTransformationMatrices;
  69999. }
  70000. }
  70001. declare module BABYLON {
  70002. interface Scene {
  70003. /** @hidden (Backing field) */
  70004. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70005. /**
  70006. * Gets or Sets the current geometry buffer associated to the scene.
  70007. */
  70008. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70009. /**
  70010. * Enables a GeometryBufferRender and associates it with the scene
  70011. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70012. * @returns the GeometryBufferRenderer
  70013. */
  70014. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70015. /**
  70016. * Disables the GeometryBufferRender associated with the scene
  70017. */
  70018. disableGeometryBufferRenderer(): void;
  70019. }
  70020. /**
  70021. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70022. * in several rendering techniques.
  70023. */
  70024. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70025. /**
  70026. * The component name helpful to identify the component in the list of scene components.
  70027. */
  70028. readonly name: string;
  70029. /**
  70030. * The scene the component belongs to.
  70031. */
  70032. scene: Scene;
  70033. /**
  70034. * Creates a new instance of the component for the given scene
  70035. * @param scene Defines the scene to register the component in
  70036. */
  70037. constructor(scene: Scene);
  70038. /**
  70039. * Registers the component in a given scene
  70040. */
  70041. register(): void;
  70042. /**
  70043. * Rebuilds the elements related to this component in case of
  70044. * context lost for instance.
  70045. */
  70046. rebuild(): void;
  70047. /**
  70048. * Disposes the component and the associated ressources
  70049. */
  70050. dispose(): void;
  70051. private _gatherRenderTargets;
  70052. }
  70053. }
  70054. declare module BABYLON {
  70055. /** @hidden */
  70056. export var motionBlurPixelShader: {
  70057. name: string;
  70058. shader: string;
  70059. };
  70060. }
  70061. declare module BABYLON {
  70062. /**
  70063. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70064. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70065. * As an example, all you have to do is to create the post-process:
  70066. * var mb = new BABYLON.MotionBlurPostProcess(
  70067. * 'mb', // The name of the effect.
  70068. * scene, // The scene containing the objects to blur according to their velocity.
  70069. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70070. * camera // The camera to apply the render pass to.
  70071. * );
  70072. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70073. */
  70074. export class MotionBlurPostProcess extends PostProcess {
  70075. /**
  70076. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70077. */
  70078. motionStrength: number;
  70079. /**
  70080. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70081. */
  70082. get motionBlurSamples(): number;
  70083. /**
  70084. * Sets the number of iterations to be used for motion blur quality
  70085. */
  70086. set motionBlurSamples(samples: number);
  70087. private _motionBlurSamples;
  70088. private _geometryBufferRenderer;
  70089. /**
  70090. * Gets a string identifying the name of the class
  70091. * @returns "MotionBlurPostProcess" string
  70092. */
  70093. getClassName(): string;
  70094. /**
  70095. * Creates a new instance MotionBlurPostProcess
  70096. * @param name The name of the effect.
  70097. * @param scene The scene containing the objects to blur according to their velocity.
  70098. * @param options The required width/height ratio to downsize to before computing the render pass.
  70099. * @param camera The camera to apply the render pass to.
  70100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70101. * @param engine The engine which the post process will be applied. (default: current engine)
  70102. * @param reusable If the post process can be reused on the same frame. (default: false)
  70103. * @param textureType Type of textures used when performing the post process. (default: 0)
  70104. * @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)
  70105. */
  70106. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70107. /**
  70108. * Excludes the given skinned mesh from computing bones velocities.
  70109. * 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.
  70110. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70111. */
  70112. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70113. /**
  70114. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70115. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70116. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70117. */
  70118. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70119. /**
  70120. * Disposes the post process.
  70121. * @param camera The camera to dispose the post process on.
  70122. */
  70123. dispose(camera?: Camera): void;
  70124. /** @hidden */
  70125. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70126. }
  70127. }
  70128. declare module BABYLON {
  70129. /** @hidden */
  70130. export var refractionPixelShader: {
  70131. name: string;
  70132. shader: string;
  70133. };
  70134. }
  70135. declare module BABYLON {
  70136. /**
  70137. * Post process which applies a refractin texture
  70138. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70139. */
  70140. export class RefractionPostProcess extends PostProcess {
  70141. private _refTexture;
  70142. private _ownRefractionTexture;
  70143. /** the base color of the refraction (used to taint the rendering) */
  70144. color: Color3;
  70145. /** simulated refraction depth */
  70146. depth: number;
  70147. /** the coefficient of the base color (0 to remove base color tainting) */
  70148. colorLevel: number;
  70149. /** Gets the url used to load the refraction texture */
  70150. refractionTextureUrl: string;
  70151. /**
  70152. * Gets or sets the refraction texture
  70153. * Please note that you are responsible for disposing the texture if you set it manually
  70154. */
  70155. get refractionTexture(): Texture;
  70156. set refractionTexture(value: Texture);
  70157. /**
  70158. * Gets a string identifying the name of the class
  70159. * @returns "RefractionPostProcess" string
  70160. */
  70161. getClassName(): string;
  70162. /**
  70163. * Initializes the RefractionPostProcess
  70164. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70165. * @param name The name of the effect.
  70166. * @param refractionTextureUrl Url of the refraction texture to use
  70167. * @param color the base color of the refraction (used to taint the rendering)
  70168. * @param depth simulated refraction depth
  70169. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70170. * @param camera The camera to apply the render pass to.
  70171. * @param options The required width/height ratio to downsize to before computing the render pass.
  70172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70173. * @param engine The engine which the post process will be applied. (default: current engine)
  70174. * @param reusable If the post process can be reused on the same frame. (default: false)
  70175. */
  70176. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70177. /**
  70178. * Disposes of the post process
  70179. * @param camera Camera to dispose post process on
  70180. */
  70181. dispose(camera: Camera): void;
  70182. /** @hidden */
  70183. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70184. }
  70185. }
  70186. declare module BABYLON {
  70187. /** @hidden */
  70188. export var sharpenPixelShader: {
  70189. name: string;
  70190. shader: string;
  70191. };
  70192. }
  70193. declare module BABYLON {
  70194. /**
  70195. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70196. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70197. */
  70198. export class SharpenPostProcess extends PostProcess {
  70199. /**
  70200. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70201. */
  70202. colorAmount: number;
  70203. /**
  70204. * How much sharpness should be applied (default: 0.3)
  70205. */
  70206. edgeAmount: number;
  70207. /**
  70208. * Gets a string identifying the name of the class
  70209. * @returns "SharpenPostProcess" string
  70210. */
  70211. getClassName(): string;
  70212. /**
  70213. * Creates a new instance ConvolutionPostProcess
  70214. * @param name The name of the effect.
  70215. * @param options The required width/height ratio to downsize to before computing the render pass.
  70216. * @param camera The camera to apply the render pass to.
  70217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70218. * @param engine The engine which the post process will be applied. (default: current engine)
  70219. * @param reusable If the post process can be reused on the same frame. (default: false)
  70220. * @param textureType Type of textures used when performing the post process. (default: 0)
  70221. * @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)
  70222. */
  70223. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70224. /** @hidden */
  70225. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70226. }
  70227. }
  70228. declare module BABYLON {
  70229. /**
  70230. * PostProcessRenderPipeline
  70231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70232. */
  70233. export class PostProcessRenderPipeline {
  70234. private engine;
  70235. private _renderEffects;
  70236. private _renderEffectsForIsolatedPass;
  70237. /**
  70238. * List of inspectable custom properties (used by the Inspector)
  70239. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70240. */
  70241. inspectableCustomProperties: IInspectable[];
  70242. /**
  70243. * @hidden
  70244. */
  70245. protected _cameras: Camera[];
  70246. /** @hidden */
  70247. _name: string;
  70248. /**
  70249. * Gets pipeline name
  70250. */
  70251. get name(): string;
  70252. /** Gets the list of attached cameras */
  70253. get cameras(): Camera[];
  70254. /**
  70255. * Initializes a PostProcessRenderPipeline
  70256. * @param engine engine to add the pipeline to
  70257. * @param name name of the pipeline
  70258. */
  70259. constructor(engine: Engine, name: string);
  70260. /**
  70261. * Gets the class name
  70262. * @returns "PostProcessRenderPipeline"
  70263. */
  70264. getClassName(): string;
  70265. /**
  70266. * If all the render effects in the pipeline are supported
  70267. */
  70268. get isSupported(): boolean;
  70269. /**
  70270. * Adds an effect to the pipeline
  70271. * @param renderEffect the effect to add
  70272. */
  70273. addEffect(renderEffect: PostProcessRenderEffect): void;
  70274. /** @hidden */
  70275. _rebuild(): void;
  70276. /** @hidden */
  70277. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70278. /** @hidden */
  70279. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70280. /** @hidden */
  70281. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70282. /** @hidden */
  70283. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70284. /** @hidden */
  70285. _attachCameras(cameras: Camera, unique: boolean): void;
  70286. /** @hidden */
  70287. _attachCameras(cameras: Camera[], unique: boolean): void;
  70288. /** @hidden */
  70289. _detachCameras(cameras: Camera): void;
  70290. /** @hidden */
  70291. _detachCameras(cameras: Nullable<Camera[]>): void;
  70292. /** @hidden */
  70293. _update(): void;
  70294. /** @hidden */
  70295. _reset(): void;
  70296. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70297. /**
  70298. * Sets the required values to the prepass renderer.
  70299. * @param prePassRenderer defines the prepass renderer to setup.
  70300. * @returns true if the pre pass is needed.
  70301. */
  70302. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70303. /**
  70304. * Disposes of the pipeline
  70305. */
  70306. dispose(): void;
  70307. }
  70308. }
  70309. declare module BABYLON {
  70310. /**
  70311. * PostProcessRenderPipelineManager class
  70312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70313. */
  70314. export class PostProcessRenderPipelineManager {
  70315. private _renderPipelines;
  70316. /**
  70317. * Initializes a PostProcessRenderPipelineManager
  70318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70319. */
  70320. constructor();
  70321. /**
  70322. * Gets the list of supported render pipelines
  70323. */
  70324. get supportedPipelines(): PostProcessRenderPipeline[];
  70325. /**
  70326. * Adds a pipeline to the manager
  70327. * @param renderPipeline The pipeline to add
  70328. */
  70329. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70330. /**
  70331. * Attaches a camera to the pipeline
  70332. * @param renderPipelineName The name of the pipeline to attach to
  70333. * @param cameras the camera to attach
  70334. * @param unique if the camera can be attached multiple times to the pipeline
  70335. */
  70336. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70337. /**
  70338. * Detaches a camera from the pipeline
  70339. * @param renderPipelineName The name of the pipeline to detach from
  70340. * @param cameras the camera to detach
  70341. */
  70342. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70343. /**
  70344. * Enables an effect by name on a pipeline
  70345. * @param renderPipelineName the name of the pipeline to enable the effect in
  70346. * @param renderEffectName the name of the effect to enable
  70347. * @param cameras the cameras that the effect should be enabled on
  70348. */
  70349. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70350. /**
  70351. * Disables an effect by name on a pipeline
  70352. * @param renderPipelineName the name of the pipeline to disable the effect in
  70353. * @param renderEffectName the name of the effect to disable
  70354. * @param cameras the cameras that the effect should be disabled on
  70355. */
  70356. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70357. /**
  70358. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70359. */
  70360. update(): void;
  70361. /** @hidden */
  70362. _rebuild(): void;
  70363. /**
  70364. * Disposes of the manager and pipelines
  70365. */
  70366. dispose(): void;
  70367. }
  70368. }
  70369. declare module BABYLON {
  70370. interface Scene {
  70371. /** @hidden (Backing field) */
  70372. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70373. /**
  70374. * Gets the postprocess render pipeline manager
  70375. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70376. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70377. */
  70378. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70379. }
  70380. /**
  70381. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70382. */
  70383. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70384. /**
  70385. * The component name helpfull to identify the component in the list of scene components.
  70386. */
  70387. readonly name: string;
  70388. /**
  70389. * The scene the component belongs to.
  70390. */
  70391. scene: Scene;
  70392. /**
  70393. * Creates a new instance of the component for the given scene
  70394. * @param scene Defines the scene to register the component in
  70395. */
  70396. constructor(scene: Scene);
  70397. /**
  70398. * Registers the component in a given scene
  70399. */
  70400. register(): void;
  70401. /**
  70402. * Rebuilds the elements related to this component in case of
  70403. * context lost for instance.
  70404. */
  70405. rebuild(): void;
  70406. /**
  70407. * Disposes the component and the associated ressources
  70408. */
  70409. dispose(): void;
  70410. private _gatherRenderTargets;
  70411. }
  70412. }
  70413. declare module BABYLON {
  70414. /**
  70415. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70416. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70417. */
  70418. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70419. private _scene;
  70420. private _camerasToBeAttached;
  70421. /**
  70422. * ID of the sharpen post process,
  70423. */
  70424. private readonly SharpenPostProcessId;
  70425. /**
  70426. * @ignore
  70427. * ID of the image processing post process;
  70428. */
  70429. readonly ImageProcessingPostProcessId: string;
  70430. /**
  70431. * @ignore
  70432. * ID of the Fast Approximate Anti-Aliasing post process;
  70433. */
  70434. readonly FxaaPostProcessId: string;
  70435. /**
  70436. * ID of the chromatic aberration post process,
  70437. */
  70438. private readonly ChromaticAberrationPostProcessId;
  70439. /**
  70440. * ID of the grain post process
  70441. */
  70442. private readonly GrainPostProcessId;
  70443. /**
  70444. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70445. */
  70446. sharpen: SharpenPostProcess;
  70447. private _sharpenEffect;
  70448. private bloom;
  70449. /**
  70450. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70451. */
  70452. depthOfField: DepthOfFieldEffect;
  70453. /**
  70454. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70455. */
  70456. fxaa: FxaaPostProcess;
  70457. /**
  70458. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70459. */
  70460. imageProcessing: ImageProcessingPostProcess;
  70461. /**
  70462. * Chromatic aberration post process which will shift rgb colors in the image
  70463. */
  70464. chromaticAberration: ChromaticAberrationPostProcess;
  70465. private _chromaticAberrationEffect;
  70466. /**
  70467. * Grain post process which add noise to the image
  70468. */
  70469. grain: GrainPostProcess;
  70470. private _grainEffect;
  70471. /**
  70472. * Glow post process which adds a glow to emissive areas of the image
  70473. */
  70474. private _glowLayer;
  70475. /**
  70476. * Animations which can be used to tweak settings over a period of time
  70477. */
  70478. animations: Animation[];
  70479. private _imageProcessingConfigurationObserver;
  70480. private _sharpenEnabled;
  70481. private _bloomEnabled;
  70482. private _depthOfFieldEnabled;
  70483. private _depthOfFieldBlurLevel;
  70484. private _fxaaEnabled;
  70485. private _imageProcessingEnabled;
  70486. private _defaultPipelineTextureType;
  70487. private _bloomScale;
  70488. private _chromaticAberrationEnabled;
  70489. private _grainEnabled;
  70490. private _buildAllowed;
  70491. /**
  70492. * Gets active scene
  70493. */
  70494. get scene(): Scene;
  70495. /**
  70496. * Enable or disable the sharpen process from the pipeline
  70497. */
  70498. set sharpenEnabled(enabled: boolean);
  70499. get sharpenEnabled(): boolean;
  70500. private _resizeObserver;
  70501. private _hardwareScaleLevel;
  70502. private _bloomKernel;
  70503. /**
  70504. * Specifies the size of the bloom blur kernel, relative to the final output size
  70505. */
  70506. get bloomKernel(): number;
  70507. set bloomKernel(value: number);
  70508. /**
  70509. * Specifies the weight of the bloom in the final rendering
  70510. */
  70511. private _bloomWeight;
  70512. /**
  70513. * Specifies the luma threshold for the area that will be blurred by the bloom
  70514. */
  70515. private _bloomThreshold;
  70516. private _hdr;
  70517. /**
  70518. * The strength of the bloom.
  70519. */
  70520. set bloomWeight(value: number);
  70521. get bloomWeight(): number;
  70522. /**
  70523. * The strength of the bloom.
  70524. */
  70525. set bloomThreshold(value: number);
  70526. get bloomThreshold(): number;
  70527. /**
  70528. * The scale of the bloom, lower value will provide better performance.
  70529. */
  70530. set bloomScale(value: number);
  70531. get bloomScale(): number;
  70532. /**
  70533. * Enable or disable the bloom from the pipeline
  70534. */
  70535. set bloomEnabled(enabled: boolean);
  70536. get bloomEnabled(): boolean;
  70537. private _rebuildBloom;
  70538. /**
  70539. * If the depth of field is enabled.
  70540. */
  70541. get depthOfFieldEnabled(): boolean;
  70542. set depthOfFieldEnabled(enabled: boolean);
  70543. /**
  70544. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70545. */
  70546. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70547. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70548. /**
  70549. * If the anti aliasing is enabled.
  70550. */
  70551. set fxaaEnabled(enabled: boolean);
  70552. get fxaaEnabled(): boolean;
  70553. private _samples;
  70554. /**
  70555. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70556. */
  70557. set samples(sampleCount: number);
  70558. get samples(): number;
  70559. /**
  70560. * If image processing is enabled.
  70561. */
  70562. set imageProcessingEnabled(enabled: boolean);
  70563. get imageProcessingEnabled(): boolean;
  70564. /**
  70565. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70566. */
  70567. set glowLayerEnabled(enabled: boolean);
  70568. get glowLayerEnabled(): boolean;
  70569. /**
  70570. * Gets the glow layer (or null if not defined)
  70571. */
  70572. get glowLayer(): Nullable<GlowLayer>;
  70573. /**
  70574. * Enable or disable the chromaticAberration process from the pipeline
  70575. */
  70576. set chromaticAberrationEnabled(enabled: boolean);
  70577. get chromaticAberrationEnabled(): boolean;
  70578. /**
  70579. * Enable or disable the grain process from the pipeline
  70580. */
  70581. set grainEnabled(enabled: boolean);
  70582. get grainEnabled(): boolean;
  70583. /**
  70584. * @constructor
  70585. * @param name - The rendering pipeline name (default: "")
  70586. * @param hdr - If high dynamic range textures should be used (default: true)
  70587. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70588. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70589. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70590. */
  70591. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70592. /**
  70593. * Get the class name
  70594. * @returns "DefaultRenderingPipeline"
  70595. */
  70596. getClassName(): string;
  70597. /**
  70598. * Force the compilation of the entire pipeline.
  70599. */
  70600. prepare(): void;
  70601. private _hasCleared;
  70602. private _prevPostProcess;
  70603. private _prevPrevPostProcess;
  70604. private _setAutoClearAndTextureSharing;
  70605. private _depthOfFieldSceneObserver;
  70606. private _buildPipeline;
  70607. private _disposePostProcesses;
  70608. /**
  70609. * Adds a camera to the pipeline
  70610. * @param camera the camera to be added
  70611. */
  70612. addCamera(camera: Camera): void;
  70613. /**
  70614. * Removes a camera from the pipeline
  70615. * @param camera the camera to remove
  70616. */
  70617. removeCamera(camera: Camera): void;
  70618. /**
  70619. * Dispose of the pipeline and stop all post processes
  70620. */
  70621. dispose(): void;
  70622. /**
  70623. * Serialize the rendering pipeline (Used when exporting)
  70624. * @returns the serialized object
  70625. */
  70626. serialize(): any;
  70627. /**
  70628. * Parse the serialized pipeline
  70629. * @param source Source pipeline.
  70630. * @param scene The scene to load the pipeline to.
  70631. * @param rootUrl The URL of the serialized pipeline.
  70632. * @returns An instantiated pipeline from the serialized object.
  70633. */
  70634. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70635. }
  70636. }
  70637. declare module BABYLON {
  70638. /** @hidden */
  70639. export var lensHighlightsPixelShader: {
  70640. name: string;
  70641. shader: string;
  70642. };
  70643. }
  70644. declare module BABYLON {
  70645. /** @hidden */
  70646. export var depthOfFieldPixelShader: {
  70647. name: string;
  70648. shader: string;
  70649. };
  70650. }
  70651. declare module BABYLON {
  70652. /**
  70653. * BABYLON.JS Chromatic Aberration GLSL Shader
  70654. * Author: Olivier Guyot
  70655. * Separates very slightly R, G and B colors on the edges of the screen
  70656. * Inspired by Francois Tarlier & Martins Upitis
  70657. */
  70658. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70659. /**
  70660. * @ignore
  70661. * The chromatic aberration PostProcess id in the pipeline
  70662. */
  70663. LensChromaticAberrationEffect: string;
  70664. /**
  70665. * @ignore
  70666. * The highlights enhancing PostProcess id in the pipeline
  70667. */
  70668. HighlightsEnhancingEffect: string;
  70669. /**
  70670. * @ignore
  70671. * The depth-of-field PostProcess id in the pipeline
  70672. */
  70673. LensDepthOfFieldEffect: string;
  70674. private _scene;
  70675. private _depthTexture;
  70676. private _grainTexture;
  70677. private _chromaticAberrationPostProcess;
  70678. private _highlightsPostProcess;
  70679. private _depthOfFieldPostProcess;
  70680. private _edgeBlur;
  70681. private _grainAmount;
  70682. private _chromaticAberration;
  70683. private _distortion;
  70684. private _highlightsGain;
  70685. private _highlightsThreshold;
  70686. private _dofDistance;
  70687. private _dofAperture;
  70688. private _dofDarken;
  70689. private _dofPentagon;
  70690. private _blurNoise;
  70691. /**
  70692. * @constructor
  70693. *
  70694. * Effect parameters are as follow:
  70695. * {
  70696. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70697. * edge_blur: number; // from 0 to x (1 for realism)
  70698. * distortion: number; // from 0 to x (1 for realism)
  70699. * grain_amount: number; // from 0 to 1
  70700. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70701. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70702. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70703. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70704. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70705. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70706. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70707. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70708. * }
  70709. * Note: if an effect parameter is unset, effect is disabled
  70710. *
  70711. * @param name The rendering pipeline name
  70712. * @param parameters - An object containing all parameters (see above)
  70713. * @param scene The scene linked to this pipeline
  70714. * @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)
  70715. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70716. */
  70717. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70718. /**
  70719. * Get the class name
  70720. * @returns "LensRenderingPipeline"
  70721. */
  70722. getClassName(): string;
  70723. /**
  70724. * Gets associated scene
  70725. */
  70726. get scene(): Scene;
  70727. /**
  70728. * Gets or sets the edge blur
  70729. */
  70730. get edgeBlur(): number;
  70731. set edgeBlur(value: number);
  70732. /**
  70733. * Gets or sets the grain amount
  70734. */
  70735. get grainAmount(): number;
  70736. set grainAmount(value: number);
  70737. /**
  70738. * Gets or sets the chromatic aberration amount
  70739. */
  70740. get chromaticAberration(): number;
  70741. set chromaticAberration(value: number);
  70742. /**
  70743. * Gets or sets the depth of field aperture
  70744. */
  70745. get dofAperture(): number;
  70746. set dofAperture(value: number);
  70747. /**
  70748. * Gets or sets the edge distortion
  70749. */
  70750. get edgeDistortion(): number;
  70751. set edgeDistortion(value: number);
  70752. /**
  70753. * Gets or sets the depth of field distortion
  70754. */
  70755. get dofDistortion(): number;
  70756. set dofDistortion(value: number);
  70757. /**
  70758. * Gets or sets the darken out of focus amount
  70759. */
  70760. get darkenOutOfFocus(): number;
  70761. set darkenOutOfFocus(value: number);
  70762. /**
  70763. * Gets or sets a boolean indicating if blur noise is enabled
  70764. */
  70765. get blurNoise(): boolean;
  70766. set blurNoise(value: boolean);
  70767. /**
  70768. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70769. */
  70770. get pentagonBokeh(): boolean;
  70771. set pentagonBokeh(value: boolean);
  70772. /**
  70773. * Gets or sets the highlight grain amount
  70774. */
  70775. get highlightsGain(): number;
  70776. set highlightsGain(value: number);
  70777. /**
  70778. * Gets or sets the highlight threshold
  70779. */
  70780. get highlightsThreshold(): number;
  70781. set highlightsThreshold(value: number);
  70782. /**
  70783. * Sets the amount of blur at the edges
  70784. * @param amount blur amount
  70785. */
  70786. setEdgeBlur(amount: number): void;
  70787. /**
  70788. * Sets edge blur to 0
  70789. */
  70790. disableEdgeBlur(): void;
  70791. /**
  70792. * Sets the amout of grain
  70793. * @param amount Amount of grain
  70794. */
  70795. setGrainAmount(amount: number): void;
  70796. /**
  70797. * Set grain amount to 0
  70798. */
  70799. disableGrain(): void;
  70800. /**
  70801. * Sets the chromatic aberration amount
  70802. * @param amount amount of chromatic aberration
  70803. */
  70804. setChromaticAberration(amount: number): void;
  70805. /**
  70806. * Sets chromatic aberration amount to 0
  70807. */
  70808. disableChromaticAberration(): void;
  70809. /**
  70810. * Sets the EdgeDistortion amount
  70811. * @param amount amount of EdgeDistortion
  70812. */
  70813. setEdgeDistortion(amount: number): void;
  70814. /**
  70815. * Sets edge distortion to 0
  70816. */
  70817. disableEdgeDistortion(): void;
  70818. /**
  70819. * Sets the FocusDistance amount
  70820. * @param amount amount of FocusDistance
  70821. */
  70822. setFocusDistance(amount: number): void;
  70823. /**
  70824. * Disables depth of field
  70825. */
  70826. disableDepthOfField(): void;
  70827. /**
  70828. * Sets the Aperture amount
  70829. * @param amount amount of Aperture
  70830. */
  70831. setAperture(amount: number): void;
  70832. /**
  70833. * Sets the DarkenOutOfFocus amount
  70834. * @param amount amount of DarkenOutOfFocus
  70835. */
  70836. setDarkenOutOfFocus(amount: number): void;
  70837. private _pentagonBokehIsEnabled;
  70838. /**
  70839. * Creates a pentagon bokeh effect
  70840. */
  70841. enablePentagonBokeh(): void;
  70842. /**
  70843. * Disables the pentagon bokeh effect
  70844. */
  70845. disablePentagonBokeh(): void;
  70846. /**
  70847. * Enables noise blur
  70848. */
  70849. enableNoiseBlur(): void;
  70850. /**
  70851. * Disables noise blur
  70852. */
  70853. disableNoiseBlur(): void;
  70854. /**
  70855. * Sets the HighlightsGain amount
  70856. * @param amount amount of HighlightsGain
  70857. */
  70858. setHighlightsGain(amount: number): void;
  70859. /**
  70860. * Sets the HighlightsThreshold amount
  70861. * @param amount amount of HighlightsThreshold
  70862. */
  70863. setHighlightsThreshold(amount: number): void;
  70864. /**
  70865. * Disables highlights
  70866. */
  70867. disableHighlights(): void;
  70868. /**
  70869. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70870. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70871. */
  70872. dispose(disableDepthRender?: boolean): void;
  70873. private _createChromaticAberrationPostProcess;
  70874. private _createHighlightsPostProcess;
  70875. private _createDepthOfFieldPostProcess;
  70876. private _createGrainTexture;
  70877. }
  70878. }
  70879. declare module BABYLON {
  70880. /** @hidden */
  70881. export var ssao2PixelShader: {
  70882. name: string;
  70883. shader: string;
  70884. };
  70885. }
  70886. declare module BABYLON {
  70887. /** @hidden */
  70888. export var ssaoCombinePixelShader: {
  70889. name: string;
  70890. shader: string;
  70891. };
  70892. }
  70893. declare module BABYLON {
  70894. /**
  70895. * Render pipeline to produce ssao effect
  70896. */
  70897. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70898. /**
  70899. * @ignore
  70900. * The PassPostProcess id in the pipeline that contains the original scene color
  70901. */
  70902. SSAOOriginalSceneColorEffect: string;
  70903. /**
  70904. * @ignore
  70905. * The SSAO PostProcess id in the pipeline
  70906. */
  70907. SSAORenderEffect: string;
  70908. /**
  70909. * @ignore
  70910. * The horizontal blur PostProcess id in the pipeline
  70911. */
  70912. SSAOBlurHRenderEffect: string;
  70913. /**
  70914. * @ignore
  70915. * The vertical blur PostProcess id in the pipeline
  70916. */
  70917. SSAOBlurVRenderEffect: string;
  70918. /**
  70919. * @ignore
  70920. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70921. */
  70922. SSAOCombineRenderEffect: string;
  70923. /**
  70924. * The output strength of the SSAO post-process. Default value is 1.0.
  70925. */
  70926. totalStrength: number;
  70927. /**
  70928. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70929. */
  70930. maxZ: number;
  70931. /**
  70932. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70933. */
  70934. minZAspect: number;
  70935. private _samples;
  70936. /**
  70937. * Number of samples used for the SSAO calculations. Default value is 8
  70938. */
  70939. set samples(n: number);
  70940. get samples(): number;
  70941. private _textureSamples;
  70942. /**
  70943. * Number of samples to use for antialiasing
  70944. */
  70945. set textureSamples(n: number);
  70946. get textureSamples(): number;
  70947. /**
  70948. * Force rendering the geometry through geometry buffer
  70949. */
  70950. private _forceGeometryBuffer;
  70951. /**
  70952. * Ratio object used for SSAO ratio and blur ratio
  70953. */
  70954. private _ratio;
  70955. /**
  70956. * Dynamically generated sphere sampler.
  70957. */
  70958. private _sampleSphere;
  70959. /**
  70960. * Blur filter offsets
  70961. */
  70962. private _samplerOffsets;
  70963. private _expensiveBlur;
  70964. /**
  70965. * If bilateral blur should be used
  70966. */
  70967. set expensiveBlur(b: boolean);
  70968. get expensiveBlur(): boolean;
  70969. /**
  70970. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70971. */
  70972. radius: number;
  70973. /**
  70974. * The base color of the SSAO post-process
  70975. * The final result is "base + ssao" between [0, 1]
  70976. */
  70977. base: number;
  70978. /**
  70979. * Support test.
  70980. */
  70981. static get IsSupported(): boolean;
  70982. private _scene;
  70983. private _randomTexture;
  70984. private _originalColorPostProcess;
  70985. private _ssaoPostProcess;
  70986. private _blurHPostProcess;
  70987. private _blurVPostProcess;
  70988. private _ssaoCombinePostProcess;
  70989. private _prePassRenderer;
  70990. /**
  70991. * Gets active scene
  70992. */
  70993. get scene(): Scene;
  70994. /**
  70995. * @constructor
  70996. * @param name The rendering pipeline name
  70997. * @param scene The scene linked to this pipeline
  70998. * @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 }
  70999. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71000. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71001. */
  71002. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71003. /**
  71004. * Get the class name
  71005. * @returns "SSAO2RenderingPipeline"
  71006. */
  71007. getClassName(): string;
  71008. /**
  71009. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71010. */
  71011. dispose(disableGeometryBufferRenderer?: boolean): void;
  71012. private _createBlurPostProcess;
  71013. /** @hidden */
  71014. _rebuild(): void;
  71015. private _bits;
  71016. private _radicalInverse_VdC;
  71017. private _hammersley;
  71018. private _hemisphereSample_uniform;
  71019. private _generateHemisphere;
  71020. private _getDefinesForSSAO;
  71021. private _createSSAOPostProcess;
  71022. private _createSSAOCombinePostProcess;
  71023. private _createRandomTexture;
  71024. /**
  71025. * Serialize the rendering pipeline (Used when exporting)
  71026. * @returns the serialized object
  71027. */
  71028. serialize(): any;
  71029. /**
  71030. * Parse the serialized pipeline
  71031. * @param source Source pipeline.
  71032. * @param scene The scene to load the pipeline to.
  71033. * @param rootUrl The URL of the serialized pipeline.
  71034. * @returns An instantiated pipeline from the serialized object.
  71035. */
  71036. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71037. /**
  71038. * Sets the required values to the prepass renderer.
  71039. * @param prePassRenderer defines the prepass renderer to setup
  71040. * @returns true if the pre pass is needed.
  71041. */
  71042. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71043. }
  71044. }
  71045. declare module BABYLON {
  71046. /** @hidden */
  71047. export var ssaoPixelShader: {
  71048. name: string;
  71049. shader: string;
  71050. };
  71051. }
  71052. declare module BABYLON {
  71053. /**
  71054. * Render pipeline to produce ssao effect
  71055. */
  71056. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71057. /**
  71058. * @ignore
  71059. * The PassPostProcess id in the pipeline that contains the original scene color
  71060. */
  71061. SSAOOriginalSceneColorEffect: string;
  71062. /**
  71063. * @ignore
  71064. * The SSAO PostProcess id in the pipeline
  71065. */
  71066. SSAORenderEffect: string;
  71067. /**
  71068. * @ignore
  71069. * The horizontal blur PostProcess id in the pipeline
  71070. */
  71071. SSAOBlurHRenderEffect: string;
  71072. /**
  71073. * @ignore
  71074. * The vertical blur PostProcess id in the pipeline
  71075. */
  71076. SSAOBlurVRenderEffect: string;
  71077. /**
  71078. * @ignore
  71079. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71080. */
  71081. SSAOCombineRenderEffect: string;
  71082. /**
  71083. * The output strength of the SSAO post-process. Default value is 1.0.
  71084. */
  71085. totalStrength: number;
  71086. /**
  71087. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71088. */
  71089. radius: number;
  71090. /**
  71091. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71092. * Must not be equal to fallOff and superior to fallOff.
  71093. * Default value is 0.0075
  71094. */
  71095. area: number;
  71096. /**
  71097. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71098. * Must not be equal to area and inferior to area.
  71099. * Default value is 0.000001
  71100. */
  71101. fallOff: number;
  71102. /**
  71103. * The base color of the SSAO post-process
  71104. * The final result is "base + ssao" between [0, 1]
  71105. */
  71106. base: number;
  71107. private _scene;
  71108. private _depthTexture;
  71109. private _randomTexture;
  71110. private _originalColorPostProcess;
  71111. private _ssaoPostProcess;
  71112. private _blurHPostProcess;
  71113. private _blurVPostProcess;
  71114. private _ssaoCombinePostProcess;
  71115. private _firstUpdate;
  71116. /**
  71117. * Gets active scene
  71118. */
  71119. get scene(): Scene;
  71120. /**
  71121. * @constructor
  71122. * @param name - The rendering pipeline name
  71123. * @param scene - The scene linked to this pipeline
  71124. * @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 }
  71125. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71126. */
  71127. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71128. /**
  71129. * Get the class name
  71130. * @returns "SSAORenderingPipeline"
  71131. */
  71132. getClassName(): string;
  71133. /**
  71134. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71135. */
  71136. dispose(disableDepthRender?: boolean): void;
  71137. private _createBlurPostProcess;
  71138. /** @hidden */
  71139. _rebuild(): void;
  71140. private _createSSAOPostProcess;
  71141. private _createSSAOCombinePostProcess;
  71142. private _createRandomTexture;
  71143. }
  71144. }
  71145. declare module BABYLON {
  71146. /** @hidden */
  71147. export var screenSpaceReflectionPixelShader: {
  71148. name: string;
  71149. shader: string;
  71150. };
  71151. }
  71152. declare module BABYLON {
  71153. /**
  71154. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71155. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71156. */
  71157. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71158. /**
  71159. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71160. */
  71161. threshold: number;
  71162. /**
  71163. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71164. */
  71165. strength: number;
  71166. /**
  71167. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71168. */
  71169. reflectionSpecularFalloffExponent: number;
  71170. /**
  71171. * 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]
  71172. */
  71173. step: number;
  71174. /**
  71175. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71176. */
  71177. roughnessFactor: number;
  71178. private _geometryBufferRenderer;
  71179. private _enableSmoothReflections;
  71180. private _reflectionSamples;
  71181. private _smoothSteps;
  71182. /**
  71183. * Gets a string identifying the name of the class
  71184. * @returns "ScreenSpaceReflectionPostProcess" string
  71185. */
  71186. getClassName(): string;
  71187. /**
  71188. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71189. * @param name The name of the effect.
  71190. * @param scene The scene containing the objects to calculate reflections.
  71191. * @param options The required width/height ratio to downsize to before computing the render pass.
  71192. * @param camera The camera to apply the render pass to.
  71193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71194. * @param engine The engine which the post process will be applied. (default: current engine)
  71195. * @param reusable If the post process can be reused on the same frame. (default: false)
  71196. * @param textureType Type of textures used when performing the post process. (default: 0)
  71197. * @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)
  71198. */
  71199. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71200. /**
  71201. * Gets wether or not smoothing reflections is enabled.
  71202. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71203. */
  71204. get enableSmoothReflections(): boolean;
  71205. /**
  71206. * Sets wether or not smoothing reflections is enabled.
  71207. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71208. */
  71209. set enableSmoothReflections(enabled: boolean);
  71210. /**
  71211. * Gets the number of samples taken while computing reflections. More samples count is high,
  71212. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71213. */
  71214. get reflectionSamples(): number;
  71215. /**
  71216. * Sets the number of samples taken while computing reflections. More samples count is high,
  71217. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71218. */
  71219. set reflectionSamples(samples: number);
  71220. /**
  71221. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71222. * more the post-process will require GPU power and can generate a drop in FPS.
  71223. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71224. */
  71225. get smoothSteps(): number;
  71226. set smoothSteps(steps: number);
  71227. private _updateEffectDefines;
  71228. /** @hidden */
  71229. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71230. }
  71231. }
  71232. declare module BABYLON {
  71233. /** @hidden */
  71234. export var standardPixelShader: {
  71235. name: string;
  71236. shader: string;
  71237. };
  71238. }
  71239. declare module BABYLON {
  71240. /**
  71241. * Standard rendering pipeline
  71242. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71243. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71244. */
  71245. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71246. /**
  71247. * Public members
  71248. */
  71249. /**
  71250. * Post-process which contains the original scene color before the pipeline applies all the effects
  71251. */
  71252. originalPostProcess: Nullable<PostProcess>;
  71253. /**
  71254. * Post-process used to down scale an image x4
  71255. */
  71256. downSampleX4PostProcess: Nullable<PostProcess>;
  71257. /**
  71258. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71259. */
  71260. brightPassPostProcess: Nullable<PostProcess>;
  71261. /**
  71262. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71263. */
  71264. blurHPostProcesses: PostProcess[];
  71265. /**
  71266. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71267. */
  71268. blurVPostProcesses: PostProcess[];
  71269. /**
  71270. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71271. */
  71272. textureAdderPostProcess: Nullable<PostProcess>;
  71273. /**
  71274. * Post-process used to create volumetric lighting effect
  71275. */
  71276. volumetricLightPostProcess: Nullable<PostProcess>;
  71277. /**
  71278. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71279. */
  71280. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71281. /**
  71282. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71283. */
  71284. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71285. /**
  71286. * Post-process used to merge the volumetric light effect and the real scene color
  71287. */
  71288. volumetricLightMergePostProces: Nullable<PostProcess>;
  71289. /**
  71290. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71291. */
  71292. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71293. /**
  71294. * Base post-process used to calculate the average luminance of the final image for HDR
  71295. */
  71296. luminancePostProcess: Nullable<PostProcess>;
  71297. /**
  71298. * Post-processes used to create down sample post-processes in order to get
  71299. * the average luminance of the final image for HDR
  71300. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71301. */
  71302. luminanceDownSamplePostProcesses: PostProcess[];
  71303. /**
  71304. * Post-process used to create a HDR effect (light adaptation)
  71305. */
  71306. hdrPostProcess: Nullable<PostProcess>;
  71307. /**
  71308. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71309. */
  71310. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71311. /**
  71312. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71313. */
  71314. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71315. /**
  71316. * Post-process used to merge the final HDR post-process and the real scene color
  71317. */
  71318. hdrFinalPostProcess: Nullable<PostProcess>;
  71319. /**
  71320. * Post-process used to create a lens flare effect
  71321. */
  71322. lensFlarePostProcess: Nullable<PostProcess>;
  71323. /**
  71324. * Post-process that merges the result of the lens flare post-process and the real scene color
  71325. */
  71326. lensFlareComposePostProcess: Nullable<PostProcess>;
  71327. /**
  71328. * Post-process used to create a motion blur effect
  71329. */
  71330. motionBlurPostProcess: Nullable<PostProcess>;
  71331. /**
  71332. * Post-process used to create a depth of field effect
  71333. */
  71334. depthOfFieldPostProcess: Nullable<PostProcess>;
  71335. /**
  71336. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71337. */
  71338. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71339. /**
  71340. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71341. */
  71342. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71343. /**
  71344. * Represents the brightness threshold in order to configure the illuminated surfaces
  71345. */
  71346. brightThreshold: number;
  71347. /**
  71348. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71349. */
  71350. blurWidth: number;
  71351. /**
  71352. * Sets if the blur for highlighted surfaces must be only horizontal
  71353. */
  71354. horizontalBlur: boolean;
  71355. /**
  71356. * Gets the overall exposure used by the pipeline
  71357. */
  71358. get exposure(): number;
  71359. /**
  71360. * Sets the overall exposure used by the pipeline
  71361. */
  71362. set exposure(value: number);
  71363. /**
  71364. * Texture used typically to simulate "dirty" on camera lens
  71365. */
  71366. lensTexture: Nullable<Texture>;
  71367. /**
  71368. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71369. */
  71370. volumetricLightCoefficient: number;
  71371. /**
  71372. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71373. */
  71374. volumetricLightPower: number;
  71375. /**
  71376. * Used the set the blur intensity to smooth the volumetric lights
  71377. */
  71378. volumetricLightBlurScale: number;
  71379. /**
  71380. * Light (spot or directional) used to generate the volumetric lights rays
  71381. * The source light must have a shadow generate so the pipeline can get its
  71382. * depth map
  71383. */
  71384. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71385. /**
  71386. * For eye adaptation, represents the minimum luminance the eye can see
  71387. */
  71388. hdrMinimumLuminance: number;
  71389. /**
  71390. * For eye adaptation, represents the decrease luminance speed
  71391. */
  71392. hdrDecreaseRate: number;
  71393. /**
  71394. * For eye adaptation, represents the increase luminance speed
  71395. */
  71396. hdrIncreaseRate: number;
  71397. /**
  71398. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71399. */
  71400. get hdrAutoExposure(): boolean;
  71401. /**
  71402. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71403. */
  71404. set hdrAutoExposure(value: boolean);
  71405. /**
  71406. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71407. */
  71408. lensColorTexture: Nullable<Texture>;
  71409. /**
  71410. * The overall strengh for the lens flare effect
  71411. */
  71412. lensFlareStrength: number;
  71413. /**
  71414. * Dispersion coefficient for lens flare ghosts
  71415. */
  71416. lensFlareGhostDispersal: number;
  71417. /**
  71418. * Main lens flare halo width
  71419. */
  71420. lensFlareHaloWidth: number;
  71421. /**
  71422. * Based on the lens distortion effect, defines how much the lens flare result
  71423. * is distorted
  71424. */
  71425. lensFlareDistortionStrength: number;
  71426. /**
  71427. * Configures the blur intensity used for for lens flare (halo)
  71428. */
  71429. lensFlareBlurWidth: number;
  71430. /**
  71431. * Lens star texture must be used to simulate rays on the flares and is available
  71432. * in the documentation
  71433. */
  71434. lensStarTexture: Nullable<Texture>;
  71435. /**
  71436. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71437. * flare effect by taking account of the dirt texture
  71438. */
  71439. lensFlareDirtTexture: Nullable<Texture>;
  71440. /**
  71441. * Represents the focal length for the depth of field effect
  71442. */
  71443. depthOfFieldDistance: number;
  71444. /**
  71445. * Represents the blur intensity for the blurred part of the depth of field effect
  71446. */
  71447. depthOfFieldBlurWidth: number;
  71448. /**
  71449. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71450. */
  71451. get motionStrength(): number;
  71452. /**
  71453. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71454. */
  71455. set motionStrength(strength: number);
  71456. /**
  71457. * Gets wether or not the motion blur post-process is object based or screen based.
  71458. */
  71459. get objectBasedMotionBlur(): boolean;
  71460. /**
  71461. * Sets wether or not the motion blur post-process should be object based or screen based
  71462. */
  71463. set objectBasedMotionBlur(value: boolean);
  71464. /**
  71465. * List of animations for the pipeline (IAnimatable implementation)
  71466. */
  71467. animations: Animation[];
  71468. /**
  71469. * Private members
  71470. */
  71471. private _scene;
  71472. private _currentDepthOfFieldSource;
  71473. private _basePostProcess;
  71474. private _fixedExposure;
  71475. private _currentExposure;
  71476. private _hdrAutoExposure;
  71477. private _hdrCurrentLuminance;
  71478. private _motionStrength;
  71479. private _isObjectBasedMotionBlur;
  71480. private _floatTextureType;
  71481. private _camerasToBeAttached;
  71482. private _ratio;
  71483. private _bloomEnabled;
  71484. private _depthOfFieldEnabled;
  71485. private _vlsEnabled;
  71486. private _lensFlareEnabled;
  71487. private _hdrEnabled;
  71488. private _motionBlurEnabled;
  71489. private _fxaaEnabled;
  71490. private _screenSpaceReflectionsEnabled;
  71491. private _motionBlurSamples;
  71492. private _volumetricLightStepsCount;
  71493. private _samples;
  71494. /**
  71495. * @ignore
  71496. * Specifies if the bloom pipeline is enabled
  71497. */
  71498. get BloomEnabled(): boolean;
  71499. set BloomEnabled(enabled: boolean);
  71500. /**
  71501. * @ignore
  71502. * Specifies if the depth of field pipeline is enabed
  71503. */
  71504. get DepthOfFieldEnabled(): boolean;
  71505. set DepthOfFieldEnabled(enabled: boolean);
  71506. /**
  71507. * @ignore
  71508. * Specifies if the lens flare pipeline is enabed
  71509. */
  71510. get LensFlareEnabled(): boolean;
  71511. set LensFlareEnabled(enabled: boolean);
  71512. /**
  71513. * @ignore
  71514. * Specifies if the HDR pipeline is enabled
  71515. */
  71516. get HDREnabled(): boolean;
  71517. set HDREnabled(enabled: boolean);
  71518. /**
  71519. * @ignore
  71520. * Specifies if the volumetric lights scattering effect is enabled
  71521. */
  71522. get VLSEnabled(): boolean;
  71523. set VLSEnabled(enabled: boolean);
  71524. /**
  71525. * @ignore
  71526. * Specifies if the motion blur effect is enabled
  71527. */
  71528. get MotionBlurEnabled(): boolean;
  71529. set MotionBlurEnabled(enabled: boolean);
  71530. /**
  71531. * Specifies if anti-aliasing is enabled
  71532. */
  71533. get fxaaEnabled(): boolean;
  71534. set fxaaEnabled(enabled: boolean);
  71535. /**
  71536. * Specifies if screen space reflections are enabled.
  71537. */
  71538. get screenSpaceReflectionsEnabled(): boolean;
  71539. set screenSpaceReflectionsEnabled(enabled: boolean);
  71540. /**
  71541. * Specifies the number of steps used to calculate the volumetric lights
  71542. * Typically in interval [50, 200]
  71543. */
  71544. get volumetricLightStepsCount(): number;
  71545. set volumetricLightStepsCount(count: number);
  71546. /**
  71547. * Specifies the number of samples used for the motion blur effect
  71548. * Typically in interval [16, 64]
  71549. */
  71550. get motionBlurSamples(): number;
  71551. set motionBlurSamples(samples: number);
  71552. /**
  71553. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71554. */
  71555. get samples(): number;
  71556. set samples(sampleCount: number);
  71557. /**
  71558. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71559. * @constructor
  71560. * @param name The rendering pipeline name
  71561. * @param scene The scene linked to this pipeline
  71562. * @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)
  71563. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71564. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71565. */
  71566. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71567. private _buildPipeline;
  71568. private _createDownSampleX4PostProcess;
  71569. private _createBrightPassPostProcess;
  71570. private _createBlurPostProcesses;
  71571. private _createTextureAdderPostProcess;
  71572. private _createVolumetricLightPostProcess;
  71573. private _createLuminancePostProcesses;
  71574. private _createHdrPostProcess;
  71575. private _createLensFlarePostProcess;
  71576. private _createDepthOfFieldPostProcess;
  71577. private _createMotionBlurPostProcess;
  71578. private _getDepthTexture;
  71579. private _disposePostProcesses;
  71580. /**
  71581. * Dispose of the pipeline and stop all post processes
  71582. */
  71583. dispose(): void;
  71584. /**
  71585. * Serialize the rendering pipeline (Used when exporting)
  71586. * @returns the serialized object
  71587. */
  71588. serialize(): any;
  71589. /**
  71590. * Parse the serialized pipeline
  71591. * @param source Source pipeline.
  71592. * @param scene The scene to load the pipeline to.
  71593. * @param rootUrl The URL of the serialized pipeline.
  71594. * @returns An instantiated pipeline from the serialized object.
  71595. */
  71596. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71597. /**
  71598. * Luminance steps
  71599. */
  71600. static LuminanceSteps: number;
  71601. }
  71602. }
  71603. declare module BABYLON {
  71604. /** @hidden */
  71605. export var stereoscopicInterlacePixelShader: {
  71606. name: string;
  71607. shader: string;
  71608. };
  71609. }
  71610. declare module BABYLON {
  71611. /**
  71612. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71613. */
  71614. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71615. private _stepSize;
  71616. private _passedProcess;
  71617. /**
  71618. * Gets a string identifying the name of the class
  71619. * @returns "StereoscopicInterlacePostProcessI" string
  71620. */
  71621. getClassName(): string;
  71622. /**
  71623. * Initializes a StereoscopicInterlacePostProcessI
  71624. * @param name The name of the effect.
  71625. * @param rigCameras The rig cameras to be appled to the post process
  71626. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71627. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71629. * @param engine The engine which the post process will be applied. (default: current engine)
  71630. * @param reusable If the post process can be reused on the same frame. (default: false)
  71631. */
  71632. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71633. }
  71634. /**
  71635. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71636. */
  71637. export class StereoscopicInterlacePostProcess extends PostProcess {
  71638. private _stepSize;
  71639. private _passedProcess;
  71640. /**
  71641. * Gets a string identifying the name of the class
  71642. * @returns "StereoscopicInterlacePostProcess" string
  71643. */
  71644. getClassName(): string;
  71645. /**
  71646. * Initializes a StereoscopicInterlacePostProcess
  71647. * @param name The name of the effect.
  71648. * @param rigCameras The rig cameras to be appled to the post process
  71649. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71651. * @param engine The engine which the post process will be applied. (default: current engine)
  71652. * @param reusable If the post process can be reused on the same frame. (default: false)
  71653. */
  71654. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71655. }
  71656. }
  71657. declare module BABYLON {
  71658. /** @hidden */
  71659. export var tonemapPixelShader: {
  71660. name: string;
  71661. shader: string;
  71662. };
  71663. }
  71664. declare module BABYLON {
  71665. /** Defines operator used for tonemapping */
  71666. export enum TonemappingOperator {
  71667. /** Hable */
  71668. Hable = 0,
  71669. /** Reinhard */
  71670. Reinhard = 1,
  71671. /** HejiDawson */
  71672. HejiDawson = 2,
  71673. /** Photographic */
  71674. Photographic = 3
  71675. }
  71676. /**
  71677. * Defines a post process to apply tone mapping
  71678. */
  71679. export class TonemapPostProcess extends PostProcess {
  71680. private _operator;
  71681. /** Defines the required exposure adjustement */
  71682. exposureAdjustment: number;
  71683. /**
  71684. * Gets a string identifying the name of the class
  71685. * @returns "TonemapPostProcess" string
  71686. */
  71687. getClassName(): string;
  71688. /**
  71689. * Creates a new TonemapPostProcess
  71690. * @param name defines the name of the postprocess
  71691. * @param _operator defines the operator to use
  71692. * @param exposureAdjustment defines the required exposure adjustement
  71693. * @param camera defines the camera to use (can be null)
  71694. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71695. * @param engine defines the hosting engine (can be ignore if camera is set)
  71696. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71697. */
  71698. constructor(name: string, _operator: TonemappingOperator,
  71699. /** Defines the required exposure adjustement */
  71700. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71701. }
  71702. }
  71703. declare module BABYLON {
  71704. /** @hidden */
  71705. export var volumetricLightScatteringPixelShader: {
  71706. name: string;
  71707. shader: string;
  71708. };
  71709. }
  71710. declare module BABYLON {
  71711. /** @hidden */
  71712. export var volumetricLightScatteringPassVertexShader: {
  71713. name: string;
  71714. shader: string;
  71715. };
  71716. }
  71717. declare module BABYLON {
  71718. /** @hidden */
  71719. export var volumetricLightScatteringPassPixelShader: {
  71720. name: string;
  71721. shader: string;
  71722. };
  71723. }
  71724. declare module BABYLON {
  71725. /**
  71726. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71727. */
  71728. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71729. private _volumetricLightScatteringPass;
  71730. private _volumetricLightScatteringRTT;
  71731. private _viewPort;
  71732. private _screenCoordinates;
  71733. private _cachedDefines;
  71734. /**
  71735. * If not undefined, the mesh position is computed from the attached node position
  71736. */
  71737. attachedNode: {
  71738. position: Vector3;
  71739. };
  71740. /**
  71741. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71742. */
  71743. customMeshPosition: Vector3;
  71744. /**
  71745. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71746. */
  71747. useCustomMeshPosition: boolean;
  71748. /**
  71749. * If the post-process should inverse the light scattering direction
  71750. */
  71751. invert: boolean;
  71752. /**
  71753. * The internal mesh used by the post-process
  71754. */
  71755. mesh: Mesh;
  71756. /**
  71757. * @hidden
  71758. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71759. */
  71760. get useDiffuseColor(): boolean;
  71761. set useDiffuseColor(useDiffuseColor: boolean);
  71762. /**
  71763. * Array containing the excluded meshes not rendered in the internal pass
  71764. */
  71765. excludedMeshes: AbstractMesh[];
  71766. /**
  71767. * Controls the overall intensity of the post-process
  71768. */
  71769. exposure: number;
  71770. /**
  71771. * Dissipates each sample's contribution in range [0, 1]
  71772. */
  71773. decay: number;
  71774. /**
  71775. * Controls the overall intensity of each sample
  71776. */
  71777. weight: number;
  71778. /**
  71779. * Controls the density of each sample
  71780. */
  71781. density: number;
  71782. /**
  71783. * @constructor
  71784. * @param name The post-process name
  71785. * @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)
  71786. * @param camera The camera that the post-process will be attached to
  71787. * @param mesh The mesh used to create the light scattering
  71788. * @param samples The post-process quality, default 100
  71789. * @param samplingModeThe post-process filtering mode
  71790. * @param engine The babylon engine
  71791. * @param reusable If the post-process is reusable
  71792. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71793. */
  71794. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71795. /**
  71796. * Returns the string "VolumetricLightScatteringPostProcess"
  71797. * @returns "VolumetricLightScatteringPostProcess"
  71798. */
  71799. getClassName(): string;
  71800. private _isReady;
  71801. /**
  71802. * Sets the new light position for light scattering effect
  71803. * @param position The new custom light position
  71804. */
  71805. setCustomMeshPosition(position: Vector3): void;
  71806. /**
  71807. * Returns the light position for light scattering effect
  71808. * @return Vector3 The custom light position
  71809. */
  71810. getCustomMeshPosition(): Vector3;
  71811. /**
  71812. * Disposes the internal assets and detaches the post-process from the camera
  71813. */
  71814. dispose(camera: Camera): void;
  71815. /**
  71816. * Returns the render target texture used by the post-process
  71817. * @return the render target texture used by the post-process
  71818. */
  71819. getPass(): RenderTargetTexture;
  71820. private _meshExcluded;
  71821. private _createPass;
  71822. private _updateMeshScreenCoordinates;
  71823. /**
  71824. * Creates a default mesh for the Volumeric Light Scattering post-process
  71825. * @param name The mesh name
  71826. * @param scene The scene where to create the mesh
  71827. * @return the default mesh
  71828. */
  71829. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71830. }
  71831. }
  71832. declare module BABYLON {
  71833. /** @hidden */
  71834. export var screenSpaceCurvaturePixelShader: {
  71835. name: string;
  71836. shader: string;
  71837. };
  71838. }
  71839. declare module BABYLON {
  71840. /**
  71841. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71842. */
  71843. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71844. /**
  71845. * Defines how much ridge the curvature effect displays.
  71846. */
  71847. ridge: number;
  71848. /**
  71849. * Defines how much valley the curvature effect displays.
  71850. */
  71851. valley: number;
  71852. private _geometryBufferRenderer;
  71853. /**
  71854. * Gets a string identifying the name of the class
  71855. * @returns "ScreenSpaceCurvaturePostProcess" string
  71856. */
  71857. getClassName(): string;
  71858. /**
  71859. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71860. * @param name The name of the effect.
  71861. * @param scene The scene containing the objects to blur according to their velocity.
  71862. * @param options The required width/height ratio to downsize to before computing the render pass.
  71863. * @param camera The camera to apply the render pass to.
  71864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71865. * @param engine The engine which the post process will be applied. (default: current engine)
  71866. * @param reusable If the post process can be reused on the same frame. (default: false)
  71867. * @param textureType Type of textures used when performing the post process. (default: 0)
  71868. * @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)
  71869. */
  71870. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71871. /**
  71872. * Support test.
  71873. */
  71874. static get IsSupported(): boolean;
  71875. /** @hidden */
  71876. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71877. }
  71878. }
  71879. declare module BABYLON {
  71880. interface Scene {
  71881. /** @hidden (Backing field) */
  71882. _boundingBoxRenderer: BoundingBoxRenderer;
  71883. /** @hidden (Backing field) */
  71884. _forceShowBoundingBoxes: boolean;
  71885. /**
  71886. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71887. */
  71888. forceShowBoundingBoxes: boolean;
  71889. /**
  71890. * Gets the bounding box renderer associated with the scene
  71891. * @returns a BoundingBoxRenderer
  71892. */
  71893. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71894. }
  71895. interface AbstractMesh {
  71896. /** @hidden (Backing field) */
  71897. _showBoundingBox: boolean;
  71898. /**
  71899. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71900. */
  71901. showBoundingBox: boolean;
  71902. }
  71903. /**
  71904. * Component responsible of rendering the bounding box of the meshes in a scene.
  71905. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71906. */
  71907. export class BoundingBoxRenderer implements ISceneComponent {
  71908. /**
  71909. * The component name helpfull to identify the component in the list of scene components.
  71910. */
  71911. readonly name: string;
  71912. /**
  71913. * The scene the component belongs to.
  71914. */
  71915. scene: Scene;
  71916. /**
  71917. * Color of the bounding box lines placed in front of an object
  71918. */
  71919. frontColor: Color3;
  71920. /**
  71921. * Color of the bounding box lines placed behind an object
  71922. */
  71923. backColor: Color3;
  71924. /**
  71925. * Defines if the renderer should show the back lines or not
  71926. */
  71927. showBackLines: boolean;
  71928. /**
  71929. * Observable raised before rendering a bounding box
  71930. */
  71931. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71932. /**
  71933. * Observable raised after rendering a bounding box
  71934. */
  71935. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71936. /**
  71937. * @hidden
  71938. */
  71939. renderList: SmartArray<BoundingBox>;
  71940. private _colorShader;
  71941. private _vertexBuffers;
  71942. private _indexBuffer;
  71943. private _fillIndexBuffer;
  71944. private _fillIndexData;
  71945. /**
  71946. * Instantiates a new bounding box renderer in a scene.
  71947. * @param scene the scene the renderer renders in
  71948. */
  71949. constructor(scene: Scene);
  71950. /**
  71951. * Registers the component in a given scene
  71952. */
  71953. register(): void;
  71954. private _evaluateSubMesh;
  71955. private _activeMesh;
  71956. private _prepareRessources;
  71957. private _createIndexBuffer;
  71958. /**
  71959. * Rebuilds the elements related to this component in case of
  71960. * context lost for instance.
  71961. */
  71962. rebuild(): void;
  71963. /**
  71964. * @hidden
  71965. */
  71966. reset(): void;
  71967. /**
  71968. * Render the bounding boxes of a specific rendering group
  71969. * @param renderingGroupId defines the rendering group to render
  71970. */
  71971. render(renderingGroupId: number): void;
  71972. /**
  71973. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71974. * @param mesh Define the mesh to render the occlusion bounding box for
  71975. */
  71976. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71977. /**
  71978. * Dispose and release the resources attached to this renderer.
  71979. */
  71980. dispose(): void;
  71981. }
  71982. }
  71983. declare module BABYLON {
  71984. interface Scene {
  71985. /** @hidden (Backing field) */
  71986. _depthRenderer: {
  71987. [id: string]: DepthRenderer;
  71988. };
  71989. /**
  71990. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71991. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71992. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71993. * @returns the created depth renderer
  71994. */
  71995. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71996. /**
  71997. * Disables a depth renderer for a given camera
  71998. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71999. */
  72000. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72001. }
  72002. /**
  72003. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72004. * in several rendering techniques.
  72005. */
  72006. export class DepthRendererSceneComponent implements ISceneComponent {
  72007. /**
  72008. * The component name helpfull to identify the component in the list of scene components.
  72009. */
  72010. readonly name: string;
  72011. /**
  72012. * The scene the component belongs to.
  72013. */
  72014. scene: Scene;
  72015. /**
  72016. * Creates a new instance of the component for the given scene
  72017. * @param scene Defines the scene to register the component in
  72018. */
  72019. constructor(scene: Scene);
  72020. /**
  72021. * Registers the component in a given scene
  72022. */
  72023. register(): void;
  72024. /**
  72025. * Rebuilds the elements related to this component in case of
  72026. * context lost for instance.
  72027. */
  72028. rebuild(): void;
  72029. /**
  72030. * Disposes the component and the associated ressources
  72031. */
  72032. dispose(): void;
  72033. private _gatherRenderTargets;
  72034. private _gatherActiveCameraRenderTargets;
  72035. }
  72036. }
  72037. declare module BABYLON {
  72038. interface AbstractScene {
  72039. /** @hidden (Backing field) */
  72040. _prePassRenderer: Nullable<PrePassRenderer>;
  72041. /**
  72042. * Gets or Sets the current prepass renderer associated to the scene.
  72043. */
  72044. prePassRenderer: Nullable<PrePassRenderer>;
  72045. /**
  72046. * Enables the prepass and associates it with the scene
  72047. * @returns the PrePassRenderer
  72048. */
  72049. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72050. /**
  72051. * Disables the prepass associated with the scene
  72052. */
  72053. disablePrePassRenderer(): void;
  72054. }
  72055. /**
  72056. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72057. * in several rendering techniques.
  72058. */
  72059. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  72060. /**
  72061. * The component name helpful to identify the component in the list of scene components.
  72062. */
  72063. readonly name: string;
  72064. /**
  72065. * The scene the component belongs to.
  72066. */
  72067. scene: Scene;
  72068. /**
  72069. * Creates a new instance of the component for the given scene
  72070. * @param scene Defines the scene to register the component in
  72071. */
  72072. constructor(scene: Scene);
  72073. /**
  72074. * Registers the component in a given scene
  72075. */
  72076. register(): void;
  72077. private _beforeCameraDraw;
  72078. private _afterCameraDraw;
  72079. private _beforeClearStage;
  72080. /**
  72081. * Serializes the component data to the specified json object
  72082. * @param serializationObject The object to serialize to
  72083. */
  72084. serialize(serializationObject: any): void;
  72085. /**
  72086. * Adds all the elements from the container to the scene
  72087. * @param container the container holding the elements
  72088. */
  72089. addFromContainer(container: AbstractScene): void;
  72090. /**
  72091. * Removes all the elements in the container from the scene
  72092. * @param container contains the elements to remove
  72093. * @param dispose if the removed element should be disposed (default: false)
  72094. */
  72095. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72096. /**
  72097. * Rebuilds the elements related to this component in case of
  72098. * context lost for instance.
  72099. */
  72100. rebuild(): void;
  72101. /**
  72102. * Disposes the component and the associated ressources
  72103. */
  72104. dispose(): void;
  72105. }
  72106. }
  72107. declare module BABYLON {
  72108. /** @hidden */
  72109. export var outlinePixelShader: {
  72110. name: string;
  72111. shader: string;
  72112. };
  72113. }
  72114. declare module BABYLON {
  72115. /** @hidden */
  72116. export var outlineVertexShader: {
  72117. name: string;
  72118. shader: string;
  72119. };
  72120. }
  72121. declare module BABYLON {
  72122. interface Scene {
  72123. /** @hidden */
  72124. _outlineRenderer: OutlineRenderer;
  72125. /**
  72126. * Gets the outline renderer associated with the scene
  72127. * @returns a OutlineRenderer
  72128. */
  72129. getOutlineRenderer(): OutlineRenderer;
  72130. }
  72131. interface AbstractMesh {
  72132. /** @hidden (Backing field) */
  72133. _renderOutline: boolean;
  72134. /**
  72135. * Gets or sets a boolean indicating if the outline must be rendered as well
  72136. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72137. */
  72138. renderOutline: boolean;
  72139. /** @hidden (Backing field) */
  72140. _renderOverlay: boolean;
  72141. /**
  72142. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72143. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72144. */
  72145. renderOverlay: boolean;
  72146. }
  72147. /**
  72148. * This class is responsible to draw bothe outline/overlay of meshes.
  72149. * It should not be used directly but through the available method on mesh.
  72150. */
  72151. export class OutlineRenderer implements ISceneComponent {
  72152. /**
  72153. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72154. */
  72155. private static _StencilReference;
  72156. /**
  72157. * The name of the component. Each component must have a unique name.
  72158. */
  72159. name: string;
  72160. /**
  72161. * The scene the component belongs to.
  72162. */
  72163. scene: Scene;
  72164. /**
  72165. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72166. */
  72167. zOffset: number;
  72168. private _engine;
  72169. private _effect;
  72170. private _cachedDefines;
  72171. private _savedDepthWrite;
  72172. /**
  72173. * Instantiates a new outline renderer. (There could be only one per scene).
  72174. * @param scene Defines the scene it belongs to
  72175. */
  72176. constructor(scene: Scene);
  72177. /**
  72178. * Register the component to one instance of a scene.
  72179. */
  72180. register(): void;
  72181. /**
  72182. * Rebuilds the elements related to this component in case of
  72183. * context lost for instance.
  72184. */
  72185. rebuild(): void;
  72186. /**
  72187. * Disposes the component and the associated ressources.
  72188. */
  72189. dispose(): void;
  72190. /**
  72191. * Renders the outline in the canvas.
  72192. * @param subMesh Defines the sumesh to render
  72193. * @param batch Defines the batch of meshes in case of instances
  72194. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72195. */
  72196. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72197. /**
  72198. * Returns whether or not the outline renderer is ready for a given submesh.
  72199. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72200. * @param subMesh Defines the submesh to check readyness for
  72201. * @param useInstances Defines wheter wee are trying to render instances or not
  72202. * @returns true if ready otherwise false
  72203. */
  72204. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72205. private _beforeRenderingMesh;
  72206. private _afterRenderingMesh;
  72207. }
  72208. }
  72209. declare module BABYLON {
  72210. /**
  72211. * Defines the basic options interface of a Sprite Frame Source Size.
  72212. */
  72213. export interface ISpriteJSONSpriteSourceSize {
  72214. /**
  72215. * number of the original width of the Frame
  72216. */
  72217. w: number;
  72218. /**
  72219. * number of the original height of the Frame
  72220. */
  72221. h: number;
  72222. }
  72223. /**
  72224. * Defines the basic options interface of a Sprite Frame Data.
  72225. */
  72226. export interface ISpriteJSONSpriteFrameData {
  72227. /**
  72228. * number of the x offset of the Frame
  72229. */
  72230. x: number;
  72231. /**
  72232. * number of the y offset of the Frame
  72233. */
  72234. y: number;
  72235. /**
  72236. * number of the width of the Frame
  72237. */
  72238. w: number;
  72239. /**
  72240. * number of the height of the Frame
  72241. */
  72242. h: number;
  72243. }
  72244. /**
  72245. * Defines the basic options interface of a JSON Sprite.
  72246. */
  72247. export interface ISpriteJSONSprite {
  72248. /**
  72249. * string name of the Frame
  72250. */
  72251. filename: string;
  72252. /**
  72253. * ISpriteJSONSpriteFrame basic object of the frame data
  72254. */
  72255. frame: ISpriteJSONSpriteFrameData;
  72256. /**
  72257. * boolean to flag is the frame was rotated.
  72258. */
  72259. rotated: boolean;
  72260. /**
  72261. * boolean to flag is the frame was trimmed.
  72262. */
  72263. trimmed: boolean;
  72264. /**
  72265. * ISpriteJSONSpriteFrame basic object of the source data
  72266. */
  72267. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72268. /**
  72269. * ISpriteJSONSpriteFrame basic object of the source data
  72270. */
  72271. sourceSize: ISpriteJSONSpriteSourceSize;
  72272. }
  72273. /**
  72274. * Defines the basic options interface of a JSON atlas.
  72275. */
  72276. export interface ISpriteJSONAtlas {
  72277. /**
  72278. * Array of objects that contain the frame data.
  72279. */
  72280. frames: Array<ISpriteJSONSprite>;
  72281. /**
  72282. * object basic object containing the sprite meta data.
  72283. */
  72284. meta?: object;
  72285. }
  72286. }
  72287. declare module BABYLON {
  72288. /** @hidden */
  72289. export var spriteMapPixelShader: {
  72290. name: string;
  72291. shader: string;
  72292. };
  72293. }
  72294. declare module BABYLON {
  72295. /** @hidden */
  72296. export var spriteMapVertexShader: {
  72297. name: string;
  72298. shader: string;
  72299. };
  72300. }
  72301. declare module BABYLON {
  72302. /**
  72303. * Defines the basic options interface of a SpriteMap
  72304. */
  72305. export interface ISpriteMapOptions {
  72306. /**
  72307. * Vector2 of the number of cells in the grid.
  72308. */
  72309. stageSize?: Vector2;
  72310. /**
  72311. * Vector2 of the size of the output plane in World Units.
  72312. */
  72313. outputSize?: Vector2;
  72314. /**
  72315. * Vector3 of the position of the output plane in World Units.
  72316. */
  72317. outputPosition?: Vector3;
  72318. /**
  72319. * Vector3 of the rotation of the output plane.
  72320. */
  72321. outputRotation?: Vector3;
  72322. /**
  72323. * number of layers that the system will reserve in resources.
  72324. */
  72325. layerCount?: number;
  72326. /**
  72327. * number of max animation frames a single cell will reserve in resources.
  72328. */
  72329. maxAnimationFrames?: number;
  72330. /**
  72331. * number cell index of the base tile when the system compiles.
  72332. */
  72333. baseTile?: number;
  72334. /**
  72335. * boolean flip the sprite after its been repositioned by the framing data.
  72336. */
  72337. flipU?: boolean;
  72338. /**
  72339. * Vector3 scalar of the global RGB values of the SpriteMap.
  72340. */
  72341. colorMultiply?: Vector3;
  72342. }
  72343. /**
  72344. * Defines the IDisposable interface in order to be cleanable from resources.
  72345. */
  72346. export interface ISpriteMap extends IDisposable {
  72347. /**
  72348. * String name of the SpriteMap.
  72349. */
  72350. name: string;
  72351. /**
  72352. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72353. */
  72354. atlasJSON: ISpriteJSONAtlas;
  72355. /**
  72356. * Texture of the SpriteMap.
  72357. */
  72358. spriteSheet: Texture;
  72359. /**
  72360. * The parameters to initialize the SpriteMap with.
  72361. */
  72362. options: ISpriteMapOptions;
  72363. }
  72364. /**
  72365. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72366. */
  72367. export class SpriteMap implements ISpriteMap {
  72368. /** The Name of the spriteMap */
  72369. name: string;
  72370. /** The JSON file with the frame and meta data */
  72371. atlasJSON: ISpriteJSONAtlas;
  72372. /** The systems Sprite Sheet Texture */
  72373. spriteSheet: Texture;
  72374. /** Arguments passed with the Constructor */
  72375. options: ISpriteMapOptions;
  72376. /** Public Sprite Storage array, parsed from atlasJSON */
  72377. sprites: Array<ISpriteJSONSprite>;
  72378. /** Returns the Number of Sprites in the System */
  72379. get spriteCount(): number;
  72380. /** Returns the Position of Output Plane*/
  72381. get position(): Vector3;
  72382. /** Returns the Position of Output Plane*/
  72383. set position(v: Vector3);
  72384. /** Returns the Rotation of Output Plane*/
  72385. get rotation(): Vector3;
  72386. /** Returns the Rotation of Output Plane*/
  72387. set rotation(v: Vector3);
  72388. /** Sets the AnimationMap*/
  72389. get animationMap(): RawTexture;
  72390. /** Sets the AnimationMap*/
  72391. set animationMap(v: RawTexture);
  72392. /** Scene that the SpriteMap was created in */
  72393. private _scene;
  72394. /** Texture Buffer of Float32 that holds tile frame data*/
  72395. private _frameMap;
  72396. /** Texture Buffers of Float32 that holds tileMap data*/
  72397. private _tileMaps;
  72398. /** Texture Buffer of Float32 that holds Animation Data*/
  72399. private _animationMap;
  72400. /** Custom ShaderMaterial Central to the System*/
  72401. private _material;
  72402. /** Custom ShaderMaterial Central to the System*/
  72403. private _output;
  72404. /** Systems Time Ticker*/
  72405. private _time;
  72406. /**
  72407. * Creates a new SpriteMap
  72408. * @param name defines the SpriteMaps Name
  72409. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72410. * @param spriteSheet is the Texture that the Sprites are on.
  72411. * @param options a basic deployment configuration
  72412. * @param scene The Scene that the map is deployed on
  72413. */
  72414. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72415. /**
  72416. * Returns tileID location
  72417. * @returns Vector2 the cell position ID
  72418. */
  72419. getTileID(): Vector2;
  72420. /**
  72421. * Gets the UV location of the mouse over the SpriteMap.
  72422. * @returns Vector2 the UV position of the mouse interaction
  72423. */
  72424. getMousePosition(): Vector2;
  72425. /**
  72426. * Creates the "frame" texture Buffer
  72427. * -------------------------------------
  72428. * Structure of frames
  72429. * "filename": "Falling-Water-2.png",
  72430. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72431. * "rotated": true,
  72432. * "trimmed": true,
  72433. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72434. * "sourceSize": {"w":32,"h":32}
  72435. * @returns RawTexture of the frameMap
  72436. */
  72437. private _createFrameBuffer;
  72438. /**
  72439. * Creates the tileMap texture Buffer
  72440. * @param buffer normally and array of numbers, or a false to generate from scratch
  72441. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72442. * @returns RawTexture of the tileMap
  72443. */
  72444. private _createTileBuffer;
  72445. /**
  72446. * Modifies the data of the tileMaps
  72447. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72448. * @param pos is the iVector2 Coordinates of the Tile
  72449. * @param tile The SpriteIndex of the new Tile
  72450. */
  72451. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72452. /**
  72453. * Creates the animationMap texture Buffer
  72454. * @param buffer normally and array of numbers, or a false to generate from scratch
  72455. * @returns RawTexture of the animationMap
  72456. */
  72457. private _createTileAnimationBuffer;
  72458. /**
  72459. * Modifies the data of the animationMap
  72460. * @param cellID is the Index of the Sprite
  72461. * @param _frame is the target Animation frame
  72462. * @param toCell is the Target Index of the next frame of the animation
  72463. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72464. * @param speed is a global scalar of the time variable on the map.
  72465. */
  72466. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72467. /**
  72468. * Exports the .tilemaps file
  72469. */
  72470. saveTileMaps(): void;
  72471. /**
  72472. * Imports the .tilemaps file
  72473. * @param url of the .tilemaps file
  72474. */
  72475. loadTileMaps(url: string): void;
  72476. /**
  72477. * Release associated resources
  72478. */
  72479. dispose(): void;
  72480. }
  72481. }
  72482. declare module BABYLON {
  72483. /**
  72484. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72485. * @see https://doc.babylonjs.com/babylon101/sprites
  72486. */
  72487. export class SpritePackedManager extends SpriteManager {
  72488. /** defines the packed manager's name */
  72489. name: string;
  72490. /**
  72491. * Creates a new sprite manager from a packed sprite sheet
  72492. * @param name defines the manager's name
  72493. * @param imgUrl defines the sprite sheet url
  72494. * @param capacity defines the maximum allowed number of sprites
  72495. * @param scene defines the hosting scene
  72496. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72497. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72498. * @param samplingMode defines the smapling mode to use with spritesheet
  72499. * @param fromPacked set to true; do not alter
  72500. */
  72501. constructor(
  72502. /** defines the packed manager's name */
  72503. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72504. }
  72505. }
  72506. declare module BABYLON {
  72507. /**
  72508. * Defines the list of states available for a task inside a AssetsManager
  72509. */
  72510. export enum AssetTaskState {
  72511. /**
  72512. * Initialization
  72513. */
  72514. INIT = 0,
  72515. /**
  72516. * Running
  72517. */
  72518. RUNNING = 1,
  72519. /**
  72520. * Done
  72521. */
  72522. DONE = 2,
  72523. /**
  72524. * Error
  72525. */
  72526. ERROR = 3
  72527. }
  72528. /**
  72529. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72530. */
  72531. export abstract class AbstractAssetTask {
  72532. /**
  72533. * Task name
  72534. */ name: string;
  72535. /**
  72536. * Callback called when the task is successful
  72537. */
  72538. onSuccess: (task: any) => void;
  72539. /**
  72540. * Callback called when the task is not successful
  72541. */
  72542. onError: (task: any, message?: string, exception?: any) => void;
  72543. /**
  72544. * Creates a new AssetsManager
  72545. * @param name defines the name of the task
  72546. */
  72547. constructor(
  72548. /**
  72549. * Task name
  72550. */ name: string);
  72551. private _isCompleted;
  72552. private _taskState;
  72553. private _errorObject;
  72554. /**
  72555. * Get if the task is completed
  72556. */
  72557. get isCompleted(): boolean;
  72558. /**
  72559. * Gets the current state of the task
  72560. */
  72561. get taskState(): AssetTaskState;
  72562. /**
  72563. * Gets the current error object (if task is in error)
  72564. */
  72565. get errorObject(): {
  72566. message?: string;
  72567. exception?: any;
  72568. };
  72569. /**
  72570. * Internal only
  72571. * @hidden
  72572. */
  72573. _setErrorObject(message?: string, exception?: any): void;
  72574. /**
  72575. * Execute the current task
  72576. * @param scene defines the scene where you want your assets to be loaded
  72577. * @param onSuccess is a callback called when the task is successfully executed
  72578. * @param onError is a callback called if an error occurs
  72579. */
  72580. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72581. /**
  72582. * Execute the current task
  72583. * @param scene defines the scene where you want your assets to be loaded
  72584. * @param onSuccess is a callback called when the task is successfully executed
  72585. * @param onError is a callback called if an error occurs
  72586. */
  72587. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72588. /**
  72589. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72590. * This can be used with failed tasks that have the reason for failure fixed.
  72591. */
  72592. reset(): void;
  72593. private onErrorCallback;
  72594. private onDoneCallback;
  72595. }
  72596. /**
  72597. * Define the interface used by progress events raised during assets loading
  72598. */
  72599. export interface IAssetsProgressEvent {
  72600. /**
  72601. * Defines the number of remaining tasks to process
  72602. */
  72603. remainingCount: number;
  72604. /**
  72605. * Defines the total number of tasks
  72606. */
  72607. totalCount: number;
  72608. /**
  72609. * Defines the task that was just processed
  72610. */
  72611. task: AbstractAssetTask;
  72612. }
  72613. /**
  72614. * Class used to share progress information about assets loading
  72615. */
  72616. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72617. /**
  72618. * Defines the number of remaining tasks to process
  72619. */
  72620. remainingCount: number;
  72621. /**
  72622. * Defines the total number of tasks
  72623. */
  72624. totalCount: number;
  72625. /**
  72626. * Defines the task that was just processed
  72627. */
  72628. task: AbstractAssetTask;
  72629. /**
  72630. * Creates a AssetsProgressEvent
  72631. * @param remainingCount defines the number of remaining tasks to process
  72632. * @param totalCount defines the total number of tasks
  72633. * @param task defines the task that was just processed
  72634. */
  72635. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72636. }
  72637. /**
  72638. * Define a task used by AssetsManager to load assets into a container
  72639. */
  72640. export class ContainerAssetTask extends AbstractAssetTask {
  72641. /**
  72642. * Defines the name of the task
  72643. */
  72644. name: string;
  72645. /**
  72646. * Defines the list of mesh's names you want to load
  72647. */
  72648. meshesNames: any;
  72649. /**
  72650. * Defines the root url to use as a base to load your meshes and associated resources
  72651. */
  72652. rootUrl: string;
  72653. /**
  72654. * Defines the filename or File of the scene to load from
  72655. */
  72656. sceneFilename: string | File;
  72657. /**
  72658. * Get the loaded asset container
  72659. */
  72660. loadedContainer: AssetContainer;
  72661. /**
  72662. * Gets the list of loaded meshes
  72663. */
  72664. loadedMeshes: Array<AbstractMesh>;
  72665. /**
  72666. * Gets the list of loaded particle systems
  72667. */
  72668. loadedParticleSystems: Array<IParticleSystem>;
  72669. /**
  72670. * Gets the list of loaded skeletons
  72671. */
  72672. loadedSkeletons: Array<Skeleton>;
  72673. /**
  72674. * Gets the list of loaded animation groups
  72675. */
  72676. loadedAnimationGroups: Array<AnimationGroup>;
  72677. /**
  72678. * Callback called when the task is successful
  72679. */
  72680. onSuccess: (task: ContainerAssetTask) => void;
  72681. /**
  72682. * Callback called when the task is successful
  72683. */
  72684. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72685. /**
  72686. * Creates a new ContainerAssetTask
  72687. * @param name defines the name of the task
  72688. * @param meshesNames defines the list of mesh's names you want to load
  72689. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72690. * @param sceneFilename defines the filename or File of the scene to load from
  72691. */
  72692. constructor(
  72693. /**
  72694. * Defines the name of the task
  72695. */
  72696. name: string,
  72697. /**
  72698. * Defines the list of mesh's names you want to load
  72699. */
  72700. meshesNames: any,
  72701. /**
  72702. * Defines the root url to use as a base to load your meshes and associated resources
  72703. */
  72704. rootUrl: string,
  72705. /**
  72706. * Defines the filename or File of the scene to load from
  72707. */
  72708. sceneFilename: string | File);
  72709. /**
  72710. * Execute the current task
  72711. * @param scene defines the scene where you want your assets to be loaded
  72712. * @param onSuccess is a callback called when the task is successfully executed
  72713. * @param onError is a callback called if an error occurs
  72714. */
  72715. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72716. }
  72717. /**
  72718. * Define a task used by AssetsManager to load meshes
  72719. */
  72720. export class MeshAssetTask extends AbstractAssetTask {
  72721. /**
  72722. * Defines the name of the task
  72723. */
  72724. name: string;
  72725. /**
  72726. * Defines the list of mesh's names you want to load
  72727. */
  72728. meshesNames: any;
  72729. /**
  72730. * Defines the root url to use as a base to load your meshes and associated resources
  72731. */
  72732. rootUrl: string;
  72733. /**
  72734. * Defines the filename or File of the scene to load from
  72735. */
  72736. sceneFilename: string | File;
  72737. /**
  72738. * Gets the list of loaded meshes
  72739. */
  72740. loadedMeshes: Array<AbstractMesh>;
  72741. /**
  72742. * Gets the list of loaded particle systems
  72743. */
  72744. loadedParticleSystems: Array<IParticleSystem>;
  72745. /**
  72746. * Gets the list of loaded skeletons
  72747. */
  72748. loadedSkeletons: Array<Skeleton>;
  72749. /**
  72750. * Gets the list of loaded animation groups
  72751. */
  72752. loadedAnimationGroups: Array<AnimationGroup>;
  72753. /**
  72754. * Callback called when the task is successful
  72755. */
  72756. onSuccess: (task: MeshAssetTask) => void;
  72757. /**
  72758. * Callback called when the task is successful
  72759. */
  72760. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72761. /**
  72762. * Creates a new MeshAssetTask
  72763. * @param name defines the name of the task
  72764. * @param meshesNames defines the list of mesh's names you want to load
  72765. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72766. * @param sceneFilename defines the filename or File of the scene to load from
  72767. */
  72768. constructor(
  72769. /**
  72770. * Defines the name of the task
  72771. */
  72772. name: string,
  72773. /**
  72774. * Defines the list of mesh's names you want to load
  72775. */
  72776. meshesNames: any,
  72777. /**
  72778. * Defines the root url to use as a base to load your meshes and associated resources
  72779. */
  72780. rootUrl: string,
  72781. /**
  72782. * Defines the filename or File of the scene to load from
  72783. */
  72784. sceneFilename: string | File);
  72785. /**
  72786. * Execute the current task
  72787. * @param scene defines the scene where you want your assets to be loaded
  72788. * @param onSuccess is a callback called when the task is successfully executed
  72789. * @param onError is a callback called if an error occurs
  72790. */
  72791. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72792. }
  72793. /**
  72794. * Define a task used by AssetsManager to load text content
  72795. */
  72796. export class TextFileAssetTask extends AbstractAssetTask {
  72797. /**
  72798. * Defines the name of the task
  72799. */
  72800. name: string;
  72801. /**
  72802. * Defines the location of the file to load
  72803. */
  72804. url: string;
  72805. /**
  72806. * Gets the loaded text string
  72807. */
  72808. text: string;
  72809. /**
  72810. * Callback called when the task is successful
  72811. */
  72812. onSuccess: (task: TextFileAssetTask) => void;
  72813. /**
  72814. * Callback called when the task is successful
  72815. */
  72816. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72817. /**
  72818. * Creates a new TextFileAssetTask object
  72819. * @param name defines the name of the task
  72820. * @param url defines the location of the file to load
  72821. */
  72822. constructor(
  72823. /**
  72824. * Defines the name of the task
  72825. */
  72826. name: string,
  72827. /**
  72828. * Defines the location of the file to load
  72829. */
  72830. url: string);
  72831. /**
  72832. * Execute the current task
  72833. * @param scene defines the scene where you want your assets to be loaded
  72834. * @param onSuccess is a callback called when the task is successfully executed
  72835. * @param onError is a callback called if an error occurs
  72836. */
  72837. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72838. }
  72839. /**
  72840. * Define a task used by AssetsManager to load binary data
  72841. */
  72842. export class BinaryFileAssetTask extends AbstractAssetTask {
  72843. /**
  72844. * Defines the name of the task
  72845. */
  72846. name: string;
  72847. /**
  72848. * Defines the location of the file to load
  72849. */
  72850. url: string;
  72851. /**
  72852. * Gets the lodaded data (as an array buffer)
  72853. */
  72854. data: ArrayBuffer;
  72855. /**
  72856. * Callback called when the task is successful
  72857. */
  72858. onSuccess: (task: BinaryFileAssetTask) => void;
  72859. /**
  72860. * Callback called when the task is successful
  72861. */
  72862. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72863. /**
  72864. * Creates a new BinaryFileAssetTask object
  72865. * @param name defines the name of the new task
  72866. * @param url defines the location of the file to load
  72867. */
  72868. constructor(
  72869. /**
  72870. * Defines the name of the task
  72871. */
  72872. name: string,
  72873. /**
  72874. * Defines the location of the file to load
  72875. */
  72876. url: string);
  72877. /**
  72878. * Execute the current task
  72879. * @param scene defines the scene where you want your assets to be loaded
  72880. * @param onSuccess is a callback called when the task is successfully executed
  72881. * @param onError is a callback called if an error occurs
  72882. */
  72883. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72884. }
  72885. /**
  72886. * Define a task used by AssetsManager to load images
  72887. */
  72888. export class ImageAssetTask extends AbstractAssetTask {
  72889. /**
  72890. * Defines the name of the task
  72891. */
  72892. name: string;
  72893. /**
  72894. * Defines the location of the image to load
  72895. */
  72896. url: string;
  72897. /**
  72898. * Gets the loaded images
  72899. */
  72900. image: HTMLImageElement;
  72901. /**
  72902. * Callback called when the task is successful
  72903. */
  72904. onSuccess: (task: ImageAssetTask) => void;
  72905. /**
  72906. * Callback called when the task is successful
  72907. */
  72908. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72909. /**
  72910. * Creates a new ImageAssetTask
  72911. * @param name defines the name of the task
  72912. * @param url defines the location of the image to load
  72913. */
  72914. constructor(
  72915. /**
  72916. * Defines the name of the task
  72917. */
  72918. name: string,
  72919. /**
  72920. * Defines the location of the image to load
  72921. */
  72922. url: string);
  72923. /**
  72924. * Execute the current task
  72925. * @param scene defines the scene where you want your assets to be loaded
  72926. * @param onSuccess is a callback called when the task is successfully executed
  72927. * @param onError is a callback called if an error occurs
  72928. */
  72929. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72930. }
  72931. /**
  72932. * Defines the interface used by texture loading tasks
  72933. */
  72934. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72935. /**
  72936. * Gets the loaded texture
  72937. */
  72938. texture: TEX;
  72939. }
  72940. /**
  72941. * Define a task used by AssetsManager to load 2D textures
  72942. */
  72943. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72944. /**
  72945. * Defines the name of the task
  72946. */
  72947. name: string;
  72948. /**
  72949. * Defines the location of the file to load
  72950. */
  72951. url: string;
  72952. /**
  72953. * Defines if mipmap should not be generated (default is false)
  72954. */
  72955. noMipmap?: boolean | undefined;
  72956. /**
  72957. * Defines if texture must be inverted on Y axis (default is true)
  72958. */
  72959. invertY: boolean;
  72960. /**
  72961. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72962. */
  72963. samplingMode: number;
  72964. /**
  72965. * Gets the loaded texture
  72966. */
  72967. texture: Texture;
  72968. /**
  72969. * Callback called when the task is successful
  72970. */
  72971. onSuccess: (task: TextureAssetTask) => void;
  72972. /**
  72973. * Callback called when the task is successful
  72974. */
  72975. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72976. /**
  72977. * Creates a new TextureAssetTask object
  72978. * @param name defines the name of the task
  72979. * @param url defines the location of the file to load
  72980. * @param noMipmap defines if mipmap should not be generated (default is false)
  72981. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72982. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72983. */
  72984. constructor(
  72985. /**
  72986. * Defines the name of the task
  72987. */
  72988. name: string,
  72989. /**
  72990. * Defines the location of the file to load
  72991. */
  72992. url: string,
  72993. /**
  72994. * Defines if mipmap should not be generated (default is false)
  72995. */
  72996. noMipmap?: boolean | undefined,
  72997. /**
  72998. * Defines if texture must be inverted on Y axis (default is true)
  72999. */
  73000. invertY?: boolean,
  73001. /**
  73002. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73003. */
  73004. samplingMode?: number);
  73005. /**
  73006. * Execute the current task
  73007. * @param scene defines the scene where you want your assets to be loaded
  73008. * @param onSuccess is a callback called when the task is successfully executed
  73009. * @param onError is a callback called if an error occurs
  73010. */
  73011. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73012. }
  73013. /**
  73014. * Define a task used by AssetsManager to load cube textures
  73015. */
  73016. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73017. /**
  73018. * Defines the name of the task
  73019. */
  73020. name: string;
  73021. /**
  73022. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73023. */
  73024. url: string;
  73025. /**
  73026. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73027. */
  73028. extensions?: string[] | undefined;
  73029. /**
  73030. * Defines if mipmaps should not be generated (default is false)
  73031. */
  73032. noMipmap?: boolean | undefined;
  73033. /**
  73034. * Defines the explicit list of files (undefined by default)
  73035. */
  73036. files?: string[] | undefined;
  73037. /**
  73038. * Gets the loaded texture
  73039. */
  73040. texture: CubeTexture;
  73041. /**
  73042. * Callback called when the task is successful
  73043. */
  73044. onSuccess: (task: CubeTextureAssetTask) => void;
  73045. /**
  73046. * Callback called when the task is successful
  73047. */
  73048. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73049. /**
  73050. * Creates a new CubeTextureAssetTask
  73051. * @param name defines the name of the task
  73052. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73053. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73054. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73055. * @param files defines the explicit list of files (undefined by default)
  73056. */
  73057. constructor(
  73058. /**
  73059. * Defines the name of the task
  73060. */
  73061. name: string,
  73062. /**
  73063. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73064. */
  73065. url: string,
  73066. /**
  73067. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73068. */
  73069. extensions?: string[] | undefined,
  73070. /**
  73071. * Defines if mipmaps should not be generated (default is false)
  73072. */
  73073. noMipmap?: boolean | undefined,
  73074. /**
  73075. * Defines the explicit list of files (undefined by default)
  73076. */
  73077. files?: string[] | undefined);
  73078. /**
  73079. * Execute the current task
  73080. * @param scene defines the scene where you want your assets to be loaded
  73081. * @param onSuccess is a callback called when the task is successfully executed
  73082. * @param onError is a callback called if an error occurs
  73083. */
  73084. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73085. }
  73086. /**
  73087. * Define a task used by AssetsManager to load HDR cube textures
  73088. */
  73089. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73090. /**
  73091. * Defines the name of the task
  73092. */
  73093. name: string;
  73094. /**
  73095. * Defines the location of the file to load
  73096. */
  73097. url: string;
  73098. /**
  73099. * Defines the desired size (the more it increases the longer the generation will be)
  73100. */
  73101. size: number;
  73102. /**
  73103. * Defines if mipmaps should not be generated (default is false)
  73104. */
  73105. noMipmap: boolean;
  73106. /**
  73107. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73108. */
  73109. generateHarmonics: boolean;
  73110. /**
  73111. * 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)
  73112. */
  73113. gammaSpace: boolean;
  73114. /**
  73115. * Internal Use Only
  73116. */
  73117. reserved: boolean;
  73118. /**
  73119. * Gets the loaded texture
  73120. */
  73121. texture: HDRCubeTexture;
  73122. /**
  73123. * Callback called when the task is successful
  73124. */
  73125. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73126. /**
  73127. * Callback called when the task is successful
  73128. */
  73129. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73130. /**
  73131. * Creates a new HDRCubeTextureAssetTask object
  73132. * @param name defines the name of the task
  73133. * @param url defines the location of the file to load
  73134. * @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.
  73135. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73136. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73137. * @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)
  73138. * @param reserved Internal use only
  73139. */
  73140. constructor(
  73141. /**
  73142. * Defines the name of the task
  73143. */
  73144. name: string,
  73145. /**
  73146. * Defines the location of the file to load
  73147. */
  73148. url: string,
  73149. /**
  73150. * Defines the desired size (the more it increases the longer the generation will be)
  73151. */
  73152. size: number,
  73153. /**
  73154. * Defines if mipmaps should not be generated (default is false)
  73155. */
  73156. noMipmap?: boolean,
  73157. /**
  73158. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73159. */
  73160. generateHarmonics?: boolean,
  73161. /**
  73162. * 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)
  73163. */
  73164. gammaSpace?: boolean,
  73165. /**
  73166. * Internal Use Only
  73167. */
  73168. reserved?: boolean);
  73169. /**
  73170. * Execute the current task
  73171. * @param scene defines the scene where you want your assets to be loaded
  73172. * @param onSuccess is a callback called when the task is successfully executed
  73173. * @param onError is a callback called if an error occurs
  73174. */
  73175. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73176. }
  73177. /**
  73178. * Define a task used by AssetsManager to load Equirectangular cube textures
  73179. */
  73180. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73181. /**
  73182. * Defines the name of the task
  73183. */
  73184. name: string;
  73185. /**
  73186. * Defines the location of the file to load
  73187. */
  73188. url: string;
  73189. /**
  73190. * Defines the desired size (the more it increases the longer the generation will be)
  73191. */
  73192. size: number;
  73193. /**
  73194. * Defines if mipmaps should not be generated (default is false)
  73195. */
  73196. noMipmap: boolean;
  73197. /**
  73198. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73199. * but the standard material would require them in Gamma space) (default is true)
  73200. */
  73201. gammaSpace: boolean;
  73202. /**
  73203. * Gets the loaded texture
  73204. */
  73205. texture: EquiRectangularCubeTexture;
  73206. /**
  73207. * Callback called when the task is successful
  73208. */
  73209. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73210. /**
  73211. * Callback called when the task is successful
  73212. */
  73213. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73214. /**
  73215. * Creates a new EquiRectangularCubeTextureAssetTask object
  73216. * @param name defines the name of the task
  73217. * @param url defines the location of the file to load
  73218. * @param size defines the desired size (the more it increases the longer the generation will be)
  73219. * If the size is omitted this implies you are using a preprocessed cubemap.
  73220. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73221. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73222. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73223. * (default is true)
  73224. */
  73225. constructor(
  73226. /**
  73227. * Defines the name of the task
  73228. */
  73229. name: string,
  73230. /**
  73231. * Defines the location of the file to load
  73232. */
  73233. url: string,
  73234. /**
  73235. * Defines the desired size (the more it increases the longer the generation will be)
  73236. */
  73237. size: number,
  73238. /**
  73239. * Defines if mipmaps should not be generated (default is false)
  73240. */
  73241. noMipmap?: boolean,
  73242. /**
  73243. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73244. * but the standard material would require them in Gamma space) (default is true)
  73245. */
  73246. gammaSpace?: boolean);
  73247. /**
  73248. * Execute the current task
  73249. * @param scene defines the scene where you want your assets to be loaded
  73250. * @param onSuccess is a callback called when the task is successfully executed
  73251. * @param onError is a callback called if an error occurs
  73252. */
  73253. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73254. }
  73255. /**
  73256. * This class can be used to easily import assets into a scene
  73257. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73258. */
  73259. export class AssetsManager {
  73260. private _scene;
  73261. private _isLoading;
  73262. protected _tasks: AbstractAssetTask[];
  73263. protected _waitingTasksCount: number;
  73264. protected _totalTasksCount: number;
  73265. /**
  73266. * Callback called when all tasks are processed
  73267. */
  73268. onFinish: (tasks: AbstractAssetTask[]) => void;
  73269. /**
  73270. * Callback called when a task is successful
  73271. */
  73272. onTaskSuccess: (task: AbstractAssetTask) => void;
  73273. /**
  73274. * Callback called when a task had an error
  73275. */
  73276. onTaskError: (task: AbstractAssetTask) => void;
  73277. /**
  73278. * Callback called when a task is done (whatever the result is)
  73279. */
  73280. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73281. /**
  73282. * Observable called when all tasks are processed
  73283. */
  73284. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73285. /**
  73286. * Observable called when a task had an error
  73287. */
  73288. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73289. /**
  73290. * Observable called when all tasks were executed
  73291. */
  73292. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73293. /**
  73294. * Observable called when a task is done (whatever the result is)
  73295. */
  73296. onProgressObservable: Observable<IAssetsProgressEvent>;
  73297. /**
  73298. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73299. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73300. */
  73301. useDefaultLoadingScreen: boolean;
  73302. /**
  73303. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73304. * when all assets have been downloaded.
  73305. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73306. */
  73307. autoHideLoadingUI: boolean;
  73308. /**
  73309. * Creates a new AssetsManager
  73310. * @param scene defines the scene to work on
  73311. */
  73312. constructor(scene: Scene);
  73313. /**
  73314. * Add a ContainerAssetTask to the list of active tasks
  73315. * @param taskName defines the name of the new task
  73316. * @param meshesNames defines the name of meshes to load
  73317. * @param rootUrl defines the root url to use to locate files
  73318. * @param sceneFilename defines the filename of the scene file
  73319. * @returns a new ContainerAssetTask object
  73320. */
  73321. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73322. /**
  73323. * Add a MeshAssetTask to the list of active tasks
  73324. * @param taskName defines the name of the new task
  73325. * @param meshesNames defines the name of meshes to load
  73326. * @param rootUrl defines the root url to use to locate files
  73327. * @param sceneFilename defines the filename of the scene file
  73328. * @returns a new MeshAssetTask object
  73329. */
  73330. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73331. /**
  73332. * Add a TextFileAssetTask to the list of active tasks
  73333. * @param taskName defines the name of the new task
  73334. * @param url defines the url of the file to load
  73335. * @returns a new TextFileAssetTask object
  73336. */
  73337. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73338. /**
  73339. * Add a BinaryFileAssetTask to the list of active tasks
  73340. * @param taskName defines the name of the new task
  73341. * @param url defines the url of the file to load
  73342. * @returns a new BinaryFileAssetTask object
  73343. */
  73344. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73345. /**
  73346. * Add a ImageAssetTask to the list of active tasks
  73347. * @param taskName defines the name of the new task
  73348. * @param url defines the url of the file to load
  73349. * @returns a new ImageAssetTask object
  73350. */
  73351. addImageTask(taskName: string, url: string): ImageAssetTask;
  73352. /**
  73353. * Add a TextureAssetTask to the list of active tasks
  73354. * @param taskName defines the name of the new task
  73355. * @param url defines the url of the file to load
  73356. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73357. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73358. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73359. * @returns a new TextureAssetTask object
  73360. */
  73361. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73362. /**
  73363. * Add a CubeTextureAssetTask to the list of active tasks
  73364. * @param taskName defines the name of the new task
  73365. * @param url defines the url of the file to load
  73366. * @param extensions defines the extension to use to load the cube map (can be null)
  73367. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73368. * @param files defines the list of files to load (can be null)
  73369. * @returns a new CubeTextureAssetTask object
  73370. */
  73371. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73372. /**
  73373. *
  73374. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73375. * @param taskName defines the name of the new task
  73376. * @param url defines the url of the file to load
  73377. * @param size defines the size you want for the cubemap (can be null)
  73378. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73379. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73380. * @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)
  73381. * @param reserved Internal use only
  73382. * @returns a new HDRCubeTextureAssetTask object
  73383. */
  73384. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73385. /**
  73386. *
  73387. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73388. * @param taskName defines the name of the new task
  73389. * @param url defines the url of the file to load
  73390. * @param size defines the size you want for the cubemap (can be null)
  73391. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73392. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73393. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73394. * @returns a new EquiRectangularCubeTextureAssetTask object
  73395. */
  73396. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73397. /**
  73398. * Remove a task from the assets manager.
  73399. * @param task the task to remove
  73400. */
  73401. removeTask(task: AbstractAssetTask): void;
  73402. private _decreaseWaitingTasksCount;
  73403. private _runTask;
  73404. /**
  73405. * Reset the AssetsManager and remove all tasks
  73406. * @return the current instance of the AssetsManager
  73407. */
  73408. reset(): AssetsManager;
  73409. /**
  73410. * Start the loading process
  73411. * @return the current instance of the AssetsManager
  73412. */
  73413. load(): AssetsManager;
  73414. /**
  73415. * Start the loading process as an async operation
  73416. * @return a promise returning the list of failed tasks
  73417. */
  73418. loadAsync(): Promise<void>;
  73419. }
  73420. }
  73421. declare module BABYLON {
  73422. /**
  73423. * Wrapper class for promise with external resolve and reject.
  73424. */
  73425. export class Deferred<T> {
  73426. /**
  73427. * The promise associated with this deferred object.
  73428. */
  73429. readonly promise: Promise<T>;
  73430. private _resolve;
  73431. private _reject;
  73432. /**
  73433. * The resolve method of the promise associated with this deferred object.
  73434. */
  73435. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73436. /**
  73437. * The reject method of the promise associated with this deferred object.
  73438. */
  73439. get reject(): (reason?: any) => void;
  73440. /**
  73441. * Constructor for this deferred object.
  73442. */
  73443. constructor();
  73444. }
  73445. }
  73446. declare module BABYLON {
  73447. /**
  73448. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73449. */
  73450. export class MeshExploder {
  73451. private _centerMesh;
  73452. private _meshes;
  73453. private _meshesOrigins;
  73454. private _toCenterVectors;
  73455. private _scaledDirection;
  73456. private _newPosition;
  73457. private _centerPosition;
  73458. /**
  73459. * Explodes meshes from a center mesh.
  73460. * @param meshes The meshes to explode.
  73461. * @param centerMesh The mesh to be center of explosion.
  73462. */
  73463. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73464. private _setCenterMesh;
  73465. /**
  73466. * Get class name
  73467. * @returns "MeshExploder"
  73468. */
  73469. getClassName(): string;
  73470. /**
  73471. * "Exploded meshes"
  73472. * @returns Array of meshes with the centerMesh at index 0.
  73473. */
  73474. getMeshes(): Array<Mesh>;
  73475. /**
  73476. * Explodes meshes giving a specific direction
  73477. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73478. */
  73479. explode(direction?: number): void;
  73480. }
  73481. }
  73482. declare module BABYLON {
  73483. /**
  73484. * Class used to help managing file picking and drag'n'drop
  73485. */
  73486. export class FilesInput {
  73487. /**
  73488. * List of files ready to be loaded
  73489. */
  73490. static get FilesToLoad(): {
  73491. [key: string]: File;
  73492. };
  73493. /**
  73494. * Callback called when a file is processed
  73495. */
  73496. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73497. private _engine;
  73498. private _currentScene;
  73499. private _sceneLoadedCallback;
  73500. private _progressCallback;
  73501. private _additionalRenderLoopLogicCallback;
  73502. private _textureLoadingCallback;
  73503. private _startingProcessingFilesCallback;
  73504. private _onReloadCallback;
  73505. private _errorCallback;
  73506. private _elementToMonitor;
  73507. private _sceneFileToLoad;
  73508. private _filesToLoad;
  73509. /**
  73510. * Creates a new FilesInput
  73511. * @param engine defines the rendering engine
  73512. * @param scene defines the hosting scene
  73513. * @param sceneLoadedCallback callback called when scene is loaded
  73514. * @param progressCallback callback called to track progress
  73515. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73516. * @param textureLoadingCallback callback called when a texture is loading
  73517. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73518. * @param onReloadCallback callback called when a reload is requested
  73519. * @param errorCallback callback call if an error occurs
  73520. */
  73521. 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>);
  73522. private _dragEnterHandler;
  73523. private _dragOverHandler;
  73524. private _dropHandler;
  73525. /**
  73526. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73527. * @param elementToMonitor defines the DOM element to track
  73528. */
  73529. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73530. /** Gets the current list of files to load */
  73531. get filesToLoad(): File[];
  73532. /**
  73533. * Release all associated resources
  73534. */
  73535. dispose(): void;
  73536. private renderFunction;
  73537. private drag;
  73538. private drop;
  73539. private _traverseFolder;
  73540. private _processFiles;
  73541. /**
  73542. * Load files from a drop event
  73543. * @param event defines the drop event to use as source
  73544. */
  73545. loadFiles(event: any): void;
  73546. private _processReload;
  73547. /**
  73548. * Reload the current scene from the loaded files
  73549. */
  73550. reload(): void;
  73551. }
  73552. }
  73553. declare module BABYLON {
  73554. /**
  73555. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73556. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73557. */
  73558. export class SceneOptimization {
  73559. /**
  73560. * Defines the priority of this optimization (0 by default which means first in the list)
  73561. */
  73562. priority: number;
  73563. /**
  73564. * Gets a string describing the action executed by the current optimization
  73565. * @returns description string
  73566. */
  73567. getDescription(): string;
  73568. /**
  73569. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73570. * @param scene defines the current scene where to apply this optimization
  73571. * @param optimizer defines the current optimizer
  73572. * @returns true if everything that can be done was applied
  73573. */
  73574. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73575. /**
  73576. * Creates the SceneOptimization object
  73577. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73578. * @param desc defines the description associated with the optimization
  73579. */
  73580. constructor(
  73581. /**
  73582. * Defines the priority of this optimization (0 by default which means first in the list)
  73583. */
  73584. priority?: number);
  73585. }
  73586. /**
  73587. * Defines an optimization used to reduce the size of render target textures
  73588. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73589. */
  73590. export class TextureOptimization extends SceneOptimization {
  73591. /**
  73592. * Defines the priority of this optimization (0 by default which means first in the list)
  73593. */
  73594. priority: number;
  73595. /**
  73596. * 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
  73597. */
  73598. maximumSize: number;
  73599. /**
  73600. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73601. */
  73602. step: number;
  73603. /**
  73604. * Gets a string describing the action executed by the current optimization
  73605. * @returns description string
  73606. */
  73607. getDescription(): string;
  73608. /**
  73609. * Creates the TextureOptimization object
  73610. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73611. * @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
  73612. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73613. */
  73614. constructor(
  73615. /**
  73616. * Defines the priority of this optimization (0 by default which means first in the list)
  73617. */
  73618. priority?: number,
  73619. /**
  73620. * 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
  73621. */
  73622. maximumSize?: number,
  73623. /**
  73624. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73625. */
  73626. step?: number);
  73627. /**
  73628. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73629. * @param scene defines the current scene where to apply this optimization
  73630. * @param optimizer defines the current optimizer
  73631. * @returns true if everything that can be done was applied
  73632. */
  73633. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73634. }
  73635. /**
  73636. * Defines an optimization used to increase or decrease the rendering resolution
  73637. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73638. */
  73639. export class HardwareScalingOptimization extends SceneOptimization {
  73640. /**
  73641. * Defines the priority of this optimization (0 by default which means first in the list)
  73642. */
  73643. priority: number;
  73644. /**
  73645. * Defines the maximum scale to use (2 by default)
  73646. */
  73647. maximumScale: number;
  73648. /**
  73649. * Defines the step to use between two passes (0.5 by default)
  73650. */
  73651. step: number;
  73652. private _currentScale;
  73653. private _directionOffset;
  73654. /**
  73655. * Gets a string describing the action executed by the current optimization
  73656. * @return description string
  73657. */
  73658. getDescription(): string;
  73659. /**
  73660. * Creates the HardwareScalingOptimization object
  73661. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73662. * @param maximumScale defines the maximum scale to use (2 by default)
  73663. * @param step defines the step to use between two passes (0.5 by default)
  73664. */
  73665. constructor(
  73666. /**
  73667. * Defines the priority of this optimization (0 by default which means first in the list)
  73668. */
  73669. priority?: number,
  73670. /**
  73671. * Defines the maximum scale to use (2 by default)
  73672. */
  73673. maximumScale?: number,
  73674. /**
  73675. * Defines the step to use between two passes (0.5 by default)
  73676. */
  73677. step?: number);
  73678. /**
  73679. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73680. * @param scene defines the current scene where to apply this optimization
  73681. * @param optimizer defines the current optimizer
  73682. * @returns true if everything that can be done was applied
  73683. */
  73684. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73685. }
  73686. /**
  73687. * Defines an optimization used to remove shadows
  73688. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73689. */
  73690. export class ShadowsOptimization extends SceneOptimization {
  73691. /**
  73692. * Gets a string describing the action executed by the current optimization
  73693. * @return description string
  73694. */
  73695. getDescription(): string;
  73696. /**
  73697. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73698. * @param scene defines the current scene where to apply this optimization
  73699. * @param optimizer defines the current optimizer
  73700. * @returns true if everything that can be done was applied
  73701. */
  73702. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73703. }
  73704. /**
  73705. * Defines an optimization used to turn post-processes off
  73706. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73707. */
  73708. export class PostProcessesOptimization extends SceneOptimization {
  73709. /**
  73710. * Gets a string describing the action executed by the current optimization
  73711. * @return description string
  73712. */
  73713. getDescription(): string;
  73714. /**
  73715. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73716. * @param scene defines the current scene where to apply this optimization
  73717. * @param optimizer defines the current optimizer
  73718. * @returns true if everything that can be done was applied
  73719. */
  73720. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73721. }
  73722. /**
  73723. * Defines an optimization used to turn lens flares off
  73724. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73725. */
  73726. export class LensFlaresOptimization extends SceneOptimization {
  73727. /**
  73728. * Gets a string describing the action executed by the current optimization
  73729. * @return description string
  73730. */
  73731. getDescription(): string;
  73732. /**
  73733. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73734. * @param scene defines the current scene where to apply this optimization
  73735. * @param optimizer defines the current optimizer
  73736. * @returns true if everything that can be done was applied
  73737. */
  73738. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73739. }
  73740. /**
  73741. * Defines an optimization based on user defined callback.
  73742. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73743. */
  73744. export class CustomOptimization extends SceneOptimization {
  73745. /**
  73746. * Callback called to apply the custom optimization.
  73747. */
  73748. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73749. /**
  73750. * Callback called to get custom description
  73751. */
  73752. onGetDescription: () => string;
  73753. /**
  73754. * Gets a string describing the action executed by the current optimization
  73755. * @returns description string
  73756. */
  73757. getDescription(): string;
  73758. /**
  73759. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73760. * @param scene defines the current scene where to apply this optimization
  73761. * @param optimizer defines the current optimizer
  73762. * @returns true if everything that can be done was applied
  73763. */
  73764. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73765. }
  73766. /**
  73767. * Defines an optimization used to turn particles off
  73768. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73769. */
  73770. export class ParticlesOptimization extends SceneOptimization {
  73771. /**
  73772. * Gets a string describing the action executed by the current optimization
  73773. * @return description string
  73774. */
  73775. getDescription(): string;
  73776. /**
  73777. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73778. * @param scene defines the current scene where to apply this optimization
  73779. * @param optimizer defines the current optimizer
  73780. * @returns true if everything that can be done was applied
  73781. */
  73782. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73783. }
  73784. /**
  73785. * Defines an optimization used to turn render targets off
  73786. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73787. */
  73788. export class RenderTargetsOptimization extends SceneOptimization {
  73789. /**
  73790. * Gets a string describing the action executed by the current optimization
  73791. * @return description string
  73792. */
  73793. getDescription(): string;
  73794. /**
  73795. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73796. * @param scene defines the current scene where to apply this optimization
  73797. * @param optimizer defines the current optimizer
  73798. * @returns true if everything that can be done was applied
  73799. */
  73800. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73801. }
  73802. /**
  73803. * Defines an optimization used to merge meshes with compatible materials
  73804. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73805. */
  73806. export class MergeMeshesOptimization extends SceneOptimization {
  73807. private static _UpdateSelectionTree;
  73808. /**
  73809. * Gets or sets a boolean which defines if optimization octree has to be updated
  73810. */
  73811. static get UpdateSelectionTree(): boolean;
  73812. /**
  73813. * Gets or sets a boolean which defines if optimization octree has to be updated
  73814. */
  73815. static set UpdateSelectionTree(value: boolean);
  73816. /**
  73817. * Gets a string describing the action executed by the current optimization
  73818. * @return description string
  73819. */
  73820. getDescription(): string;
  73821. private _canBeMerged;
  73822. /**
  73823. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73824. * @param scene defines the current scene where to apply this optimization
  73825. * @param optimizer defines the current optimizer
  73826. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73827. * @returns true if everything that can be done was applied
  73828. */
  73829. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73830. }
  73831. /**
  73832. * Defines a list of options used by SceneOptimizer
  73833. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73834. */
  73835. export class SceneOptimizerOptions {
  73836. /**
  73837. * Defines the target frame rate to reach (60 by default)
  73838. */
  73839. targetFrameRate: number;
  73840. /**
  73841. * Defines the interval between two checkes (2000ms by default)
  73842. */
  73843. trackerDuration: number;
  73844. /**
  73845. * Gets the list of optimizations to apply
  73846. */
  73847. optimizations: SceneOptimization[];
  73848. /**
  73849. * Creates a new list of options used by SceneOptimizer
  73850. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73851. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73852. */
  73853. constructor(
  73854. /**
  73855. * Defines the target frame rate to reach (60 by default)
  73856. */
  73857. targetFrameRate?: number,
  73858. /**
  73859. * Defines the interval between two checkes (2000ms by default)
  73860. */
  73861. trackerDuration?: number);
  73862. /**
  73863. * Add a new optimization
  73864. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73865. * @returns the current SceneOptimizerOptions
  73866. */
  73867. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73868. /**
  73869. * Add a new custom optimization
  73870. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73871. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73872. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73873. * @returns the current SceneOptimizerOptions
  73874. */
  73875. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73876. /**
  73877. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73878. * @param targetFrameRate defines the target frame rate (60 by default)
  73879. * @returns a SceneOptimizerOptions object
  73880. */
  73881. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73882. /**
  73883. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73884. * @param targetFrameRate defines the target frame rate (60 by default)
  73885. * @returns a SceneOptimizerOptions object
  73886. */
  73887. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73888. /**
  73889. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73890. * @param targetFrameRate defines the target frame rate (60 by default)
  73891. * @returns a SceneOptimizerOptions object
  73892. */
  73893. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73894. }
  73895. /**
  73896. * Class used to run optimizations in order to reach a target frame rate
  73897. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73898. */
  73899. export class SceneOptimizer implements IDisposable {
  73900. private _isRunning;
  73901. private _options;
  73902. private _scene;
  73903. private _currentPriorityLevel;
  73904. private _targetFrameRate;
  73905. private _trackerDuration;
  73906. private _currentFrameRate;
  73907. private _sceneDisposeObserver;
  73908. private _improvementMode;
  73909. /**
  73910. * Defines an observable called when the optimizer reaches the target frame rate
  73911. */
  73912. onSuccessObservable: Observable<SceneOptimizer>;
  73913. /**
  73914. * Defines an observable called when the optimizer enables an optimization
  73915. */
  73916. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73917. /**
  73918. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73919. */
  73920. onFailureObservable: Observable<SceneOptimizer>;
  73921. /**
  73922. * Gets a boolean indicating if the optimizer is in improvement mode
  73923. */
  73924. get isInImprovementMode(): boolean;
  73925. /**
  73926. * Gets the current priority level (0 at start)
  73927. */
  73928. get currentPriorityLevel(): number;
  73929. /**
  73930. * Gets the current frame rate checked by the SceneOptimizer
  73931. */
  73932. get currentFrameRate(): number;
  73933. /**
  73934. * Gets or sets the current target frame rate (60 by default)
  73935. */
  73936. get targetFrameRate(): number;
  73937. /**
  73938. * Gets or sets the current target frame rate (60 by default)
  73939. */
  73940. set targetFrameRate(value: number);
  73941. /**
  73942. * Gets or sets the current interval between two checks (every 2000ms by default)
  73943. */
  73944. get trackerDuration(): number;
  73945. /**
  73946. * Gets or sets the current interval between two checks (every 2000ms by default)
  73947. */
  73948. set trackerDuration(value: number);
  73949. /**
  73950. * Gets the list of active optimizations
  73951. */
  73952. get optimizations(): SceneOptimization[];
  73953. /**
  73954. * Creates a new SceneOptimizer
  73955. * @param scene defines the scene to work on
  73956. * @param options defines the options to use with the SceneOptimizer
  73957. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73958. * @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)
  73959. */
  73960. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73961. /**
  73962. * Stops the current optimizer
  73963. */
  73964. stop(): void;
  73965. /**
  73966. * Reset the optimizer to initial step (current priority level = 0)
  73967. */
  73968. reset(): void;
  73969. /**
  73970. * Start the optimizer. By default it will try to reach a specific framerate
  73971. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73972. */
  73973. start(): void;
  73974. private _checkCurrentState;
  73975. /**
  73976. * Release all resources
  73977. */
  73978. dispose(): void;
  73979. /**
  73980. * Helper function to create a SceneOptimizer with one single line of code
  73981. * @param scene defines the scene to work on
  73982. * @param options defines the options to use with the SceneOptimizer
  73983. * @param onSuccess defines a callback to call on success
  73984. * @param onFailure defines a callback to call on failure
  73985. * @returns the new SceneOptimizer object
  73986. */
  73987. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73988. }
  73989. }
  73990. declare module BABYLON {
  73991. /**
  73992. * Class used to serialize a scene into a string
  73993. */
  73994. export class SceneSerializer {
  73995. /**
  73996. * Clear cache used by a previous serialization
  73997. */
  73998. static ClearCache(): void;
  73999. /**
  74000. * Serialize a scene into a JSON compatible object
  74001. * @param scene defines the scene to serialize
  74002. * @returns a JSON compatible object
  74003. */
  74004. static Serialize(scene: Scene): any;
  74005. /**
  74006. * Serialize a mesh into a JSON compatible object
  74007. * @param toSerialize defines the mesh to serialize
  74008. * @param withParents defines if parents must be serialized as well
  74009. * @param withChildren defines if children must be serialized as well
  74010. * @returns a JSON compatible object
  74011. */
  74012. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74013. }
  74014. }
  74015. declare module BABYLON {
  74016. /**
  74017. * Class used to host texture specific utilities
  74018. */
  74019. export class TextureTools {
  74020. /**
  74021. * Uses the GPU to create a copy texture rescaled at a given size
  74022. * @param texture Texture to copy from
  74023. * @param width defines the desired width
  74024. * @param height defines the desired height
  74025. * @param useBilinearMode defines if bilinear mode has to be used
  74026. * @return the generated texture
  74027. */
  74028. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74029. }
  74030. }
  74031. declare module BABYLON {
  74032. /**
  74033. * This represents the different options available for the video capture.
  74034. */
  74035. export interface VideoRecorderOptions {
  74036. /** Defines the mime type of the video. */
  74037. mimeType: string;
  74038. /** Defines the FPS the video should be recorded at. */
  74039. fps: number;
  74040. /** Defines the chunk size for the recording data. */
  74041. recordChunckSize: number;
  74042. /** The audio tracks to attach to the recording. */
  74043. audioTracks?: MediaStreamTrack[];
  74044. }
  74045. /**
  74046. * This can help with recording videos from BabylonJS.
  74047. * This is based on the available WebRTC functionalities of the browser.
  74048. *
  74049. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74050. */
  74051. export class VideoRecorder {
  74052. private static readonly _defaultOptions;
  74053. /**
  74054. * Returns whether or not the VideoRecorder is available in your browser.
  74055. * @param engine Defines the Babylon Engine.
  74056. * @returns true if supported otherwise false.
  74057. */
  74058. static IsSupported(engine: Engine): boolean;
  74059. private readonly _options;
  74060. private _canvas;
  74061. private _mediaRecorder;
  74062. private _recordedChunks;
  74063. private _fileName;
  74064. private _resolve;
  74065. private _reject;
  74066. /**
  74067. * True when a recording is already in progress.
  74068. */
  74069. get isRecording(): boolean;
  74070. /**
  74071. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74072. * @param engine Defines the BabylonJS Engine you wish to record.
  74073. * @param options Defines options that can be used to customize the capture.
  74074. */
  74075. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74076. /**
  74077. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74078. */
  74079. stopRecording(): void;
  74080. /**
  74081. * Starts recording the canvas for a max duration specified in parameters.
  74082. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74083. * If null no automatic download will start and you can rely on the promise to get the data back.
  74084. * @param maxDuration Defines the maximum recording time in seconds.
  74085. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74086. * @return A promise callback at the end of the recording with the video data in Blob.
  74087. */
  74088. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74089. /**
  74090. * Releases internal resources used during the recording.
  74091. */
  74092. dispose(): void;
  74093. private _handleDataAvailable;
  74094. private _handleError;
  74095. private _handleStop;
  74096. }
  74097. }
  74098. declare module BABYLON {
  74099. /**
  74100. * Class containing a set of static utilities functions for screenshots
  74101. */
  74102. export class ScreenshotTools {
  74103. /**
  74104. * Captures a screenshot of the current rendering
  74105. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74106. * @param engine defines the rendering engine
  74107. * @param camera defines the source camera
  74108. * @param size This parameter can be set to a single number or to an object with the
  74109. * following (optional) properties: precision, width, height. If a single number is passed,
  74110. * it will be used for both width and height. If an object is passed, the screenshot size
  74111. * will be derived from the parameters. The precision property is a multiplier allowing
  74112. * rendering at a higher or lower resolution
  74113. * @param successCallback defines the callback receives a single parameter which contains the
  74114. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74115. * src parameter of an <img> to display it
  74116. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74117. * Check your browser for supported MIME types
  74118. */
  74119. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74120. /**
  74121. * Captures a screenshot of the current rendering
  74122. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74123. * @param engine defines the rendering engine
  74124. * @param camera defines the source camera
  74125. * @param size This parameter can be set to a single number or to an object with the
  74126. * following (optional) properties: precision, width, height. If a single number is passed,
  74127. * it will be used for both width and height. If an object is passed, the screenshot size
  74128. * will be derived from the parameters. The precision property is a multiplier allowing
  74129. * rendering at a higher or lower resolution
  74130. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74131. * Check your browser for supported MIME types
  74132. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74133. * to the src parameter of an <img> to display it
  74134. */
  74135. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74136. /**
  74137. * Generates an image screenshot from the specified camera.
  74138. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74139. * @param engine The engine to use for rendering
  74140. * @param camera The camera to use for rendering
  74141. * @param size This parameter can be set to a single number or to an object with the
  74142. * following (optional) properties: precision, width, height. If a single number is passed,
  74143. * it will be used for both width and height. If an object is passed, the screenshot size
  74144. * will be derived from the parameters. The precision property is a multiplier allowing
  74145. * rendering at a higher or lower resolution
  74146. * @param successCallback The callback receives a single parameter which contains the
  74147. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74148. * src parameter of an <img> to display it
  74149. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74150. * Check your browser for supported MIME types
  74151. * @param samples Texture samples (default: 1)
  74152. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74153. * @param fileName A name for for the downloaded file.
  74154. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74155. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74156. */
  74157. 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;
  74158. /**
  74159. * Generates an image screenshot from the specified camera.
  74160. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74161. * @param engine The engine to use for rendering
  74162. * @param camera The camera to use for rendering
  74163. * @param size This parameter can be set to a single number or to an object with the
  74164. * following (optional) properties: precision, width, height. If a single number is passed,
  74165. * it will be used for both width and height. If an object is passed, the screenshot size
  74166. * will be derived from the parameters. The precision property is a multiplier allowing
  74167. * rendering at a higher or lower resolution
  74168. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74169. * Check your browser for supported MIME types
  74170. * @param samples Texture samples (default: 1)
  74171. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74172. * @param fileName A name for for the downloaded file.
  74173. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74174. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74175. * to the src parameter of an <img> to display it
  74176. */
  74177. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74178. /**
  74179. * Gets height and width for screenshot size
  74180. * @private
  74181. */
  74182. private static _getScreenshotSize;
  74183. }
  74184. }
  74185. declare module BABYLON {
  74186. /**
  74187. * Interface for a data buffer
  74188. */
  74189. export interface IDataBuffer {
  74190. /**
  74191. * Reads bytes from the data buffer.
  74192. * @param byteOffset The byte offset to read
  74193. * @param byteLength The byte length to read
  74194. * @returns A promise that resolves when the bytes are read
  74195. */
  74196. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74197. /**
  74198. * The byte length of the buffer.
  74199. */
  74200. readonly byteLength: number;
  74201. }
  74202. /**
  74203. * Utility class for reading from a data buffer
  74204. */
  74205. export class DataReader {
  74206. /**
  74207. * The data buffer associated with this data reader.
  74208. */
  74209. readonly buffer: IDataBuffer;
  74210. /**
  74211. * The current byte offset from the beginning of the data buffer.
  74212. */
  74213. byteOffset: number;
  74214. private _dataView;
  74215. private _dataByteOffset;
  74216. /**
  74217. * Constructor
  74218. * @param buffer The buffer to read
  74219. */
  74220. constructor(buffer: IDataBuffer);
  74221. /**
  74222. * Loads the given byte length.
  74223. * @param byteLength The byte length to load
  74224. * @returns A promise that resolves when the load is complete
  74225. */
  74226. loadAsync(byteLength: number): Promise<void>;
  74227. /**
  74228. * Read a unsigned 32-bit integer from the currently loaded data range.
  74229. * @returns The 32-bit integer read
  74230. */
  74231. readUint32(): number;
  74232. /**
  74233. * Read a byte array from the currently loaded data range.
  74234. * @param byteLength The byte length to read
  74235. * @returns The byte array read
  74236. */
  74237. readUint8Array(byteLength: number): Uint8Array;
  74238. /**
  74239. * Read a string from the currently loaded data range.
  74240. * @param byteLength The byte length to read
  74241. * @returns The string read
  74242. */
  74243. readString(byteLength: number): string;
  74244. /**
  74245. * Skips the given byte length the currently loaded data range.
  74246. * @param byteLength The byte length to skip
  74247. */
  74248. skipBytes(byteLength: number): void;
  74249. }
  74250. }
  74251. declare module BABYLON {
  74252. /**
  74253. * Class for storing data to local storage if available or in-memory storage otherwise
  74254. */
  74255. export class DataStorage {
  74256. private static _Storage;
  74257. private static _GetStorage;
  74258. /**
  74259. * Reads a string from the data storage
  74260. * @param key The key to read
  74261. * @param defaultValue The value if the key doesn't exist
  74262. * @returns The string value
  74263. */
  74264. static ReadString(key: string, defaultValue: string): string;
  74265. /**
  74266. * Writes a string to the data storage
  74267. * @param key The key to write
  74268. * @param value The value to write
  74269. */
  74270. static WriteString(key: string, value: string): void;
  74271. /**
  74272. * Reads a boolean from the data storage
  74273. * @param key The key to read
  74274. * @param defaultValue The value if the key doesn't exist
  74275. * @returns The boolean value
  74276. */
  74277. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74278. /**
  74279. * Writes a boolean to the data storage
  74280. * @param key The key to write
  74281. * @param value The value to write
  74282. */
  74283. static WriteBoolean(key: string, value: boolean): void;
  74284. /**
  74285. * Reads a number from the data storage
  74286. * @param key The key to read
  74287. * @param defaultValue The value if the key doesn't exist
  74288. * @returns The number value
  74289. */
  74290. static ReadNumber(key: string, defaultValue: number): number;
  74291. /**
  74292. * Writes a number to the data storage
  74293. * @param key The key to write
  74294. * @param value The value to write
  74295. */
  74296. static WriteNumber(key: string, value: number): void;
  74297. }
  74298. }
  74299. declare module BABYLON {
  74300. /**
  74301. * Class used to record delta files between 2 scene states
  74302. */
  74303. export class SceneRecorder {
  74304. private _trackedScene;
  74305. private _savedJSON;
  74306. /**
  74307. * Track a given scene. This means the current scene state will be considered the original state
  74308. * @param scene defines the scene to track
  74309. */
  74310. track(scene: Scene): void;
  74311. /**
  74312. * Get the delta between current state and original state
  74313. * @returns a string containing the delta
  74314. */
  74315. getDelta(): any;
  74316. private _compareArray;
  74317. private _compareObjects;
  74318. private _compareCollections;
  74319. private static GetShadowGeneratorById;
  74320. /**
  74321. * Apply a given delta to a given scene
  74322. * @param deltaJSON defines the JSON containing the delta
  74323. * @param scene defines the scene to apply the delta to
  74324. */
  74325. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74326. private static _ApplyPropertiesToEntity;
  74327. private static _ApplyDeltaForEntity;
  74328. }
  74329. }
  74330. declare module BABYLON {
  74331. /**
  74332. * An interface for all Hit test features
  74333. */
  74334. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74335. /**
  74336. * Triggered when new babylon (transformed) hit test results are available
  74337. */
  74338. onHitTestResultObservable: Observable<T[]>;
  74339. }
  74340. /**
  74341. * Options used for hit testing
  74342. */
  74343. export interface IWebXRLegacyHitTestOptions {
  74344. /**
  74345. * Only test when user interacted with the scene. Default - hit test every frame
  74346. */
  74347. testOnPointerDownOnly?: boolean;
  74348. /**
  74349. * The node to use to transform the local results to world coordinates
  74350. */
  74351. worldParentNode?: TransformNode;
  74352. }
  74353. /**
  74354. * Interface defining the babylon result of raycasting/hit-test
  74355. */
  74356. export interface IWebXRLegacyHitResult {
  74357. /**
  74358. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74359. */
  74360. transformationMatrix: Matrix;
  74361. /**
  74362. * The native hit test result
  74363. */
  74364. xrHitResult: XRHitResult | XRHitTestResult;
  74365. }
  74366. /**
  74367. * The currently-working hit-test module.
  74368. * Hit test (or Ray-casting) is used to interact with the real world.
  74369. * For further information read here - https://github.com/immersive-web/hit-test
  74370. */
  74371. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74372. /**
  74373. * options to use when constructing this feature
  74374. */
  74375. readonly options: IWebXRLegacyHitTestOptions;
  74376. private _direction;
  74377. private _mat;
  74378. private _onSelectEnabled;
  74379. private _origin;
  74380. /**
  74381. * The module's name
  74382. */
  74383. static readonly Name: string;
  74384. /**
  74385. * The (Babylon) version of this module.
  74386. * This is an integer representing the implementation version.
  74387. * This number does not correspond to the WebXR specs version
  74388. */
  74389. static readonly Version: number;
  74390. /**
  74391. * Populated with the last native XR Hit Results
  74392. */
  74393. lastNativeXRHitResults: XRHitResult[];
  74394. /**
  74395. * Triggered when new babylon (transformed) hit test results are available
  74396. */
  74397. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74398. /**
  74399. * Creates a new instance of the (legacy version) hit test feature
  74400. * @param _xrSessionManager an instance of WebXRSessionManager
  74401. * @param options options to use when constructing this feature
  74402. */
  74403. constructor(_xrSessionManager: WebXRSessionManager,
  74404. /**
  74405. * options to use when constructing this feature
  74406. */
  74407. options?: IWebXRLegacyHitTestOptions);
  74408. /**
  74409. * execute a hit test with an XR Ray
  74410. *
  74411. * @param xrSession a native xrSession that will execute this hit test
  74412. * @param xrRay the ray (position and direction) to use for ray-casting
  74413. * @param referenceSpace native XR reference space to use for the hit-test
  74414. * @param filter filter function that will filter the results
  74415. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74416. */
  74417. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74418. /**
  74419. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74420. * @param event the (select) event to use to select with
  74421. * @param referenceSpace the reference space to use for this hit test
  74422. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74423. */
  74424. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74425. /**
  74426. * attach this feature
  74427. * Will usually be called by the features manager
  74428. *
  74429. * @returns true if successful.
  74430. */
  74431. attach(): boolean;
  74432. /**
  74433. * detach this feature.
  74434. * Will usually be called by the features manager
  74435. *
  74436. * @returns true if successful.
  74437. */
  74438. detach(): boolean;
  74439. /**
  74440. * Dispose this feature and all of the resources attached
  74441. */
  74442. dispose(): void;
  74443. protected _onXRFrame(frame: XRFrame): void;
  74444. private _onHitTestResults;
  74445. private _onSelect;
  74446. }
  74447. }
  74448. declare module BABYLON {
  74449. /**
  74450. * Options used for hit testing (version 2)
  74451. */
  74452. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74453. /**
  74454. * Do not create a permanent hit test. Will usually be used when only
  74455. * transient inputs are needed.
  74456. */
  74457. disablePermanentHitTest?: boolean;
  74458. /**
  74459. * Enable transient (for example touch-based) hit test inspections
  74460. */
  74461. enableTransientHitTest?: boolean;
  74462. /**
  74463. * Offset ray for the permanent hit test
  74464. */
  74465. offsetRay?: Vector3;
  74466. /**
  74467. * Offset ray for the transient hit test
  74468. */
  74469. transientOffsetRay?: Vector3;
  74470. /**
  74471. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74472. */
  74473. useReferenceSpace?: boolean;
  74474. /**
  74475. * Override the default entity type(s) of the hit-test result
  74476. */
  74477. entityTypes?: XRHitTestTrackableType[];
  74478. }
  74479. /**
  74480. * Interface defining the babylon result of hit-test
  74481. */
  74482. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74483. /**
  74484. * The input source that generated this hit test (if transient)
  74485. */
  74486. inputSource?: XRInputSource;
  74487. /**
  74488. * Is this a transient hit test
  74489. */
  74490. isTransient?: boolean;
  74491. /**
  74492. * Position of the hit test result
  74493. */
  74494. position: Vector3;
  74495. /**
  74496. * Rotation of the hit test result
  74497. */
  74498. rotationQuaternion: Quaternion;
  74499. /**
  74500. * The native hit test result
  74501. */
  74502. xrHitResult: XRHitTestResult;
  74503. }
  74504. /**
  74505. * The currently-working hit-test module.
  74506. * Hit test (or Ray-casting) is used to interact with the real world.
  74507. * For further information read here - https://github.com/immersive-web/hit-test
  74508. *
  74509. * Tested on chrome (mobile) 80.
  74510. */
  74511. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74512. /**
  74513. * options to use when constructing this feature
  74514. */
  74515. readonly options: IWebXRHitTestOptions;
  74516. private _tmpMat;
  74517. private _tmpPos;
  74518. private _tmpQuat;
  74519. private _transientXrHitTestSource;
  74520. private _xrHitTestSource;
  74521. private initHitTestSource;
  74522. /**
  74523. * The module's name
  74524. */
  74525. static readonly Name: string;
  74526. /**
  74527. * The (Babylon) version of this module.
  74528. * This is an integer representing the implementation version.
  74529. * This number does not correspond to the WebXR specs version
  74530. */
  74531. static readonly Version: number;
  74532. /**
  74533. * When set to true, each hit test will have its own position/rotation objects
  74534. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74535. * the developers will clone them or copy them as they see fit.
  74536. */
  74537. autoCloneTransformation: boolean;
  74538. /**
  74539. * Triggered when new babylon (transformed) hit test results are available
  74540. * Note - this will be called when results come back from the device. It can be an empty array!!
  74541. */
  74542. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74543. /**
  74544. * Use this to temporarily pause hit test checks.
  74545. */
  74546. paused: boolean;
  74547. /**
  74548. * Creates a new instance of the hit test feature
  74549. * @param _xrSessionManager an instance of WebXRSessionManager
  74550. * @param options options to use when constructing this feature
  74551. */
  74552. constructor(_xrSessionManager: WebXRSessionManager,
  74553. /**
  74554. * options to use when constructing this feature
  74555. */
  74556. options?: IWebXRHitTestOptions);
  74557. /**
  74558. * attach this feature
  74559. * Will usually be called by the features manager
  74560. *
  74561. * @returns true if successful.
  74562. */
  74563. attach(): boolean;
  74564. /**
  74565. * detach this feature.
  74566. * Will usually be called by the features manager
  74567. *
  74568. * @returns true if successful.
  74569. */
  74570. detach(): boolean;
  74571. /**
  74572. * Dispose this feature and all of the resources attached
  74573. */
  74574. dispose(): void;
  74575. protected _onXRFrame(frame: XRFrame): void;
  74576. private _processWebXRHitTestResult;
  74577. }
  74578. }
  74579. declare module BABYLON {
  74580. /**
  74581. * Configuration options of the anchor system
  74582. */
  74583. export interface IWebXRAnchorSystemOptions {
  74584. /**
  74585. * a node that will be used to convert local to world coordinates
  74586. */
  74587. worldParentNode?: TransformNode;
  74588. /**
  74589. * If set to true a reference of the created anchors will be kept until the next session starts
  74590. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74591. */
  74592. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74593. }
  74594. /**
  74595. * A babylon container for an XR Anchor
  74596. */
  74597. export interface IWebXRAnchor {
  74598. /**
  74599. * A babylon-assigned ID for this anchor
  74600. */
  74601. id: number;
  74602. /**
  74603. * Transformation matrix to apply to an object attached to this anchor
  74604. */
  74605. transformationMatrix: Matrix;
  74606. /**
  74607. * The native anchor object
  74608. */
  74609. xrAnchor: XRAnchor;
  74610. /**
  74611. * if defined, this object will be constantly updated by the anchor's position and rotation
  74612. */
  74613. attachedNode?: TransformNode;
  74614. }
  74615. /**
  74616. * An implementation of the anchor system for WebXR.
  74617. * For further information see https://github.com/immersive-web/anchors/
  74618. */
  74619. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74620. private _options;
  74621. private _lastFrameDetected;
  74622. private _trackedAnchors;
  74623. private _referenceSpaceForFrameAnchors;
  74624. private _futureAnchors;
  74625. /**
  74626. * The module's name
  74627. */
  74628. static readonly Name: string;
  74629. /**
  74630. * The (Babylon) version of this module.
  74631. * This is an integer representing the implementation version.
  74632. * This number does not correspond to the WebXR specs version
  74633. */
  74634. static readonly Version: number;
  74635. /**
  74636. * Observers registered here will be executed when a new anchor was added to the session
  74637. */
  74638. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74639. /**
  74640. * Observers registered here will be executed when an anchor was removed from the session
  74641. */
  74642. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74643. /**
  74644. * Observers registered here will be executed when an existing anchor updates
  74645. * This can execute N times every frame
  74646. */
  74647. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74648. /**
  74649. * Set the reference space to use for anchor creation, when not using a hit test.
  74650. * Will default to the session's reference space if not defined
  74651. */
  74652. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74653. /**
  74654. * constructs a new anchor system
  74655. * @param _xrSessionManager an instance of WebXRSessionManager
  74656. * @param _options configuration object for this feature
  74657. */
  74658. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74659. private _tmpVector;
  74660. private _tmpQuaternion;
  74661. private _populateTmpTransformation;
  74662. /**
  74663. * Create a new anchor point using a hit test result at a specific point in the scene
  74664. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74665. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74666. *
  74667. * @param hitTestResult The hit test result to use for this anchor creation
  74668. * @param position an optional position offset for this anchor
  74669. * @param rotationQuaternion an optional rotation offset for this anchor
  74670. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74671. */
  74672. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74673. /**
  74674. * Add a new anchor at a specific position and rotation
  74675. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74676. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74677. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74678. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74679. *
  74680. * @param position the position in which to add an anchor
  74681. * @param rotationQuaternion an optional rotation for the anchor transformation
  74682. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74683. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74684. */
  74685. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74686. /**
  74687. * detach this feature.
  74688. * Will usually be called by the features manager
  74689. *
  74690. * @returns true if successful.
  74691. */
  74692. detach(): boolean;
  74693. /**
  74694. * Dispose this feature and all of the resources attached
  74695. */
  74696. dispose(): void;
  74697. protected _onXRFrame(frame: XRFrame): void;
  74698. /**
  74699. * avoiding using Array.find for global support.
  74700. * @param xrAnchor the plane to find in the array
  74701. */
  74702. private _findIndexInAnchorArray;
  74703. private _updateAnchorWithXRFrame;
  74704. private _createAnchorAtTransformation;
  74705. }
  74706. }
  74707. declare module BABYLON {
  74708. /**
  74709. * Options used in the plane detector module
  74710. */
  74711. export interface IWebXRPlaneDetectorOptions {
  74712. /**
  74713. * The node to use to transform the local results to world coordinates
  74714. */
  74715. worldParentNode?: TransformNode;
  74716. /**
  74717. * If set to true a reference of the created planes will be kept until the next session starts
  74718. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74719. */
  74720. doNotRemovePlanesOnSessionEnded?: boolean;
  74721. }
  74722. /**
  74723. * A babylon interface for a WebXR plane.
  74724. * A Plane is actually a polygon, built from N points in space
  74725. *
  74726. * Supported in chrome 79, not supported in canary 81 ATM
  74727. */
  74728. export interface IWebXRPlane {
  74729. /**
  74730. * a babylon-assigned ID for this polygon
  74731. */
  74732. id: number;
  74733. /**
  74734. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74735. */
  74736. polygonDefinition: Array<Vector3>;
  74737. /**
  74738. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74739. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74740. */
  74741. transformationMatrix: Matrix;
  74742. /**
  74743. * the native xr-plane object
  74744. */
  74745. xrPlane: XRPlane;
  74746. }
  74747. /**
  74748. * The plane detector is used to detect planes in the real world when in AR
  74749. * For more information see https://github.com/immersive-web/real-world-geometry/
  74750. */
  74751. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74752. private _options;
  74753. private _detectedPlanes;
  74754. private _enabled;
  74755. private _lastFrameDetected;
  74756. /**
  74757. * The module's name
  74758. */
  74759. static readonly Name: string;
  74760. /**
  74761. * The (Babylon) version of this module.
  74762. * This is an integer representing the implementation version.
  74763. * This number does not correspond to the WebXR specs version
  74764. */
  74765. static readonly Version: number;
  74766. /**
  74767. * Observers registered here will be executed when a new plane was added to the session
  74768. */
  74769. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74770. /**
  74771. * Observers registered here will be executed when a plane is no longer detected in the session
  74772. */
  74773. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74774. /**
  74775. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74776. * This can execute N times every frame
  74777. */
  74778. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74779. /**
  74780. * construct a new Plane Detector
  74781. * @param _xrSessionManager an instance of xr Session manager
  74782. * @param _options configuration to use when constructing this feature
  74783. */
  74784. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74785. /**
  74786. * detach this feature.
  74787. * Will usually be called by the features manager
  74788. *
  74789. * @returns true if successful.
  74790. */
  74791. detach(): boolean;
  74792. /**
  74793. * Dispose this feature and all of the resources attached
  74794. */
  74795. dispose(): void;
  74796. protected _onXRFrame(frame: XRFrame): void;
  74797. private _init;
  74798. private _updatePlaneWithXRPlane;
  74799. /**
  74800. * avoiding using Array.find for global support.
  74801. * @param xrPlane the plane to find in the array
  74802. */
  74803. private findIndexInPlaneArray;
  74804. }
  74805. }
  74806. declare module BABYLON {
  74807. /**
  74808. * Options interface for the background remover plugin
  74809. */
  74810. export interface IWebXRBackgroundRemoverOptions {
  74811. /**
  74812. * Further background meshes to disable when entering AR
  74813. */
  74814. backgroundMeshes?: AbstractMesh[];
  74815. /**
  74816. * flags to configure the removal of the environment helper.
  74817. * If not set, the entire background will be removed. If set, flags should be set as well.
  74818. */
  74819. environmentHelperRemovalFlags?: {
  74820. /**
  74821. * Should the skybox be removed (default false)
  74822. */
  74823. skyBox?: boolean;
  74824. /**
  74825. * Should the ground be removed (default false)
  74826. */
  74827. ground?: boolean;
  74828. };
  74829. /**
  74830. * don't disable the environment helper
  74831. */
  74832. ignoreEnvironmentHelper?: boolean;
  74833. }
  74834. /**
  74835. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74836. */
  74837. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74838. /**
  74839. * read-only options to be used in this module
  74840. */
  74841. readonly options: IWebXRBackgroundRemoverOptions;
  74842. /**
  74843. * The module's name
  74844. */
  74845. static readonly Name: string;
  74846. /**
  74847. * The (Babylon) version of this module.
  74848. * This is an integer representing the implementation version.
  74849. * This number does not correspond to the WebXR specs version
  74850. */
  74851. static readonly Version: number;
  74852. /**
  74853. * registered observers will be triggered when the background state changes
  74854. */
  74855. onBackgroundStateChangedObservable: Observable<boolean>;
  74856. /**
  74857. * constructs a new background remover module
  74858. * @param _xrSessionManager the session manager for this module
  74859. * @param options read-only options to be used in this module
  74860. */
  74861. constructor(_xrSessionManager: WebXRSessionManager,
  74862. /**
  74863. * read-only options to be used in this module
  74864. */
  74865. options?: IWebXRBackgroundRemoverOptions);
  74866. /**
  74867. * attach this feature
  74868. * Will usually be called by the features manager
  74869. *
  74870. * @returns true if successful.
  74871. */
  74872. attach(): boolean;
  74873. /**
  74874. * detach this feature.
  74875. * Will usually be called by the features manager
  74876. *
  74877. * @returns true if successful.
  74878. */
  74879. detach(): boolean;
  74880. /**
  74881. * Dispose this feature and all of the resources attached
  74882. */
  74883. dispose(): void;
  74884. protected _onXRFrame(_xrFrame: XRFrame): void;
  74885. private _setBackgroundState;
  74886. }
  74887. }
  74888. declare module BABYLON {
  74889. /**
  74890. * Options for the controller physics feature
  74891. */
  74892. export class IWebXRControllerPhysicsOptions {
  74893. /**
  74894. * Should the headset get its own impostor
  74895. */
  74896. enableHeadsetImpostor?: boolean;
  74897. /**
  74898. * Optional parameters for the headset impostor
  74899. */
  74900. headsetImpostorParams?: {
  74901. /**
  74902. * The type of impostor to create. Default is sphere
  74903. */
  74904. impostorType: number;
  74905. /**
  74906. * the size of the impostor. Defaults to 10cm
  74907. */
  74908. impostorSize?: number | {
  74909. width: number;
  74910. height: number;
  74911. depth: number;
  74912. };
  74913. /**
  74914. * Friction definitions
  74915. */
  74916. friction?: number;
  74917. /**
  74918. * Restitution
  74919. */
  74920. restitution?: number;
  74921. };
  74922. /**
  74923. * The physics properties of the future impostors
  74924. */
  74925. physicsProperties?: {
  74926. /**
  74927. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74928. * Note that this requires a physics engine that supports mesh impostors!
  74929. */
  74930. useControllerMesh?: boolean;
  74931. /**
  74932. * The type of impostor to create. Default is sphere
  74933. */
  74934. impostorType?: number;
  74935. /**
  74936. * the size of the impostor. Defaults to 10cm
  74937. */
  74938. impostorSize?: number | {
  74939. width: number;
  74940. height: number;
  74941. depth: number;
  74942. };
  74943. /**
  74944. * Friction definitions
  74945. */
  74946. friction?: number;
  74947. /**
  74948. * Restitution
  74949. */
  74950. restitution?: number;
  74951. };
  74952. /**
  74953. * the xr input to use with this pointer selection
  74954. */
  74955. xrInput: WebXRInput;
  74956. }
  74957. /**
  74958. * Add physics impostor to your webxr controllers,
  74959. * including naive calculation of their linear and angular velocity
  74960. */
  74961. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74962. private readonly _options;
  74963. private _attachController;
  74964. private _controllers;
  74965. private _debugMode;
  74966. private _delta;
  74967. private _headsetImpostor?;
  74968. private _headsetMesh?;
  74969. private _lastTimestamp;
  74970. private _tmpQuaternion;
  74971. private _tmpVector;
  74972. /**
  74973. * The module's name
  74974. */
  74975. static readonly Name: string;
  74976. /**
  74977. * The (Babylon) version of this module.
  74978. * This is an integer representing the implementation version.
  74979. * This number does not correspond to the webxr specs version
  74980. */
  74981. static readonly Version: number;
  74982. /**
  74983. * Construct a new Controller Physics Feature
  74984. * @param _xrSessionManager the corresponding xr session manager
  74985. * @param _options options to create this feature with
  74986. */
  74987. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74988. /**
  74989. * @hidden
  74990. * enable debugging - will show console outputs and the impostor mesh
  74991. */
  74992. _enablePhysicsDebug(): void;
  74993. /**
  74994. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74995. * @param xrController the controller to add
  74996. */
  74997. addController(xrController: WebXRInputSource): void;
  74998. /**
  74999. * attach this feature
  75000. * Will usually be called by the features manager
  75001. *
  75002. * @returns true if successful.
  75003. */
  75004. attach(): boolean;
  75005. /**
  75006. * detach this feature.
  75007. * Will usually be called by the features manager
  75008. *
  75009. * @returns true if successful.
  75010. */
  75011. detach(): boolean;
  75012. /**
  75013. * Get the headset impostor, if enabled
  75014. * @returns the impostor
  75015. */
  75016. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75017. /**
  75018. * Get the physics impostor of a specific controller.
  75019. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75020. * @param controller the controller or the controller id of which to get the impostor
  75021. * @returns the impostor or null
  75022. */
  75023. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75024. /**
  75025. * Update the physics properties provided in the constructor
  75026. * @param newProperties the new properties object
  75027. */
  75028. setPhysicsProperties(newProperties: {
  75029. impostorType?: number;
  75030. impostorSize?: number | {
  75031. width: number;
  75032. height: number;
  75033. depth: number;
  75034. };
  75035. friction?: number;
  75036. restitution?: number;
  75037. }): void;
  75038. protected _onXRFrame(_xrFrame: any): void;
  75039. private _detachController;
  75040. }
  75041. }
  75042. declare module BABYLON {
  75043. /**
  75044. * A babylon interface for a "WebXR" feature point.
  75045. * Represents the position and confidence value of a given feature point.
  75046. */
  75047. export interface IWebXRFeaturePoint {
  75048. /**
  75049. * Represents the position of the feature point in world space.
  75050. */
  75051. position: Vector3;
  75052. /**
  75053. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75054. */
  75055. confidenceValue: number;
  75056. }
  75057. /**
  75058. * The feature point system is used to detect feature points from real world geometry.
  75059. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75060. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75061. */
  75062. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75063. private _enabled;
  75064. private _featurePointCloud;
  75065. /**
  75066. * The module's name
  75067. */
  75068. static readonly Name: string;
  75069. /**
  75070. * The (Babylon) version of this module.
  75071. * This is an integer representing the implementation version.
  75072. * This number does not correspond to the WebXR specs version
  75073. */
  75074. static readonly Version: number;
  75075. /**
  75076. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75077. * Will notify the observers about which feature points have been added.
  75078. */
  75079. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75080. /**
  75081. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75082. * Will notify the observers about which feature points have been updated.
  75083. */
  75084. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75085. /**
  75086. * The current feature point cloud maintained across frames.
  75087. */
  75088. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75089. /**
  75090. * construct the feature point system
  75091. * @param _xrSessionManager an instance of xr Session manager
  75092. */
  75093. constructor(_xrSessionManager: WebXRSessionManager);
  75094. /**
  75095. * Detach this feature.
  75096. * Will usually be called by the features manager
  75097. *
  75098. * @returns true if successful.
  75099. */
  75100. detach(): boolean;
  75101. /**
  75102. * Dispose this feature and all of the resources attached
  75103. */
  75104. dispose(): void;
  75105. /**
  75106. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75107. */
  75108. protected _onXRFrame(frame: XRFrame): void;
  75109. /**
  75110. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75111. */
  75112. private _init;
  75113. }
  75114. }
  75115. declare module BABYLON {
  75116. /**
  75117. * Configuration interface for the hand tracking feature
  75118. */
  75119. export interface IWebXRHandTrackingOptions {
  75120. /**
  75121. * The xrInput that will be used as source for new hands
  75122. */
  75123. xrInput: WebXRInput;
  75124. /**
  75125. * Configuration object for the joint meshes
  75126. */
  75127. jointMeshes?: {
  75128. /**
  75129. * Should the meshes created be invisible (defaults to false)
  75130. */
  75131. invisible?: boolean;
  75132. /**
  75133. * A source mesh to be used to create instances. Defaults to a sphere.
  75134. * This mesh will be the source for all other (25) meshes.
  75135. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75136. */
  75137. sourceMesh?: Mesh;
  75138. /**
  75139. * Should the source mesh stay visible. Defaults to false
  75140. */
  75141. keepOriginalVisible?: boolean;
  75142. /**
  75143. * Scale factor for all instances (defaults to 2)
  75144. */
  75145. scaleFactor?: number;
  75146. /**
  75147. * Should each instance have its own physics impostor
  75148. */
  75149. enablePhysics?: boolean;
  75150. /**
  75151. * If enabled, override default physics properties
  75152. */
  75153. physicsProps?: {
  75154. friction?: number;
  75155. restitution?: number;
  75156. impostorType?: number;
  75157. };
  75158. /**
  75159. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75160. */
  75161. handMesh?: AbstractMesh;
  75162. };
  75163. }
  75164. /**
  75165. * Parts of the hands divided to writs and finger names
  75166. */
  75167. export const enum HandPart {
  75168. /**
  75169. * HandPart - Wrist
  75170. */
  75171. WRIST = "wrist",
  75172. /**
  75173. * HandPart - The THumb
  75174. */
  75175. THUMB = "thumb",
  75176. /**
  75177. * HandPart - Index finger
  75178. */
  75179. INDEX = "index",
  75180. /**
  75181. * HandPart - Middle finger
  75182. */
  75183. MIDDLE = "middle",
  75184. /**
  75185. * HandPart - Ring finger
  75186. */
  75187. RING = "ring",
  75188. /**
  75189. * HandPart - Little finger
  75190. */
  75191. LITTLE = "little"
  75192. }
  75193. /**
  75194. * Representing a single hand (with its corresponding native XRHand object)
  75195. */
  75196. export class WebXRHand implements IDisposable {
  75197. /** the controller to which the hand correlates */
  75198. readonly xrController: WebXRInputSource;
  75199. /** the meshes to be used to track the hand joints */
  75200. readonly trackedMeshes: AbstractMesh[];
  75201. /**
  75202. * Hand-parts definition (key is HandPart)
  75203. */
  75204. handPartsDefinition: {
  75205. [key: string]: number[];
  75206. };
  75207. /**
  75208. * Populate the HandPartsDefinition object.
  75209. * This is called as a side effect since certain browsers don't have XRHand defined.
  75210. */
  75211. private generateHandPartsDefinition;
  75212. /**
  75213. * Construct a new hand object
  75214. * @param xrController the controller to which the hand correlates
  75215. * @param trackedMeshes the meshes to be used to track the hand joints
  75216. */
  75217. constructor(
  75218. /** the controller to which the hand correlates */
  75219. xrController: WebXRInputSource,
  75220. /** the meshes to be used to track the hand joints */
  75221. trackedMeshes: AbstractMesh[]);
  75222. /**
  75223. * Update this hand from the latest xr frame
  75224. * @param xrFrame xrFrame to update from
  75225. * @param referenceSpace The current viewer reference space
  75226. * @param scaleFactor optional scale factor for the meshes
  75227. */
  75228. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75229. /**
  75230. * Get meshes of part of the hand
  75231. * @param part the part of hand to get
  75232. * @returns An array of meshes that correlate to the hand part requested
  75233. */
  75234. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75235. /**
  75236. * Dispose this Hand object
  75237. */
  75238. dispose(): void;
  75239. }
  75240. /**
  75241. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75242. */
  75243. export class WebXRHandTracking extends WebXRAbstractFeature {
  75244. /**
  75245. * options to use when constructing this feature
  75246. */
  75247. readonly options: IWebXRHandTrackingOptions;
  75248. private static _idCounter;
  75249. /**
  75250. * The module's name
  75251. */
  75252. static readonly Name: string;
  75253. /**
  75254. * The (Babylon) version of this module.
  75255. * This is an integer representing the implementation version.
  75256. * This number does not correspond to the WebXR specs version
  75257. */
  75258. static readonly Version: number;
  75259. /**
  75260. * This observable will notify registered observers when a new hand object was added and initialized
  75261. */
  75262. onHandAddedObservable: Observable<WebXRHand>;
  75263. /**
  75264. * This observable will notify its observers right before the hand object is disposed
  75265. */
  75266. onHandRemovedObservable: Observable<WebXRHand>;
  75267. private _hands;
  75268. /**
  75269. * Creates a new instance of the hit test feature
  75270. * @param _xrSessionManager an instance of WebXRSessionManager
  75271. * @param options options to use when constructing this feature
  75272. */
  75273. constructor(_xrSessionManager: WebXRSessionManager,
  75274. /**
  75275. * options to use when constructing this feature
  75276. */
  75277. options: IWebXRHandTrackingOptions);
  75278. /**
  75279. * Check if the needed objects are defined.
  75280. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75281. */
  75282. isCompatible(): boolean;
  75283. /**
  75284. * attach this feature
  75285. * Will usually be called by the features manager
  75286. *
  75287. * @returns true if successful.
  75288. */
  75289. attach(): boolean;
  75290. /**
  75291. * detach this feature.
  75292. * Will usually be called by the features manager
  75293. *
  75294. * @returns true if successful.
  75295. */
  75296. detach(): boolean;
  75297. /**
  75298. * Dispose this feature and all of the resources attached
  75299. */
  75300. dispose(): void;
  75301. /**
  75302. * Get the hand object according to the controller id
  75303. * @param controllerId the controller id to which we want to get the hand
  75304. * @returns null if not found or the WebXRHand object if found
  75305. */
  75306. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75307. /**
  75308. * Get a hand object according to the requested handedness
  75309. * @param handedness the handedness to request
  75310. * @returns null if not found or the WebXRHand object if found
  75311. */
  75312. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75313. protected _onXRFrame(_xrFrame: XRFrame): void;
  75314. private _attachHand;
  75315. private _detachHand;
  75316. }
  75317. }
  75318. declare module BABYLON {
  75319. /**
  75320. * The motion controller class for all microsoft mixed reality controllers
  75321. */
  75322. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75323. protected readonly _mapping: {
  75324. defaultButton: {
  75325. valueNodeName: string;
  75326. unpressedNodeName: string;
  75327. pressedNodeName: string;
  75328. };
  75329. defaultAxis: {
  75330. valueNodeName: string;
  75331. minNodeName: string;
  75332. maxNodeName: string;
  75333. };
  75334. buttons: {
  75335. "xr-standard-trigger": {
  75336. rootNodeName: string;
  75337. componentProperty: string;
  75338. states: string[];
  75339. };
  75340. "xr-standard-squeeze": {
  75341. rootNodeName: string;
  75342. componentProperty: string;
  75343. states: string[];
  75344. };
  75345. "xr-standard-touchpad": {
  75346. rootNodeName: string;
  75347. labelAnchorNodeName: string;
  75348. touchPointNodeName: string;
  75349. };
  75350. "xr-standard-thumbstick": {
  75351. rootNodeName: string;
  75352. componentProperty: string;
  75353. states: string[];
  75354. };
  75355. };
  75356. axes: {
  75357. "xr-standard-touchpad": {
  75358. "x-axis": {
  75359. rootNodeName: string;
  75360. };
  75361. "y-axis": {
  75362. rootNodeName: string;
  75363. };
  75364. };
  75365. "xr-standard-thumbstick": {
  75366. "x-axis": {
  75367. rootNodeName: string;
  75368. };
  75369. "y-axis": {
  75370. rootNodeName: string;
  75371. };
  75372. };
  75373. };
  75374. };
  75375. /**
  75376. * The base url used to load the left and right controller models
  75377. */
  75378. static MODEL_BASE_URL: string;
  75379. /**
  75380. * The name of the left controller model file
  75381. */
  75382. static MODEL_LEFT_FILENAME: string;
  75383. /**
  75384. * The name of the right controller model file
  75385. */
  75386. static MODEL_RIGHT_FILENAME: string;
  75387. profileId: string;
  75388. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75389. protected _getFilenameAndPath(): {
  75390. filename: string;
  75391. path: string;
  75392. };
  75393. protected _getModelLoadingConstraints(): boolean;
  75394. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75395. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75396. protected _updateModel(): void;
  75397. }
  75398. }
  75399. declare module BABYLON {
  75400. /**
  75401. * The motion controller class for oculus touch (quest, rift).
  75402. * This class supports legacy mapping as well the standard xr mapping
  75403. */
  75404. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75405. private _forceLegacyControllers;
  75406. private _modelRootNode;
  75407. /**
  75408. * The base url used to load the left and right controller models
  75409. */
  75410. static MODEL_BASE_URL: string;
  75411. /**
  75412. * The name of the left controller model file
  75413. */
  75414. static MODEL_LEFT_FILENAME: string;
  75415. /**
  75416. * The name of the right controller model file
  75417. */
  75418. static MODEL_RIGHT_FILENAME: string;
  75419. /**
  75420. * Base Url for the Quest controller model.
  75421. */
  75422. static QUEST_MODEL_BASE_URL: string;
  75423. profileId: string;
  75424. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75425. protected _getFilenameAndPath(): {
  75426. filename: string;
  75427. path: string;
  75428. };
  75429. protected _getModelLoadingConstraints(): boolean;
  75430. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75431. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75432. protected _updateModel(): void;
  75433. /**
  75434. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75435. * between the touch and touch 2.
  75436. */
  75437. private _isQuest;
  75438. }
  75439. }
  75440. declare module BABYLON {
  75441. /**
  75442. * The motion controller class for the standard HTC-Vive controllers
  75443. */
  75444. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75445. private _modelRootNode;
  75446. /**
  75447. * The base url used to load the left and right controller models
  75448. */
  75449. static MODEL_BASE_URL: string;
  75450. /**
  75451. * File name for the controller model.
  75452. */
  75453. static MODEL_FILENAME: string;
  75454. profileId: string;
  75455. /**
  75456. * Create a new Vive motion controller object
  75457. * @param scene the scene to use to create this controller
  75458. * @param gamepadObject the corresponding gamepad object
  75459. * @param handedness the handedness of the controller
  75460. */
  75461. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75462. protected _getFilenameAndPath(): {
  75463. filename: string;
  75464. path: string;
  75465. };
  75466. protected _getModelLoadingConstraints(): boolean;
  75467. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75468. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75469. protected _updateModel(): void;
  75470. }
  75471. }
  75472. declare module BABYLON {
  75473. /**
  75474. * A cursor which tracks a point on a path
  75475. */
  75476. export class PathCursor {
  75477. private path;
  75478. /**
  75479. * Stores path cursor callbacks for when an onchange event is triggered
  75480. */
  75481. private _onchange;
  75482. /**
  75483. * The value of the path cursor
  75484. */
  75485. value: number;
  75486. /**
  75487. * The animation array of the path cursor
  75488. */
  75489. animations: Animation[];
  75490. /**
  75491. * Initializes the path cursor
  75492. * @param path The path to track
  75493. */
  75494. constructor(path: Path2);
  75495. /**
  75496. * Gets the cursor point on the path
  75497. * @returns A point on the path cursor at the cursor location
  75498. */
  75499. getPoint(): Vector3;
  75500. /**
  75501. * Moves the cursor ahead by the step amount
  75502. * @param step The amount to move the cursor forward
  75503. * @returns This path cursor
  75504. */
  75505. moveAhead(step?: number): PathCursor;
  75506. /**
  75507. * Moves the cursor behind by the step amount
  75508. * @param step The amount to move the cursor back
  75509. * @returns This path cursor
  75510. */
  75511. moveBack(step?: number): PathCursor;
  75512. /**
  75513. * Moves the cursor by the step amount
  75514. * If the step amount is greater than one, an exception is thrown
  75515. * @param step The amount to move the cursor
  75516. * @returns This path cursor
  75517. */
  75518. move(step: number): PathCursor;
  75519. /**
  75520. * Ensures that the value is limited between zero and one
  75521. * @returns This path cursor
  75522. */
  75523. private ensureLimits;
  75524. /**
  75525. * Runs onchange callbacks on change (used by the animation engine)
  75526. * @returns This path cursor
  75527. */
  75528. private raiseOnChange;
  75529. /**
  75530. * Executes a function on change
  75531. * @param f A path cursor onchange callback
  75532. * @returns This path cursor
  75533. */
  75534. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75535. }
  75536. }
  75537. declare module BABYLON {
  75538. /** @hidden */
  75539. export var blurPixelShader: {
  75540. name: string;
  75541. shader: string;
  75542. };
  75543. }
  75544. declare module BABYLON {
  75545. /** @hidden */
  75546. export var pointCloudVertexDeclaration: {
  75547. name: string;
  75548. shader: string;
  75549. };
  75550. }
  75551. // Mixins
  75552. interface Window {
  75553. mozIndexedDB: IDBFactory;
  75554. webkitIndexedDB: IDBFactory;
  75555. msIndexedDB: IDBFactory;
  75556. webkitURL: typeof URL;
  75557. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75558. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75559. WebGLRenderingContext: WebGLRenderingContext;
  75560. MSGesture: MSGesture;
  75561. CANNON: any;
  75562. AudioContext: AudioContext;
  75563. webkitAudioContext: AudioContext;
  75564. PointerEvent: any;
  75565. Math: Math;
  75566. Uint8Array: Uint8ArrayConstructor;
  75567. Float32Array: Float32ArrayConstructor;
  75568. mozURL: typeof URL;
  75569. msURL: typeof URL;
  75570. VRFrameData: any; // WebVR, from specs 1.1
  75571. DracoDecoderModule: any;
  75572. setImmediate(handler: (...args: any[]) => void): number;
  75573. }
  75574. interface HTMLCanvasElement {
  75575. requestPointerLock(): void;
  75576. msRequestPointerLock?(): void;
  75577. mozRequestPointerLock?(): void;
  75578. webkitRequestPointerLock?(): void;
  75579. /** Track wether a record is in progress */
  75580. isRecording: boolean;
  75581. /** Capture Stream method defined by some browsers */
  75582. captureStream(fps?: number): MediaStream;
  75583. }
  75584. interface CanvasRenderingContext2D {
  75585. msImageSmoothingEnabled: boolean;
  75586. }
  75587. interface MouseEvent {
  75588. mozMovementX: number;
  75589. mozMovementY: number;
  75590. webkitMovementX: number;
  75591. webkitMovementY: number;
  75592. msMovementX: number;
  75593. msMovementY: number;
  75594. }
  75595. interface Navigator {
  75596. mozGetVRDevices: (any: any) => any;
  75597. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75598. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75599. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75600. webkitGetGamepads(): Gamepad[];
  75601. msGetGamepads(): Gamepad[];
  75602. webkitGamepads(): Gamepad[];
  75603. }
  75604. interface HTMLVideoElement {
  75605. mozSrcObject: any;
  75606. }
  75607. interface Math {
  75608. fround(x: number): number;
  75609. imul(a: number, b: number): number;
  75610. }
  75611. interface WebGLRenderingContext {
  75612. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75613. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75614. vertexAttribDivisor(index: number, divisor: number): void;
  75615. createVertexArray(): any;
  75616. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75617. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75618. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75619. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75620. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75621. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75622. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75623. // Queries
  75624. createQuery(): WebGLQuery;
  75625. deleteQuery(query: WebGLQuery): void;
  75626. beginQuery(target: number, query: WebGLQuery): void;
  75627. endQuery(target: number): void;
  75628. getQueryParameter(query: WebGLQuery, pname: number): any;
  75629. getQuery(target: number, pname: number): any;
  75630. MAX_SAMPLES: number;
  75631. RGBA8: number;
  75632. READ_FRAMEBUFFER: number;
  75633. DRAW_FRAMEBUFFER: number;
  75634. UNIFORM_BUFFER: number;
  75635. HALF_FLOAT_OES: number;
  75636. RGBA16F: number;
  75637. RGBA32F: number;
  75638. R32F: number;
  75639. RG32F: number;
  75640. RGB32F: number;
  75641. R16F: number;
  75642. RG16F: number;
  75643. RGB16F: number;
  75644. RED: number;
  75645. RG: number;
  75646. R8: number;
  75647. RG8: number;
  75648. UNSIGNED_INT_24_8: number;
  75649. DEPTH24_STENCIL8: number;
  75650. MIN: number;
  75651. MAX: number;
  75652. /* Multiple Render Targets */
  75653. drawBuffers(buffers: number[]): void;
  75654. readBuffer(src: number): void;
  75655. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75656. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75657. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75658. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75659. // Occlusion Query
  75660. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75661. ANY_SAMPLES_PASSED: number;
  75662. QUERY_RESULT_AVAILABLE: number;
  75663. QUERY_RESULT: number;
  75664. }
  75665. interface WebGLProgram {
  75666. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75667. }
  75668. interface EXT_disjoint_timer_query {
  75669. QUERY_COUNTER_BITS_EXT: number;
  75670. TIME_ELAPSED_EXT: number;
  75671. TIMESTAMP_EXT: number;
  75672. GPU_DISJOINT_EXT: number;
  75673. QUERY_RESULT_EXT: number;
  75674. QUERY_RESULT_AVAILABLE_EXT: number;
  75675. queryCounterEXT(query: WebGLQuery, target: number): void;
  75676. createQueryEXT(): WebGLQuery;
  75677. beginQueryEXT(target: number, query: WebGLQuery): void;
  75678. endQueryEXT(target: number): void;
  75679. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75680. deleteQueryEXT(query: WebGLQuery): void;
  75681. }
  75682. interface WebGLUniformLocation {
  75683. _currentState: any;
  75684. }
  75685. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75686. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75687. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75688. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75689. interface WebGLRenderingContext {
  75690. readonly RASTERIZER_DISCARD: number;
  75691. readonly DEPTH_COMPONENT24: number;
  75692. readonly TEXTURE_3D: number;
  75693. readonly TEXTURE_2D_ARRAY: number;
  75694. readonly TEXTURE_COMPARE_FUNC: number;
  75695. readonly TEXTURE_COMPARE_MODE: number;
  75696. readonly COMPARE_REF_TO_TEXTURE: number;
  75697. readonly TEXTURE_WRAP_R: number;
  75698. readonly HALF_FLOAT: number;
  75699. readonly RGB8: number;
  75700. readonly RED_INTEGER: number;
  75701. readonly RG_INTEGER: number;
  75702. readonly RGB_INTEGER: number;
  75703. readonly RGBA_INTEGER: number;
  75704. readonly R8_SNORM: number;
  75705. readonly RG8_SNORM: number;
  75706. readonly RGB8_SNORM: number;
  75707. readonly RGBA8_SNORM: number;
  75708. readonly R8I: number;
  75709. readonly RG8I: number;
  75710. readonly RGB8I: number;
  75711. readonly RGBA8I: number;
  75712. readonly R8UI: number;
  75713. readonly RG8UI: number;
  75714. readonly RGB8UI: number;
  75715. readonly RGBA8UI: number;
  75716. readonly R16I: number;
  75717. readonly RG16I: number;
  75718. readonly RGB16I: number;
  75719. readonly RGBA16I: number;
  75720. readonly R16UI: number;
  75721. readonly RG16UI: number;
  75722. readonly RGB16UI: number;
  75723. readonly RGBA16UI: number;
  75724. readonly R32I: number;
  75725. readonly RG32I: number;
  75726. readonly RGB32I: number;
  75727. readonly RGBA32I: number;
  75728. readonly R32UI: number;
  75729. readonly RG32UI: number;
  75730. readonly RGB32UI: number;
  75731. readonly RGBA32UI: number;
  75732. readonly RGB10_A2UI: number;
  75733. readonly R11F_G11F_B10F: number;
  75734. readonly RGB9_E5: number;
  75735. readonly RGB10_A2: number;
  75736. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75737. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75738. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75739. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75740. readonly DEPTH_COMPONENT32F: number;
  75741. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75742. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75743. 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;
  75744. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75745. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75746. readonly TRANSFORM_FEEDBACK: number;
  75747. readonly INTERLEAVED_ATTRIBS: number;
  75748. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75749. createTransformFeedback(): WebGLTransformFeedback;
  75750. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75751. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75752. beginTransformFeedback(primitiveMode: number): void;
  75753. endTransformFeedback(): void;
  75754. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75755. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75756. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75757. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75758. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75759. }
  75760. interface ImageBitmap {
  75761. readonly width: number;
  75762. readonly height: number;
  75763. close(): void;
  75764. }
  75765. interface WebGLQuery extends WebGLObject {
  75766. }
  75767. declare var WebGLQuery: {
  75768. prototype: WebGLQuery;
  75769. new(): WebGLQuery;
  75770. };
  75771. interface WebGLSampler extends WebGLObject {
  75772. }
  75773. declare var WebGLSampler: {
  75774. prototype: WebGLSampler;
  75775. new(): WebGLSampler;
  75776. };
  75777. interface WebGLSync extends WebGLObject {
  75778. }
  75779. declare var WebGLSync: {
  75780. prototype: WebGLSync;
  75781. new(): WebGLSync;
  75782. };
  75783. interface WebGLTransformFeedback extends WebGLObject {
  75784. }
  75785. declare var WebGLTransformFeedback: {
  75786. prototype: WebGLTransformFeedback;
  75787. new(): WebGLTransformFeedback;
  75788. };
  75789. interface WebGLVertexArrayObject extends WebGLObject {
  75790. }
  75791. declare var WebGLVertexArrayObject: {
  75792. prototype: WebGLVertexArrayObject;
  75793. new(): WebGLVertexArrayObject;
  75794. };
  75795. // Type definitions for WebVR API
  75796. // Project: https://w3c.github.io/webvr/
  75797. // Definitions by: six a <https://github.com/lostfictions>
  75798. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75799. interface VRDisplay extends EventTarget {
  75800. /**
  75801. * Dictionary of capabilities describing the VRDisplay.
  75802. */
  75803. readonly capabilities: VRDisplayCapabilities;
  75804. /**
  75805. * z-depth defining the far plane of the eye view frustum
  75806. * enables mapping of values in the render target depth
  75807. * attachment to scene coordinates. Initially set to 10000.0.
  75808. */
  75809. depthFar: number;
  75810. /**
  75811. * z-depth defining the near plane of the eye view frustum
  75812. * enables mapping of values in the render target depth
  75813. * attachment to scene coordinates. Initially set to 0.01.
  75814. */
  75815. depthNear: number;
  75816. /**
  75817. * An identifier for this distinct VRDisplay. Used as an
  75818. * association point in the Gamepad API.
  75819. */
  75820. readonly displayId: number;
  75821. /**
  75822. * A display name, a user-readable name identifying it.
  75823. */
  75824. readonly displayName: string;
  75825. readonly isConnected: boolean;
  75826. readonly isPresenting: boolean;
  75827. /**
  75828. * If this VRDisplay supports room-scale experiences, the optional
  75829. * stage attribute contains details on the room-scale parameters.
  75830. */
  75831. readonly stageParameters: VRStageParameters | null;
  75832. /**
  75833. * Passing the value returned by `requestAnimationFrame` to
  75834. * `cancelAnimationFrame` will unregister the callback.
  75835. * @param handle Define the hanle of the request to cancel
  75836. */
  75837. cancelAnimationFrame(handle: number): void;
  75838. /**
  75839. * Stops presenting to the VRDisplay.
  75840. * @returns a promise to know when it stopped
  75841. */
  75842. exitPresent(): Promise<void>;
  75843. /**
  75844. * Return the current VREyeParameters for the given eye.
  75845. * @param whichEye Define the eye we want the parameter for
  75846. * @returns the eye parameters
  75847. */
  75848. getEyeParameters(whichEye: string): VREyeParameters;
  75849. /**
  75850. * Populates the passed VRFrameData with the information required to render
  75851. * the current frame.
  75852. * @param frameData Define the data structure to populate
  75853. * @returns true if ok otherwise false
  75854. */
  75855. getFrameData(frameData: VRFrameData): boolean;
  75856. /**
  75857. * Get the layers currently being presented.
  75858. * @returns the list of VR layers
  75859. */
  75860. getLayers(): VRLayer[];
  75861. /**
  75862. * Return a VRPose containing the future predicted pose of the VRDisplay
  75863. * when the current frame will be presented. The value returned will not
  75864. * change until JavaScript has returned control to the browser.
  75865. *
  75866. * The VRPose will contain the position, orientation, velocity,
  75867. * and acceleration of each of these properties.
  75868. * @returns the pose object
  75869. */
  75870. getPose(): VRPose;
  75871. /**
  75872. * Return the current instantaneous pose of the VRDisplay, with no
  75873. * prediction applied.
  75874. * @returns the current instantaneous pose
  75875. */
  75876. getImmediatePose(): VRPose;
  75877. /**
  75878. * The callback passed to `requestAnimationFrame` will be called
  75879. * any time a new frame should be rendered. When the VRDisplay is
  75880. * presenting the callback will be called at the native refresh
  75881. * rate of the HMD. When not presenting this function acts
  75882. * identically to how window.requestAnimationFrame acts. Content should
  75883. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75884. * asynchronously from other displays and at differing refresh rates.
  75885. * @param callback Define the eaction to run next frame
  75886. * @returns the request handle it
  75887. */
  75888. requestAnimationFrame(callback: FrameRequestCallback): number;
  75889. /**
  75890. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75891. * Repeat calls while already presenting will update the VRLayers being displayed.
  75892. * @param layers Define the list of layer to present
  75893. * @returns a promise to know when the request has been fulfilled
  75894. */
  75895. requestPresent(layers: VRLayer[]): Promise<void>;
  75896. /**
  75897. * Reset the pose for this display, treating its current position and
  75898. * orientation as the "origin/zero" values. VRPose.position,
  75899. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75900. * updated when calling resetPose(). This should be called in only
  75901. * sitting-space experiences.
  75902. */
  75903. resetPose(): void;
  75904. /**
  75905. * The VRLayer provided to the VRDisplay will be captured and presented
  75906. * in the HMD. Calling this function has the same effect on the source
  75907. * canvas as any other operation that uses its source image, and canvases
  75908. * created without preserveDrawingBuffer set to true will be cleared.
  75909. * @param pose Define the pose to submit
  75910. */
  75911. submitFrame(pose?: VRPose): void;
  75912. }
  75913. declare var VRDisplay: {
  75914. prototype: VRDisplay;
  75915. new(): VRDisplay;
  75916. };
  75917. interface VRLayer {
  75918. leftBounds?: number[] | Float32Array | null;
  75919. rightBounds?: number[] | Float32Array | null;
  75920. source?: HTMLCanvasElement | null;
  75921. }
  75922. interface VRDisplayCapabilities {
  75923. readonly canPresent: boolean;
  75924. readonly hasExternalDisplay: boolean;
  75925. readonly hasOrientation: boolean;
  75926. readonly hasPosition: boolean;
  75927. readonly maxLayers: number;
  75928. }
  75929. interface VREyeParameters {
  75930. /** @deprecated */
  75931. readonly fieldOfView: VRFieldOfView;
  75932. readonly offset: Float32Array;
  75933. readonly renderHeight: number;
  75934. readonly renderWidth: number;
  75935. }
  75936. interface VRFieldOfView {
  75937. readonly downDegrees: number;
  75938. readonly leftDegrees: number;
  75939. readonly rightDegrees: number;
  75940. readonly upDegrees: number;
  75941. }
  75942. interface VRFrameData {
  75943. readonly leftProjectionMatrix: Float32Array;
  75944. readonly leftViewMatrix: Float32Array;
  75945. readonly pose: VRPose;
  75946. readonly rightProjectionMatrix: Float32Array;
  75947. readonly rightViewMatrix: Float32Array;
  75948. readonly timestamp: number;
  75949. }
  75950. interface VRPose {
  75951. readonly angularAcceleration: Float32Array | null;
  75952. readonly angularVelocity: Float32Array | null;
  75953. readonly linearAcceleration: Float32Array | null;
  75954. readonly linearVelocity: Float32Array | null;
  75955. readonly orientation: Float32Array | null;
  75956. readonly position: Float32Array | null;
  75957. readonly timestamp: number;
  75958. }
  75959. interface VRStageParameters {
  75960. sittingToStandingTransform?: Float32Array;
  75961. sizeX?: number;
  75962. sizeY?: number;
  75963. }
  75964. interface Navigator {
  75965. getVRDisplays(): Promise<VRDisplay[]>;
  75966. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75967. }
  75968. interface Window {
  75969. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75970. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75971. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75972. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75973. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75974. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75975. }
  75976. interface Gamepad {
  75977. readonly displayId: number;
  75978. }
  75979. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  75980. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  75981. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  75982. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  75983. type XRHandedness = "none" | "left" | "right";
  75984. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  75985. type XREye = "none" | "left" | "right";
  75986. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  75987. interface XRSpace extends EventTarget {}
  75988. interface XRRenderState {
  75989. depthNear?: number;
  75990. depthFar?: number;
  75991. inlineVerticalFieldOfView?: number;
  75992. baseLayer?: XRWebGLLayer;
  75993. }
  75994. interface XRInputSource {
  75995. handedness: XRHandedness;
  75996. targetRayMode: XRTargetRayMode;
  75997. targetRaySpace: XRSpace;
  75998. gripSpace: XRSpace | undefined;
  75999. gamepad: Gamepad | undefined;
  76000. profiles: Array<string>;
  76001. hand: XRHand | undefined;
  76002. }
  76003. interface XRSessionInit {
  76004. optionalFeatures?: string[];
  76005. requiredFeatures?: string[];
  76006. }
  76007. interface XRSession {
  76008. addEventListener: Function;
  76009. removeEventListener: Function;
  76010. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76011. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76012. requestAnimationFrame: Function;
  76013. end(): Promise<void>;
  76014. renderState: XRRenderState;
  76015. inputSources: Array<XRInputSource>;
  76016. // hit test
  76017. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76018. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76019. // legacy AR hit test
  76020. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76021. // legacy plane detection
  76022. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76023. }
  76024. interface XRReferenceSpace extends XRSpace {
  76025. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76026. onreset: any;
  76027. }
  76028. type XRPlaneSet = Set<XRPlane>;
  76029. type XRAnchorSet = Set<XRAnchor>;
  76030. interface XRFrame {
  76031. session: XRSession;
  76032. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76033. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76034. // AR
  76035. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76036. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76037. // Anchors
  76038. trackedAnchors?: XRAnchorSet;
  76039. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76040. // Planes
  76041. worldInformation: {
  76042. detectedPlanes?: XRPlaneSet;
  76043. };
  76044. // Hand tracking
  76045. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76046. }
  76047. interface XRViewerPose extends XRPose {
  76048. views: Array<XRView>;
  76049. }
  76050. interface XRPose {
  76051. transform: XRRigidTransform;
  76052. emulatedPosition: boolean;
  76053. }
  76054. interface XRWebGLLayerOptions {
  76055. antialias?: boolean;
  76056. depth?: boolean;
  76057. stencil?: boolean;
  76058. alpha?: boolean;
  76059. multiview?: boolean;
  76060. framebufferScaleFactor?: number;
  76061. }
  76062. declare var XRWebGLLayer: {
  76063. prototype: XRWebGLLayer;
  76064. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76065. };
  76066. interface XRWebGLLayer {
  76067. framebuffer: WebGLFramebuffer;
  76068. framebufferWidth: number;
  76069. framebufferHeight: number;
  76070. getViewport: Function;
  76071. }
  76072. declare class XRRigidTransform {
  76073. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76074. position: DOMPointReadOnly;
  76075. orientation: DOMPointReadOnly;
  76076. matrix: Float32Array;
  76077. inverse: XRRigidTransform;
  76078. }
  76079. interface XRView {
  76080. eye: XREye;
  76081. projectionMatrix: Float32Array;
  76082. transform: XRRigidTransform;
  76083. }
  76084. interface XRInputSourceChangeEvent {
  76085. session: XRSession;
  76086. removed: Array<XRInputSource>;
  76087. added: Array<XRInputSource>;
  76088. }
  76089. interface XRInputSourceEvent extends Event {
  76090. readonly frame: XRFrame;
  76091. readonly inputSource: XRInputSource;
  76092. }
  76093. // Experimental(er) features
  76094. declare class XRRay {
  76095. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76096. origin: DOMPointReadOnly;
  76097. direction: DOMPointReadOnly;
  76098. matrix: Float32Array;
  76099. }
  76100. declare enum XRHitTestTrackableType {
  76101. "point",
  76102. "plane",
  76103. "mesh",
  76104. }
  76105. interface XRHitResult {
  76106. hitMatrix: Float32Array;
  76107. }
  76108. interface XRTransientInputHitTestResult {
  76109. readonly inputSource: XRInputSource;
  76110. readonly results: Array<XRHitTestResult>;
  76111. }
  76112. interface XRHitTestResult {
  76113. getPose(baseSpace: XRSpace): XRPose | undefined;
  76114. // When anchor system is enabled
  76115. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76116. }
  76117. interface XRHitTestSource {
  76118. cancel(): void;
  76119. }
  76120. interface XRTransientInputHitTestSource {
  76121. cancel(): void;
  76122. }
  76123. interface XRHitTestOptionsInit {
  76124. space: XRSpace;
  76125. entityTypes?: Array<XRHitTestTrackableType>;
  76126. offsetRay?: XRRay;
  76127. }
  76128. interface XRTransientInputHitTestOptionsInit {
  76129. profile: string;
  76130. entityTypes?: Array<XRHitTestTrackableType>;
  76131. offsetRay?: XRRay;
  76132. }
  76133. interface XRAnchor {
  76134. anchorSpace: XRSpace;
  76135. delete(): void;
  76136. }
  76137. interface XRPlane {
  76138. orientation: "Horizontal" | "Vertical";
  76139. planeSpace: XRSpace;
  76140. polygon: Array<DOMPointReadOnly>;
  76141. lastChangedTime: number;
  76142. }
  76143. interface XRJointSpace extends XRSpace {}
  76144. interface XRJointPose extends XRPose {
  76145. radius: number | undefined;
  76146. }
  76147. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76148. readonly length: number;
  76149. [index: number]: XRJointSpace;
  76150. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76151. readonly WRIST: number;
  76152. readonly THUMB_METACARPAL: number;
  76153. readonly THUMB_PHALANX_PROXIMAL: number;
  76154. readonly THUMB_PHALANX_DISTAL: number;
  76155. readonly THUMB_PHALANX_TIP: number;
  76156. readonly INDEX_METACARPAL: number;
  76157. readonly INDEX_PHALANX_PROXIMAL: number;
  76158. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76159. readonly INDEX_PHALANX_DISTAL: number;
  76160. readonly INDEX_PHALANX_TIP: number;
  76161. readonly MIDDLE_METACARPAL: number;
  76162. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76163. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76164. readonly MIDDLE_PHALANX_DISTAL: number;
  76165. readonly MIDDLE_PHALANX_TIP: number;
  76166. readonly RING_METACARPAL: number;
  76167. readonly RING_PHALANX_PROXIMAL: number;
  76168. readonly RING_PHALANX_INTERMEDIATE: number;
  76169. readonly RING_PHALANX_DISTAL: number;
  76170. readonly RING_PHALANX_TIP: number;
  76171. readonly LITTLE_METACARPAL: number;
  76172. readonly LITTLE_PHALANX_PROXIMAL: number;
  76173. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76174. readonly LITTLE_PHALANX_DISTAL: number;
  76175. readonly LITTLE_PHALANX_TIP: number;
  76176. }
  76177. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76178. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76179. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76180. interface XRSession {
  76181. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76182. }
  76183. interface XRFrame {
  76184. featurePointCloud? : Array<number>;
  76185. }